Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Drupal\Core\DependencyInjection; use Symfony\Component\DependencyInjecti..
Decoded Output download
<?php
namespace Drupal\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides dependency injection friendly methods for serialization.
*/
trait DependencySerializationTrait {
/**
* An array of service IDs keyed by property name used for serialization.
*
* @var array
*/
protected $_serviceIds = [];
/**
* {@inheritdoc}
*/
public function __sleep() {
$this->_serviceIds = [];
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value) && isset($value->_serviceId)) {
// If a class member was instantiated by the dependency injection
// container, only store its ID so it can be used to get a fresh object
// on unserialization.
$this->_serviceIds[$key] = $value->_serviceId;
unset($vars[$key]);
}
// Special case the container, which might not have a service ID.
elseif ($value instanceof ContainerInterface) {
$this->_serviceIds[$key] = 'service_container';
unset($vars[$key]);
}
}
return array_keys($vars);
}
/**
* {@inheritdoc}
*/
public function __wakeup() {
// Tests in isolation potentially unserialize in the parent process.
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP']) && !\Drupal::hasContainer()) {
return;
}
$container = \Drupal::getContainer();
foreach ($this->_serviceIds as $key => $service_id) {
$this->$key = $container->get($service_id);
}
$this->_serviceIds = [];
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Drupal\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides dependency injection friendly methods for serialization.
*/
trait DependencySerializationTrait {
/**
* An array of service IDs keyed by property name used for serialization.
*
* @var array
*/
protected $_serviceIds = [];
/**
* {@inheritdoc}
*/
public function __sleep() {
$this->_serviceIds = [];
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value) && isset($value->_serviceId)) {
// If a class member was instantiated by the dependency injection
// container, only store its ID so it can be used to get a fresh object
// on unserialization.
$this->_serviceIds[$key] = $value->_serviceId;
unset($vars[$key]);
}
// Special case the container, which might not have a service ID.
elseif ($value instanceof ContainerInterface) {
$this->_serviceIds[$key] = 'service_container';
unset($vars[$key]);
}
}
return array_keys($vars);
}
/**
* {@inheritdoc}
*/
public function __wakeup() {
// Tests in isolation potentially unserialize in the parent process.
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP']) && !\Drupal::hasContainer()) {
return;
}
$container = \Drupal::getContainer();
foreach ($this->_serviceIds as $key => $service_id) {
$this->$key = $container->get($service_id);
}
$this->_serviceIds = [];
}
}
Function Calls
None |
Stats
MD5 | 6348352cbadd81717d469e16ab0b7765 |
Eval Count | 0 |
Decode Time | 91 ms |