You are here

public function AbstractProxyFactory::getProxy in Plug 7

Gets a reference proxy instance for the entity of the given type and identified by the given identifier.

Parameters

string $className:

array $identifier:

Return value

\Doctrine\Common\Proxy\Proxy

Throws

\Doctrine\Common\Proxy\Exception\OutOfBoundsException

File

lib/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php, line 115

Class

AbstractProxyFactory
Abstract factory for proxy objects.

Namespace

Doctrine\Common\Proxy

Code

public function getProxy($className, array $identifier) {
  $definition = isset($this->definitions[$className]) ? $this->definitions[$className] : $this
    ->getProxyDefinition($className);
  $fqcn = $definition->proxyClassName;
  $proxy = new $fqcn($definition->initializer, $definition->cloner);
  foreach ($definition->identifierFields as $idField) {
    if (!isset($identifier[$idField])) {
      throw OutOfBoundsException::missingPrimaryKeyValue($className, $idField);
    }
    $definition->reflectionFields[$idField]
      ->setValue($proxy, $identifier[$idField]);
  }
  return $proxy;
}