Skip to content
Snippets Groups Projects

3261263 Added mapbuilder service with appropriate interface, updated map controller

4 files
+ 206
3
Compare changes
  • Side-by-side
  • Inline

Files

+ 30
3
@@ -8,20 +8,46 @@ use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\entity_reference_map\EntityReferenceMapBuilderInterface;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Map controller.
*/
class EntityReferenceMapController extends ControllerBase {
/**
* EntityReferenceMapBuilder service.
*
* @var \Drupal\entity_reference_map\EntityReferenceMapBuilderInterface
*/
protected EntityReferenceMapBuilderInterface $entityReferenceMapBuilder;
/**
* Constructs EntityReferenceMapController object.
*
* @param \Drupal\entity_reference_map\EntityReferenceMapBuilderInterface $entity_reference_map_builder
*
*/
public function __construct(EntityReferenceMapBuilderInterface $entity_reference_map_builder) {
$this->entityReferenceMapBuilder = $entity_reference_map_builder;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_reference_map.builder')
);
}
/**
* Builds a block for rendering map content.
*/
public function mapOverview(NodeInterface $node) {
// @todo: Replace empty array for the result of a build method.
// Issue - https://www.drupal.org/project/3259790/issues/3261219.
$tree = [];
$tree = $this->entityReferenceMapBuilder->build($node);
$tree_id = Html::getUniqueId('tree');
return [
@@ -59,4 +85,5 @@ class EntityReferenceMapController extends ControllerBase {
$account->hasPermission("view node map page in {$node->getType()}")
Please register or sign in to reply
);
}
}
Loading