/** * Constructs a EntityAliasTypeBase instance. * * @param array $configuration * A configuration array containing information about the plugin instance. * @param string $plugin_id * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager service. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager service. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->moduleHandler = $module_handler; $this->languageManager = $language_manager; $this->entityTypeManager = $entity_type_manager; }
/** * Overrides the parent constructor to populate context definitions. * * Expression plugins can be configured to have arbitrary context definitions. * * @param array $configuration * The plugin configuration, i.e. an array with configuration values keyed * by configuration option name. The special key 'context_definitions' may * be used to initialize the context definitions by setting it to an array * of definitions keyed by context names. * @param string $plugin_id * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. */ public function __construct(array $configuration, $plugin_id, $plugin_definition) { if (isset($configuration['context_definitions'])) { $plugin_definition['context'] = $this->createContextDefinitions($configuration['context_definitions']); } if (isset($configuration['provided_definitions'])) { $plugin_definition['provides'] = $this->createContextDefinitions($configuration['provided_definitions']); } parent::__construct($configuration, $plugin_id, $plugin_definition); }
/** * {@inheritdoc} */ public function getContextValue($name) { try { return parent::getContextValue($name); } catch (ContextException $e) { // Catch the undocumented exception thrown when no context value is set // for a required context. // @todo: Remove once https://www.drupal.org/node/2677162 is fixed. if (strpos($e->getMessage(), 'context is required') === FALSE) { throw $e; } } }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { /** @var \Drupal\rng\RuleComponentInterface $component */ $component = $this->getEntity(); $is_new = $component->isNew(); $plugin_configuration = $this->plugin->getConfiguration(); $component->setConfiguration($plugin_configuration); $component->save(); $type = $this->entity->getType(); $types = ['action' => $this->t('Action'), 'condition' => $this->t('Condition')]; $t_args = ['@type' => isset($types[$type]) ? $types[$type] : $this->t('Component')]; if ($is_new) { drupal_set_message(t('@type created.', $t_args)); } else { drupal_set_message(t('@type updated.', $t_args)); } }
/** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->setConfiguration($configuration); }
/** * {@inheritdoc} */ public function getCacheMaxAge() { $max_age = parent::getCacheMaxAge(); // @todo Configurability of this will be removed in // https://www.drupal.org/node/2458763. return Cache::mergeMaxAges($max_age, (int) $this->configuration['cache']['max_age']); }