Skip to content
Snippets Groups Projects
Verified Commit 001e3935 authored by lysenko's avatar lysenko Committed by Luhur Abdi Rizal
Browse files

Issue #3377519 by Lysenko, el7cosmos: TypeError:...

Issue #3377519 by Lysenko, el7cosmos: TypeError: Drupal\core_event_dispatcher\Event\Entity\EntityFieldAccessEvent::getItems(): Return value must be of type Drupal\Core\Field\FieldItemListInterface, null returned in Drupal\core_event_dispatcher\Event\Entity\EntityFieldAccessEvent->getItems() (
parent 5de42bd5
No related branches found
Tags 4.0.0
No related merge requests found
......@@ -81,10 +81,10 @@ class EntityFieldAccessEvent extends Event implements EventInterface, AccessEven
/**
* Get the items.
*
* @return \Drupal\Core\Field\FieldItemListInterface
* @return null|\Drupal\Core\Field\FieldItemListInterface
* The items.
*/
public function getItems(): FieldItemListInterface {
public function getItems(): ?FieldItemListInterface {
return $this->items;
}
......
......@@ -146,4 +146,28 @@ class EntityFieldAccessEventTest extends KernelTestBase {
];
}
/**
* Field access event with no items.
*
* @throws \Exception
*/
public function testEntityFieldAccessEventWithNoItems(): void {
$this->listen(EntityHookEvents::ENTITY_FIELD_ACCESS, 'onEntityFieldAccessEventWithNoItems');
$accessControlHandler = $this->container->get('entity_type.manager')
->getAccessControlHandler('entity_test');
$accessControlHandler->fieldAccess($this->operation, $this->fieldDefinition, NULL, NULL, TRUE);
}
/**
* Callback for EntityFieldAccessEvent.
*
* @param \Drupal\core_event_dispatcher\Event\Entity\EntityFieldAccessEvent $event
* The event.
*/
public function onEntityFieldAccessEventWithNoItems(EntityFieldAccessEvent $event): void {
$this->assertNull($event->getItems());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment