You are here

class CommerceProductScheduler in Scheduler 2.x

Plugin for Commerce Product entity type.

@package Drupal\Scheduler\Plugin\Scheduler

Plugin annotation


@SchedulerPlugin(
 id = "commerce_product_scheduler",
 label = @Translation("Commerce Product Scheduler Plugin"),
 description = @Translation("Provides support for scheduling Commerce Product entities"),
 entityType = "commerce_product",
 typeFieldName = "type",
 dependency = "commerce_product",
 schedulerEventClass = "\Drupal\scheduler\Event\SchedulerCommerceProductEvents",
 publishAction = "commerce_publish_product",
 unpublishAction = "commerce_unpublish_product"
)

Hierarchy

Expanded class hierarchy of CommerceProductScheduler

File

src/Plugin/Scheduler/CommerceProductScheduler.php, line 25

Namespace

Drupal\scheduler\Plugin\Scheduler
View source
class CommerceProductScheduler 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 commerce product bundle objects, keyed by bundle name, or an empty
   *   array if Commerce is not enabled.
   */
  public function getTypes() {
    if (!\Drupal::moduleHandler()
      ->moduleExists('commerce')) {
      return [];
    }
    $productTypes = \Drupal::entityTypeManager()
      ->getStorage('commerce_product_type')
      ->loadMultiple();
    return $productTypes;
  }

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

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

}

Members

Namesort descending Modifiers Type Description Overrides
CommerceProductScheduler::entityFormIds public function Get the form IDs for commerce product add/edit forms. Overrides SchedulerPluginBase::entityFormIds
CommerceProductScheduler::entityTypeFormIds public function Get the form IDs for commerce product type forms. Overrides SchedulerPluginBase::entityTypeFormIds
CommerceProductScheduler::getTypes public function Get the available types/bundles for the entity type. Overrides SchedulerPluginBase::getTypes
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
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.