function EntityReferenceItemBase::__get
Overrides FieldItemBase::__get
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ EntityReferenceItemBase.php, line 20
Class
- EntityReferenceItemBase
- Base class for field items referencing other entities.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
public function __get($property_name) {
// This is a workaround for a PHP bug where a fiber suspend from within a
// __get() call can incorrectly trigger PHP's recursion guarding.
// See https://github.com/php/php-src/issues/14983
if ($property_name === 'entity' && \Fiber::getCurrent()) {
$fiber = new \Fiber(fn() => parent::__get($property_name));
$fiber->start();
while (!$fiber->isTerminated()) {
if ($fiber->isSuspended()) {
$resume_type = $fiber->resume();
if (!$fiber->isTerminated() && $resume_type !== FiberResumeType::Immediate) {
usleep(500);
}
}
}
return $fiber->getReturn();
}
return parent::__get($property_name);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.