Пример #1
0
 /**
  * Gets the template collection from an action on the rule.
  *
  * @param \Drupal\rng\RuleInterface $rule
  *   The rule.
  *
  * @return \Drupal\courier\TemplateCollectionInterface|NULL
  *   A template collection entity, or NULL if no template collection is
  *   associated.
  */
 protected function getTemplateCollectionForRule(RuleInterface $rule)
 {
     foreach ($rule->getActions() as $action) {
         $conf = $action->getConfiguration();
         $id = $conf['template_collection'];
         if ($id && ($template_collection = TemplateCollection::load($id))) {
             return $template_collection;
         }
     }
     return NULL;
 }
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $configuration = $this->getConfiguration();
     // Create new.
     if (!isset($configuration['template_collection'])) {
         $template_collection = TemplateCollection::create();
         if ($template_collection->save()) {
             $this->courierManager->addTemplates($template_collection);
             $template_collection->save();
         }
         $this->configuration['template_collection'] = $template_collection->id();
     }
 }