protected function ProxyLogicTest::getSuggestedInitializerImplementation in Plug 7
Retrieves the suggested implementation of an initializer that proxy factories in O*M are currently following, and that should be used to initialize the current proxy object
Return value
\Closure
4 calls to ProxyLogicTest::getSuggestedInitializerImplementation()
- ProxyLogicTest::testFailedLoadingWillThrowException in lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyLogicTest.php - ProxyLogicTest::testInitializationRestoresDefaultPublicLazyLoadedFieldValues in lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyLogicTest.php - ProxyLogicTest::testInitializedProxyUnserialization in lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyLogicTest.php - ProxyLogicTest::testLoadingWithPersisterWillBeTriggeredOnlyOnce in lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyLogicTest.php
File
- lib/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Proxy/ ProxyLogicTest.php, line 718
Class
- ProxyLogicTest
- Test the generated proxies behavior. These tests make assumptions about the structure of LazyLoadableObject
Namespace
Doctrine\Tests\Common\ProxyCode
protected function getSuggestedInitializerImplementation() {
$loader = $this->proxyLoader;
$identifier = $this->identifier;
return function (LazyLoadableObject $proxy) use ($loader, $identifier) {
/* @var $proxy LazyLoadableObject|Proxy */
$proxy
->__setInitializer(null);
$proxy
->__setCloner(null);
if ($proxy
->__isInitialized()) {
return;
}
$properties = $proxy
->__getLazyProperties();
foreach ($properties as $propertyName => $property) {
if (!isset($proxy->{$propertyName})) {
$proxy->{$propertyName} = $properties[$propertyName];
}
}
$proxy
->__setInitialized(true);
if (method_exists($proxy, '__wakeup')) {
$proxy
->__wakeup();
}
if (null === $loader
->load($identifier, $proxy)) {
throw new \UnexpectedValueException('Couldn\'t load');
}
};
}