You are here

public function GlobalTemplateCollectionManager::getLocalCollection in Courier 2.x

Same name and namespace in other branches
  1. 8 src/Service/GlobalTemplateCollectionManager.php \Drupal\courier\Service\GlobalTemplateCollectionManager::getLocalCollection()

Locate, and optionally instantiate, a local template collection to associate a global template collection.

Parameters

\Drupal\courier\Entity\GlobalTemplateCollectionInterface $global_template_collection: A global template collection entity.

Return value

\Drupal\courier\TemplateCollectionInterface A template collection entity.

Throws

\Drupal\courier\Exception\GlobalTemplateCollectionException Thrown if passed global template collection is unsaved.

Overrides GlobalTemplateCollectionManagerInterface::getLocalCollection

File

src/Service/GlobalTemplateCollectionManager.php, line 119

Class

GlobalTemplateCollectionManager
The global template collection manager.

Namespace

Drupal\courier\Service

Code

public function getLocalCollection(GlobalTemplateCollectionInterface $global_template_collection) {
  $template_collection_id = $this->keyValueStore
    ->get($global_template_collection
    ->id());
  if ($template_collection_id) {
    $template_collection = TemplateCollection::load($template_collection_id);
    if ($template_collection) {
      return $template_collection;
    }
  }
  return $this
    ->createLocalCollectionForGlobalCollection($global_template_collection);
}