You are here

class LayoutParagraphsTempstoreParamConverter in Layout Paragraphs 2.0.x

Layout paragraphs tempstore param converter service.

@internal Tagged services are internal.

Hierarchy

Expanded class hierarchy of LayoutParagraphsTempstoreParamConverter

1 string reference to 'LayoutParagraphsTempstoreParamConverter'
layout_paragraphs.services.yml in ./layout_paragraphs.services.yml
layout_paragraphs.services.yml
1 service uses LayoutParagraphsTempstoreParamConverter
layout_paragraphs.param_converter.tempstore in ./layout_paragraphs.services.yml
Drupal\layout_paragraphs\Routing\LayoutParagraphsTempstoreParamConverter

File

src/Routing/LayoutParagraphsTempstoreParamConverter.php, line 17

Namespace

Drupal\layout_paragraphs\Routing
View source
class LayoutParagraphsTempstoreParamConverter implements ParamConverterInterface {

  /**
   * The layout paragraphs layout tempstore.
   *
   * @var \Drupal\layout_paragraphs\LayoutParagraphsLayoutTempstoreRepository
   */
  protected $layoutParagraphsLayoutTempstore;

  /**
   * The Entity Type Manager service.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface;
   */
  protected $entityTypeManager;

  /**
   * Constructs a new LayoutParagraphsEditorTempstoreParamConverter.
   *
   * @param \Drupal\layout_paragraphs\LayoutParagraphsLayoutTempstoreRepository $layout_paragraphs_layout_tempstore
   *   The layout tempstore repository.
   */
  public function __construct(LayoutParagraphsLayoutTempstoreRepository $layout_paragraphs_layout_tempstore, EntityTypeManagerInterface $entity_type_manager) {
    $this->layoutParagraphsLayoutTempstore = $layout_paragraphs_layout_tempstore;
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function convert($value, $definition, $name, array $defaults) {
    if (empty($defaults['layout_paragraphs_layout'])) {
      return NULL;
    }
    $key = $defaults['layout_paragraphs_layout'];
    return $this->layoutParagraphsLayoutTempstore
      ->getWithStorageKey($key);
  }

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, Route $route) {
    return !empty($definition['layout_paragraphs_layout_tempstore']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LayoutParagraphsTempstoreParamConverter::$entityTypeManager protected property The Entity Type Manager service.
LayoutParagraphsTempstoreParamConverter::$layoutParagraphsLayoutTempstore protected property The layout paragraphs layout tempstore.
LayoutParagraphsTempstoreParamConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
LayoutParagraphsTempstoreParamConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert
LayoutParagraphsTempstoreParamConverter::__construct public function Constructs a new LayoutParagraphsEditorTempstoreParamConverter.