You are here

public static function TemplateCollection::getTemplateCollectionForTemplate in Courier 8

Same name and namespace in other branches
  1. 2.x src/Entity/TemplateCollection.php \Drupal\courier\Entity\TemplateCollection::getTemplateCollectionForTemplate()

Locates the template collection which references a template.

Parameters

\Drupal\courier\ChannelInterface $template: A template entity.

Return value

\Drupal\courier\Entity\TemplateCollection|NULL A template collection entity, or NULL if the template is an orphan.

Overrides TemplateCollectionInterface::getTemplateCollectionForTemplate

3 calls to TemplateCollection::getTemplateCollectionForTemplate()
courier_entity_predelete in ./courier.module
Implements hook_entity_predelete().
EmailForm::form in src/Form/EmailForm.php
Gets the actual form array to be built.
GlobalTemplateCollectionManager::getGlobalCollectionForTemplate in src/Service/GlobalTemplateCollectionManager.php
Get the global template collection associated with a template.

File

src/Entity/TemplateCollection.php, line 126

Class

TemplateCollection
Defines a local template collection entity.

Namespace

Drupal\courier\Entity

Code

public static function getTemplateCollectionForTemplate(ChannelInterface $template) {
  $ids = \Drupal::entityManager()
    ->getStorage('courier_template_collection')
    ->getQuery()
    ->condition('templates.target_type', $template
    ->getEntityTypeId(), '=')
    ->condition('templates.target_id', $template
    ->id(), '=')
    ->execute();
  return $ids ? static::load(reset($ids)) : NULL;
}