public function DependencySerializationTrait::__wakeup in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php \Drupal\Core\DependencyInjection\DependencySerializationTrait::__wakeup()
- 9 core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php \Drupal\Core\DependencyInjection\DependencySerializationTrait::__wakeup()
1 call to DependencySerializationTrait::__wakeup()
- TermStorage::__wakeup in core/
modules/ taxonomy/ src/ TermStorage.php
2 methods override DependencySerializationTrait::__wakeup()
- EntityDisplayBase::__wakeup in core/
lib/ Drupal/ Core/ Entity/ EntityDisplayBase.php - TermStorage::__wakeup in core/
modules/ taxonomy/ src/ TermStorage.php
File
- core/
lib/ Drupal/ Core/ DependencyInjection/ DependencySerializationTrait.php, line 68
Class
- DependencySerializationTrait
- Provides dependency injection friendly methods for serialization.
Namespace
Drupal\Core\DependencyInjectionCode
public function __wakeup() {
// Tests in isolation potentially unserialize in the parent process.
$phpunit_bootstrap = isset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
if ($phpunit_bootstrap && !\Drupal::hasContainer()) {
return;
}
$container = \Drupal::getContainer();
foreach ($this->_serviceIds as $key => $service_id) {
// In rare cases, when test data is serialized in the parent process,
// there is a service container but it doesn't contain all expected
// services. To avoid fatal errors during the wrap-up of failing tests, we
// check for this case, too.
if ($phpunit_bootstrap && !$container
->has($service_id)) {
continue;
}
$this->{$key} = $container
->get($service_id);
}
$this->_serviceIds = [];
// In rare cases, when test data is serialized in the parent process, there
// is a service container but it doesn't contain all expected services. To
// avoid fatal errors during the wrap-up of failing tests, we check for this
// case, too.
if ($this->_entityStorages && (!$phpunit_bootstrap || $container
->has('entity_type.manager'))) {
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $container
->get('entity_type.manager');
foreach ($this->_entityStorages as $key => $entity_type_id) {
$this->{$key} = $entity_type_manager
->getStorage($entity_type_id);
}
}
$this->_entityStorages = [];
}