You are here

private function ProxyGenerator::generateCloneImpl in Plug 7

Generates implementation for the `__clone` method of proxies.

Parameters

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

Return value

string

File

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

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 generateCloneImpl(ClassMetadata $class) {
  $hasParentClone = $class
    ->getReflectionClass()
    ->hasMethod('__clone');
  $inheritDoc = $hasParentClone ? '{@inheritDoc}' : '';
  $callParentClone = $hasParentClone ? "\n        parent::__clone();\n" : '';
  return <<<EOT
    /**
     * {<span class="php-variable">$inheritDoc</span>}
     */
    public function __clone()
    {
        \$this->__cloner__ && \$this->__cloner__->__invoke(\$this, '__clone', array());
{<span class="php-variable">$callParentClone</span>}    }
EOT;
}