本文整理汇总了PHP中Doctrine\Common\Util\ClassUtils::generateProxyClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassUtils::generateProxyClassName方法的具体用法?PHP ClassUtils::generateProxyClassName怎么用?PHP ClassUtils::generateProxyClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Util\ClassUtils
的用法示例。
在下文中一共展示了ClassUtils::generateProxyClassName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createProxyDefinition
public function createProxyDefinition($className)
{
$classMetadata = $this->metadataFactory->getMetadataFor($className);
$reflectionFields = $classMetadata->getReflectionFields();
$reflectionId = $reflectionFields[$classMetadata->getRidPropertyName()];
return new ProxyDefinition(ClassUtils::generateProxyClassName($className, $this->proxyNamespace), $classMetadata->getIdentifierFieldNames(), $classMetadata->getReflectionFields(), $this->createInitializer($classMetadata, $this->uow->getHydrator(), $reflectionId), $this->createCloner($classMetadata, $this->uow->getHydrator(), $reflectionId));
}
示例2: createProxyDefinition
/**
* @param string $className
*
* @return ProxyDefinition
* @throws FetchException
*/
protected function createProxyDefinition($className)
{
/** @var EntityMetadata $classMetadata */
$classMetadata = $this->manager->getClassMetadata($className);
/** @var ApiPersister $persister */
$persister = $this->uow->getEntityPersister($className);
return new ProxyDefinition(ClassUtils::generateProxyClassName($className, $this->manager->getConfiguration()->getProxyNamespace()), $classMetadata->getIdentifierFieldNames(), $classMetadata->getReflectionProperties(), $this->createInitializer($classMetadata, $persister), $this->createCloner($classMetadata, $persister));
}
示例3: createProxyDefinition
/**
* @inheritdoc
*/
public function createProxyDefinition($className)
{
/** @var ClassMetadata $classMetadata */
$classMetadata = $this->metadataFactory->getMetadataFor($className);
$documentPersister = $this->uow->getDocumentPersister($className);
$reflectionFields = $classMetadata->getReflectionProperties();
$reflectionId = $reflectionFields[$classMetadata->getRidPropertyName()];
return new ProxyDefinition(ClassUtils::generateProxyClassName($className, $this->proxyNamespace), $classMetadata->getIdentifierFieldNames(), $reflectionFields, $this->createInitializer($classMetadata, $documentPersister, $reflectionId), $this->createCloner($classMetadata, $documentPersister, $reflectionId));
}
示例4: createProxyDefinition
/**
* {@inheritDoc}
*/
protected function createProxyDefinition($className)
{
$cm = $this->em->getClassMetadata($className);
return new ProxyDefinition(ClassUtils::generateProxyClassName($className, $this->proxyNamespace), $cm->getIdentifierFieldNames(), $cm->getReflectionProperties(), function (BaseProxy $proxy) use($cm) {
if ($proxy->__isInitialized()) {
return;
}
}, function (BaseProxy $proxy) use($cm) {
if ($proxy->__isInitialized()) {
return;
}
});
}
示例5: generateNamespace
/**
* Generates the proxy namespace.
*
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class
*
* @return string
*/
private function generateNamespace(ClassMetadata $class)
{
$proxyClassName = ClassUtils::generateProxyClassName($class->getName(), $this->proxyNamespace);
$parts = explode('\\', strrev($proxyClassName), 2);
return strrev($parts[1]);
}
示例6: _generateProxyClass
/**
* Generates a proxy class file.
*
* @param ClassMetadata $class Metadata for the original class
* @param string $fileName Filename (full path) for the generated class
* @param string $file The proxy class template data
*/
private function _generateProxyClass(ClassMetadata $class, $fileName, $file)
{
$methods = $this->_generateMethods($class);
$sleepImpl = $this->_generateSleep($class);
$cloneImpl = $class->reflClass->hasMethod('__clone') ? 'parent::__clone();' : '';
// hasMethod() checks case-insensitive
$placeholders = array('<namespace>', '<proxyClassName>', '<className>', '<methods>', '<sleepImpl>', '<cloneImpl>');
$className = ltrim($class->name, '\\');
$proxyClassName = ClassUtils::generateProxyClassName($class->name, $this->_proxyNamespace);
$parts = explode('\\', strrev($proxyClassName), 2);
$proxyClassNamespace = strrev($parts[1]);
$proxyClassName = strrev($parts[0]);
$replacements = array($proxyClassNamespace, $proxyClassName, $className, $methods, $sleepImpl, $cloneImpl);
$file = str_replace($placeholders, $replacements, $file);
$parentDirectory = dirname($fileName);
if (!is_dir($parentDirectory)) {
if (false === @mkdir($parentDirectory, 0775, true)) {
throw ProxyException::proxyDirectoryNotWritable();
}
} else {
if (!is_writable($parentDirectory)) {
throw ProxyException::proxyDirectoryNotWritable();
}
}
$tmpFileName = $fileName . '.' . uniqid("", true);
file_put_contents($tmpFileName, $file);
rename($tmpFileName, $fileName);
}
示例7: createProxyDefinition
/**
* {@inheritDoc}
*/
protected function createProxyDefinition($className)
{
$classMetadata = $this->em->getClassMetadata($className);
$entityPersister = $this->uow->getEntityPersister($className);
return new ProxyDefinition(ClassUtils::generateProxyClassName($className, $this->proxyNs), $classMetadata->getIdentifierFieldNames(), $classMetadata->getReflectionProperties(), $this->createInitializer($classMetadata, $entityPersister), $this->createCloner($classMetadata, $entityPersister));
}
示例8: generateProxyClass
/**
* Generates a proxy class file.
*
* @param $class
* @param $fileName
* @param $template
*/
private function generateProxyClass($class, $fileName, $template)
{
$methods = $this->generateMethods($class);
$sleepImpl = $this->generateSleep($class);
$placeholders = array('<namespace>', '<proxyClassName>', '<className>', '<methods>', '<sleepImpl>');
$className = ltrim($class->name, '\\');
$proxyClassName = ClassUtils::generateProxyClassName($class->name, $this->proxyNamespace);
$parts = explode('\\', strrev($proxyClassName), 2);
$proxyClassNamespace = strrev($parts[1]);
$proxyClassName = strrev($parts[0]);
$replacements = array($proxyClassNamespace, $proxyClassName, $className, $methods, $sleepImpl);
$template = str_replace($placeholders, $replacements, $template);
file_put_contents($fileName, $template, LOCK_EX);
}
示例9: createProxyDefinition
/**
* {@inheritDoc}
*/
public function createProxyDefinition($className)
{
/* @var $classMetadata \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo */
$classMetadata = $this->metadataFactory->getMetadataFor($className);
$documentPersister = $this->uow->getDocumentPersister($className);
$reflectionId = $classMetadata->reflFields[$classMetadata->identifier];
return new ProxyDefinition(ClassUtils::generateProxyClassName($className, $this->proxyNamespace), $classMetadata->getIdentifierFieldNames(), $classMetadata->getReflectionProperties(), $this->createInitializer($classMetadata, $documentPersister, $reflectionId), $this->createCloner($classMetadata, $documentPersister, $reflectionId));
}
示例10: createProxyDefinition
/**
* {@inheritDoc}
*/
protected function createProxyDefinition($className)
{
$classMetadata = $this->documentManager->getClassMetadata($className);
return new ProxyDefinition(ClassUtils::generateProxyClassName($classMetadata->getName(), $this->proxyNamespace), array($classMetadata->identifier), $classMetadata->reflFields, $this->createInitializer($classMetadata), $this->createCloner($classMetadata, $classMetadata->reflFields[$classMetadata->identifier]));
}
示例11: testGenerateProxyClassName
public function testGenerateProxyClassName()
{
$this->assertEquals('Proxies\\__CG__\\stdClass', ClassUtils::generateProxyClassName('stdClass', 'Proxies'));
}
示例12: _generateProxyClass
/**
* Generates a proxy class file.
*
* @param $class
* @param $proxyClassName
* @param $file The path of the file to write to.
*/
private function _generateProxyClass($class, $fileName, $file)
{
$methods = $this->_generateMethods($class);
$sleepImpl = $this->_generateSleep($class);
$cloneImpl = $class->reflClass->hasMethod('__clone') ? 'parent::__clone();' : '';
// hasMethod() checks case-insensitive
$placeholders = array('<namespace>', '<proxyClassName>', '<className>', '<methods>', '<sleepImpl>', '<cloneImpl>');
$className = ltrim($class->name, '\\');
$proxyClassName = ClassUtils::generateProxyClassName($class->name, $this->_proxyNamespace);
$parts = explode('\\', strrev($proxyClassName), 2);
$proxyClassNamespace = strrev($parts[1]);
$proxyClassName = strrev($parts[0]);
$replacements = array($proxyClassNamespace, $proxyClassName, $className, $methods, $sleepImpl, $cloneImpl);
$file = str_replace($placeholders, $replacements, $file);
file_put_contents($fileName, $file, LOCK_EX);
}
示例13: createProxyDefinition
/**
* {@inheritDoc}
*/
protected function createProxyDefinition($className)
{
$classMetadata = $this->documentManager->getClassMetadata($className);
if ($classMetadata->identifier) {
$identifierFields = array($classMetadata->identifier);
$reflectionId = $classMetadata->reflFields[$classMetadata->identifier];
} else {
$identifierFields = array();
$reflectionId = null;
}
return new ProxyDefinition(ClassUtils::generateProxyClassName($classMetadata->getName(), $this->proxyNamespace), $identifierFields, $classMetadata->reflFields, $this->createInitializer($classMetadata), $this->createCloner($classMetadata, $reflectionId));
}