You are here

private function ProxyGenerator::generateConstructorImpl in Plug 7

Generates the constructor code (un-setting public lazy loaded properties, setting identifier field values).

Parameters

\Doctrine\Common\Persistence\Mapping\ClassMetadata $class:

Return value

string

File

lib/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php, line 376

Class

ProxyGenerator
This factory is used to generate proxy classes. It builds proxies from given parameters, a template and class metadata.

Namespace

Doctrine\Common\Proxy

Code

private function generateConstructorImpl(ClassMetadata $class) {
  $constructorImpl = <<<'EOT'
    /**
     * @param \Closure $initializer
     * @param \Closure $cloner
     */
    public function __construct($initializer = null, $cloner = null)
    {

EOT;
  $toUnset = array();
  foreach ($this
    ->getLazyLoadedPublicProperties($class) as $lazyPublicProperty => $unused) {
    $toUnset[] = '$this->' . $lazyPublicProperty;
  }
  $constructorImpl .= (empty($toUnset) ? '' : '        unset(' . implode(', ', $toUnset) . ");\n") . <<<'EOT'

        $this->__initializer__ = $initializer;
        $this->__cloner__      = $cloner;
    }
EOT;
  return $constructorImpl;
}