comparison core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents 129ea1e6d783
children
comparison
equal deleted inserted replaced
17:129ea1e6d783 18:af1871eacc83
6 use Drupal\block_content\BlockContentInterface; 6 use Drupal\block_content\BlockContentInterface;
7 use Drupal\block_content\Event\BlockContentGetDependencyEvent; 7 use Drupal\block_content\Event\BlockContentGetDependencyEvent;
8 use Drupal\Core\Database\Connection; 8 use Drupal\Core\Database\Connection;
9 use Drupal\Core\Entity\EntityInterface; 9 use Drupal\Core\Entity\EntityInterface;
10 use Drupal\Core\Entity\EntityTypeManagerInterface; 10 use Drupal\Core\Entity\EntityTypeManagerInterface;
11 use Drupal\layout_builder\InlineBlockUsage; 11 use Drupal\layout_builder\InlineBlockUsageInterface;
12 use Drupal\layout_builder\LayoutEntityHelperTrait; 12 use Drupal\layout_builder\LayoutEntityHelperTrait;
13 use Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface;
13 use Symfony\Component\EventDispatcher\EventSubscriberInterface; 14 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
14 15
15 /** 16 /**
16 * An event subscriber that returns an access dependency for inline blocks. 17 * An event subscriber that returns an access dependency for inline blocks.
17 * 18 *
24 * to a content block via a field that is using the private file system. The 25 * to a content block via a field that is using the private file system. The
25 * file access handler will evaluate access on the content block without setting 26 * file access handler will evaluate access on the content block without setting
26 * the dependency. 27 * the dependency.
27 * 28 *
28 * @internal 29 * @internal
30 * Tagged services are internal.
29 * 31 *
30 * @see \Drupal\file\FileAccessControlHandler::checkAccess() 32 * @see \Drupal\file\FileAccessControlHandler::checkAccess()
31 * @see \Drupal\block_content\BlockContentAccessControlHandler::checkAccess() 33 * @see \Drupal\block_content\BlockContentAccessControlHandler::checkAccess()
32 */ 34 */
33 class SetInlineBlockDependency implements EventSubscriberInterface { 35 class SetInlineBlockDependency implements EventSubscriberInterface {
49 protected $database; 51 protected $database;
50 52
51 /** 53 /**
52 * The inline block usage service. 54 * The inline block usage service.
53 * 55 *
54 * @var \Drupal\layout_builder\InlineBlockUsage 56 * @var \Drupal\layout_builder\InlineBlockUsageInterface
55 */ 57 */
56 protected $usage; 58 protected $usage;
57 59
58 /** 60 /**
59 * Constructs SetInlineBlockDependency object. 61 * Constructs SetInlineBlockDependency object.
60 * 62 *
61 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager 63 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
62 * The entity type manager. 64 * The entity type manager.
63 * @param \Drupal\Core\Database\Connection $database 65 * @param \Drupal\Core\Database\Connection $database
64 * The database connection. 66 * The database connection.
65 * @param \Drupal\layout_builder\InlineBlockUsage $usage 67 * @param \Drupal\layout_builder\InlineBlockUsageInterface $usage
66 * The inline block usage service. 68 * The inline block usage service.
69 * @param \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface $section_storage_manager
70 * The section storage manager.
67 */ 71 */
68 public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, InlineBlockUsage $usage) { 72 public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, InlineBlockUsageInterface $usage, SectionStorageManagerInterface $section_storage_manager) {
69 $this->entityTypeManager = $entity_type_manager; 73 $this->entityTypeManager = $entity_type_manager;
70 $this->database = $database; 74 $this->database = $database;
71 $this->usage = $usage; 75 $this->usage = $usage;
76 $this->sectionStorageManager = $section_storage_manager;
72 } 77 }
73 78
74 /** 79 /**
75 * {@inheritdoc} 80 * {@inheritdoc}
76 */ 81 */
122 if (empty($layout_entity_info)) { 127 if (empty($layout_entity_info)) {
123 // If the block does not have usage information then we cannot set a 128 // If the block does not have usage information then we cannot set a
124 // dependency. It may be used by another module besides layout builder. 129 // dependency. It may be used by another module besides layout builder.
125 return NULL; 130 return NULL;
126 } 131 }
127 /** @var \Drupal\layout_builder\InlineBlockUsage $usage */
128 $layout_entity_storage = $this->entityTypeManager->getStorage($layout_entity_info->layout_entity_type); 132 $layout_entity_storage = $this->entityTypeManager->getStorage($layout_entity_info->layout_entity_type);
129 $layout_entity = $layout_entity_storage->load($layout_entity_info->layout_entity_id); 133 $layout_entity = $layout_entity_storage->load($layout_entity_info->layout_entity_id);
130 if ($this->isLayoutCompatibleEntity($layout_entity)) { 134 if ($this->isLayoutCompatibleEntity($layout_entity)) {
131 if ($this->isBlockRevisionUsedInEntity($layout_entity, $block_content)) { 135 if ($this->isBlockRevisionUsedInEntity($layout_entity, $block_content)) {
132 return $layout_entity; 136 return $layout_entity;