You are here

class MediaScheduler in Scheduler 2.x

Plugin for Media entity type.

@package Drupal\Scheduler\Plugin\Scheduler

Plugin annotation


@SchedulerPlugin(
 id = "media_scheduler",
 label = @Translation("Media Scheduler Plugin"),
 description = @Translation("Provides support for scheduling media entities"),
 entityType = "media",
 typeFieldName = "bundle",
 dependency = "media",
 develGenerateForm = "devel_generate_form_media",
 userViewRoute = "view.scheduler_scheduled_media.user_page",
)

Hierarchy

Expanded class hierarchy of MediaScheduler

File

src/Plugin/Scheduler/MediaScheduler.php, line 24

Namespace

Drupal\scheduler\Plugin\Scheduler
View source
class MediaScheduler extends SchedulerPluginBase implements ContainerFactoryPluginInterface {

  /**
   * Get the available types/bundles for the entity type.
   *
   * Do not use static or drupal_static here, because changes to third-party
   * settings invalidate the saved values during phpunit testing.
   *
   * @return array
   *   The media bundle objects, keyed by bundle name, or an empty array if
   *   Media is not enabled.
   */
  public function getTypes() {
    if (!\Drupal::moduleHandler()
      ->moduleExists('media')) {
      return [];
    }
    $mediaTypes = \Drupal::entityTypeManager()
      ->getStorage('media_type')
      ->loadMultiple();
    return $mediaTypes;
  }

  /**
   * Get the form IDs for media add/edit forms.
   *
   * @return array
   *   The list of form IDs, or an empty array if Media is not enabled.
   */
  public function entityFormIds() {
    if (!\Drupal::moduleHandler()
      ->moduleExists('media')) {
      return [];
    }
    static $ids;
    if (!isset($ids)) {
      $ids = [];
      $types = array_keys($this
        ->getTypes());
      foreach ($types as $typeId) {
        $ids[] = 'media_' . $typeId . '_add_form';
        $ids[] = 'media_' . $typeId . '_edit_form';
      }
    }
    return $ids;
  }

  /**
   * Get the form IDs for media type forms.
   *
   * @return array
   *   The list of form IDs, or an empty array if Media is not enabled.
   */
  public function entityTypeFormIds() {
    if (!\Drupal::moduleHandler()
      ->moduleExists('media')) {
      return [];
    }
    return [
      'media_type_add_form',
      'media_type_edit_form',
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
MediaScheduler::entityFormIds public function Get the form IDs for media add/edit forms. Overrides SchedulerPluginBase::entityFormIds
MediaScheduler::entityTypeFormIds public function Get the form IDs for media type forms. Overrides SchedulerPluginBase::entityTypeFormIds
MediaScheduler::getTypes public function Get the available types/bundles for the entity type. Overrides SchedulerPluginBase::getTypes
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 98
SchedulerPluginBase::create public static function Create method.
SchedulerPluginBase::dependency public function Get module dependency. Overrides SchedulerPluginInterface::dependency
SchedulerPluginBase::description public function Get the plugin description. Overrides SchedulerPluginInterface::description
SchedulerPluginBase::develGenerateForm public function Get the id of the Devel Generate form for this entity type. Overrides SchedulerPluginInterface::develGenerateForm
SchedulerPluginBase::entityType public function Get the type of entity supported by this plugin. Overrides SchedulerPluginInterface::entityType
SchedulerPluginBase::label public function Get plugin label. Overrides SchedulerPluginInterface::label
SchedulerPluginBase::publishAction public function Get the publish action name of the entity type. Overrides SchedulerPluginInterface::publishAction
SchedulerPluginBase::schedulerEventClass public function Get the Scheduler event class. Overrides SchedulerPluginInterface::schedulerEventClass
SchedulerPluginBase::typeFieldName public function Get the name of the "type" field for the entity. Overrides SchedulerPluginInterface::typeFieldName
SchedulerPluginBase::unpublishAction public function Get the unpublish action name of the entity type. Overrides SchedulerPluginInterface::unpublishAction
SchedulerPluginBase::userViewRoute public function Get the route of the scheduled view on the user profile page. Overrides SchedulerPluginInterface::userViewRoute
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.