Doctrine\Common\Proxy\ProxyGenerator::getProxyFileName PHP Метод

getProxyFileName() публичный Метод

Generates the Proxy file name.
public getProxyFileName ( string $className, string $baseDirectory = null ) : string
$className string
$baseDirectory string Optional base directory for proxy file name generation. If not specified, the directory configured on the Configuration of the EntityManager will be used by this factory.
Результат string
    public function getProxyFileName($className, $baseDirectory = null)
    {
        $baseDirectory = $baseDirectory ?: $this->proxyDirectory;
        return rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . Proxy::MARKER . str_replace('\\', '', $className) . '.php';
    }

Usage Example

Пример #1
0
 /**
  * @param $className
  *
  * @return string
  */
 private function generateProxyClass($className)
 {
     $proxyClassName = 'Doctrine\\Tests\\Common\\Proxy\\MagicMethodProxy\\__CG__\\' . $className;
     if (class_exists($proxyClassName, false)) {
         return $proxyClassName;
     }
     $metadata = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $metadata->expects($this->any())->method('getName')->will($this->returnValue($className));
     $metadata->expects($this->any())->method('getIdentifier')->will($this->returnValue(array('id')));
     $metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue(new ReflectionClass($className)));
     $metadata->expects($this->any())->method('isIdentifier')->will($this->returnCallback(function ($fieldName) {
         return 'id' === $fieldName;
     }));
     $metadata->expects($this->any())->method('hasField')->will($this->returnCallback(function ($fieldName) {
         return in_array($fieldName, array('id', 'publicField'));
     }));
     $metadata->expects($this->any())->method('hasAssociation')->will($this->returnValue(false));
     $metadata->expects($this->any())->method('getFieldNames')->will($this->returnValue(array('id', 'publicField')));
     $metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue(array('id')));
     $metadata->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array()));
     $metadata->expects($this->any())->method('getTypeOfField')->will($this->returnValue('string'));
     $this->proxyGenerator->generateProxyClass($metadata, $this->proxyGenerator->getProxyFileName($className));
     require_once $this->proxyGenerator->getProxyFileName($className);
     return $proxyClassName;
 }
All Usage Examples Of Doctrine\Common\Proxy\ProxyGenerator::getProxyFileName