diff --git a/src/Plugin/Condition/MediaIsPublished.php b/src/Plugin/Condition/MediaIsPublished.php new file mode 100644 index 0000000..d698d12 --- /dev/null +++ b/src/Plugin/Condition/MediaIsPublished.php @@ -0,0 +1,96 @@ +entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function evaluate() { + $media = $this->getContextValue('media'); + if (!$media && !$this->isNegated()) { + return FALSE; + } + elseif (!$media) { + return FALSE; + } + else { + return $media->isPublished(); + } + } + + /** + * {@inheritdoc} + */ + public function summary() { + if (!empty($this->configuration['negate'])) { + return $this->t('The media is not published.'); + } + else { + return $this->t('The media is published.'); + } + } + +} + diff --git a/src/Plugin/Condition/TaxonomyTermIsPublished.php b/src/Plugin/Condition/TaxonomyTermIsPublished.php new file mode 100644 index 0000000..48f6921 --- /dev/null +++ b/src/Plugin/Condition/TaxonomyTermIsPublished.php @@ -0,0 +1,96 @@ +entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function evaluate() { + $taxonomy_term = $this->getContextValue('taxonomy_term'); + if (!$taxonomy_term && !$this->isNegated()) { + return FALSE; + } + elseif (!$taxonomy_term) { + return FALSE; + } + else { + return $taxonomy_term->isPublished(); + } + } + + /** + * {@inheritdoc} + */ + public function summary() { + if (!empty($this->configuration['negate'])) { + return $this->t('The taxonomy term is not published.'); + } + else { + return $this->t('The taxonomy term is published.'); + } + } + +} +