You are here

protected function ProxyLogicTest::getSuggestedInitializerImplementation in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php \Doctrine\Tests\Common\Proxy\ProxyLogicTest::getSuggestedInitializerImplementation()

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 vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php
ProxyLogicTest::testInitializationRestoresDefaultPublicLazyLoadedFieldValues in vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php
ProxyLogicTest::testInitializedProxyUnserialization in vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php
ProxyLogicTest::testLoadingWithPersisterWillBeTriggeredOnlyOnce in vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php

File

vendor/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\Proxy

Code

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');
    }
  };
}