LayoutParagraphsTempstoreParamConverter.php in Layout Paragraphs 2.0.x
File
src/Routing/LayoutParagraphsTempstoreParamConverter.php
View source
<?php
namespace Drupal\layout_paragraphs\Routing;
use Symfony\Component\Routing\Route;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\layout_paragraphs\LayoutParagraphsLayout;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\layout_paragraphs\LayoutParagraphsLayoutTempstoreRepository;
class LayoutParagraphsTempstoreParamConverter implements ParamConverterInterface {
protected $layoutParagraphsLayoutTempstore;
protected $entityTypeManager;
public function __construct(LayoutParagraphsLayoutTempstoreRepository $layout_paragraphs_layout_tempstore, EntityTypeManagerInterface $entity_type_manager) {
$this->layoutParagraphsLayoutTempstore = $layout_paragraphs_layout_tempstore;
$this->entityTypeManager = $entity_type_manager;
}
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);
}
public function applies($definition, $name, Route $route) {
return !empty($definition['layout_paragraphs_layout_tempstore']);
}
}