本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::getName方法的具体用法?PHP ClassMetadataInfo::getName怎么用?PHP ClassMetadataInfo::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadataInfo
的用法示例。
在下文中一共展示了ClassMetadataInfo::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* @param ClassMetadataInfo $metadata
* @param string $outputDir
* @param Closure $collectionNameBuilder
*/
public function generate(ClassMetadataInfo $metadata, $outputDir, Closure $collectionNameBuilder)
{
$tpl = file_get_contents(CodeGeneratorHelper::absPath(EntityCollectionTemplate::class, RootPath::path()));
$tplNs = CodeGeneratorHelper::ns(EntityCollectionTemplate::class);
$tplSimpleName = CodeGeneratorHelper::simpleName(EntityCollectionTemplate::class);
$entityFqcn = CodeGeneratorHelper::simpleName(EntityFqcn::class);
$collectionClassName = $collectionNameBuilder($metadata->getName());
$code = CodeGeneratorHelper::render($tpl, array($tplNs => CodeGeneratorHelper::ns($collectionClassName), $tplSimpleName => CodeGeneratorHelper::simpleName($collectionClassName), $entityFqcn => CodeGeneratorHelper::fqn($metadata->getName())));
CodeGeneratorHelper::save($collectionClassName, $code, $outputDir);
}
示例2: generateCodeBody
protected function generateCodeBody(ClassMetadataInfo $metadata)
{
$methods = array();
$methods[] = $this->generateFindBy($metadata->getName());
foreach ($metadata->fieldMappings as $fieldMapping) {
$methods[] = $this->generateFieldFindBy($metadata->getName(), $fieldMapping['type'], $fieldMapping['fieldName']);
}
foreach ($metadata->embeddedClasses as $fieldName => $embeddedClass) {
$methods[] = $this->generateFieldFindBy($metadata->getName(), $embeddedClass['class'], $fieldName);
}
foreach ($metadata->associationMappings as $associationMapping) {
$methods[] = $this->generateFieldFindBy($metadata->getName(), $associationMapping['targetEntity'], $associationMapping['fieldName']);
}
return implode("\n", $methods);
}
示例3: traverse
/**
* {@inheritdoc}
*/
public function traverse(ClassMetadataInfo $metadata)
{
$class = $metadata->getName();
if (true === $this->collection->has($class)) {
foreach ($this->collection->get($class) as $enhancer) {
$enhancer->visitClassMetadata($metadata);
}
}
}
示例4: testLoadMetadataForClass
public function testLoadMetadataForClass()
{
$metadata = new ClassMetadataInfo('Giftcards\\Encryption\\Tests\\Doctrine\\MockEntityWithEncryptedProperties');
$metadata->reflClass = new \ReflectionClass($metadata->getName());
$this->driver->loadMetadataForClass($metadata->getName(), $metadata);
$this->assertTrue($metadata->hasEncryptedProperties);
$this->assertEquals(array('encryptedProperty' => array('profile' => null)), $metadata->encryptedProperties);
$metadata = new ClassMetadataInfo('Giftcards\\Encryption\\Tests\\Doctrine\\MockEntityWithEncryptedPropertiesAndProfileSet');
$metadata->reflClass = new \ReflectionClass($metadata->getName());
$this->driver->loadMetadataForClass($metadata->getName(), $metadata);
$this->assertTrue($metadata->hasEncryptedProperties);
$this->assertEquals(array('encryptedProperty' => array('profile' => 'foo')), $metadata->encryptedProperties);
}
示例5: hasAssociationConfigs
/**
* {@inheritdoc}
*/
protected function hasAssociationConfigs(ClassMetadataInfo $metadata, $associationName)
{
if ($this->isExtendField($metadata->getName(), $associationName)) {
return false;
}
// check for default field of oneToMany or manyToMany relation
if (strpos($associationName, ExtendConfigDumper::DEFAULT_PREFIX) === 0) {
$guessedName = substr($associationName, strlen(ExtendConfigDumper::DEFAULT_PREFIX));
if (!empty($guessedName) && $this->isExtendField($metadata->getName(), $guessedName)) {
return false;
}
}
// check for inverse side field of oneToMany relation
$targetClass = $metadata->getAssociationTargetClass($associationName);
$prefix = strtolower(ExtendHelper::getShortClassName($targetClass)) . '_';
if (strpos($associationName, $prefix) === 0) {
$guessedName = substr($associationName, strlen($prefix));
if (!empty($guessedName) && $this->isExtendField($targetClass, $guessedName)) {
return false;
}
}
return parent::hasAssociationConfigs($metadata, $associationName);
}
示例6:
function it_configures_the_mappings_of_a_model_that_overrides_an_original_model($configuration, ClassMetadataInfo $metadataInfo, MappingDriver $mappingDriver)
{
$originalQux1 = __NAMESPACE__ . '\\OriginalQux1';
$originalQux2 = __NAMESPACE__ . '\\OriginalQux2';
$overrideQux1 = __NAMESPACE__ . '\\OverrideQux1';
$overrideQux2 = __NAMESPACE__ . '\\OverrideQux2';
$mappingDriver->getAllClassNames()->willReturn([$originalQux1]);
$configuration->getMetadataDriverImpl()->willReturn($mappingDriver);
$configuration->getNamingStrategy()->willReturn(null);
$metadataInfo->getName()->willReturn($overrideQux1);
$mappingDriver->loadMetadataForClass($originalQux1, Argument::any())->shouldBeCalled();
$overrides = [['original' => $originalQux1, 'override' => $overrideQux1], ['original' => $originalQux2, 'override' => $overrideQux2]];
$this->configure($metadataInfo, $overrides, $configuration);
}
示例7: setAssociationMappings
/**
* Set the association mappings of a metadata.
*
* @param ClassMetadataInfo $metadata
* @param Configuration $configuration
*/
protected function setAssociationMappings(ClassMetadataInfo $metadata, Configuration $configuration)
{
$supportedClasses = $configuration->getMetadataDriverImpl()->getAllClassNames();
foreach (class_parents($metadata->getName()) as $parent) {
if (in_array($parent, $supportedClasses)) {
$parentMetadata = new OrmClassMetadata($parent, $configuration->getNamingStrategy());
$configuration->getMetadataDriverImpl()->loadMetadataForClass($parent, $parentMetadata);
foreach ($parentMetadata->getAssociationMappings() as $key => $value) {
if ($this->hasRelation($value['type'])) {
$metadata->associationMappings[$key] = $value;
}
}
}
}
}
示例8: setAssociationMappings
/**
* @param ClassMetadataInfo $metadata
* @param $configuration
*/
private function setAssociationMappings(ClassMetadataInfo $metadata, $configuration)
{
foreach (class_parents($metadata->getName()) as $parent) {
$parentMetadata = new ClassMetadata($parent, $configuration->getNamingStrategy());
if (in_array($parent, $configuration->getMetadataDriverImpl()->getAllClassNames())) {
$configuration->getMetadataDriverImpl()->loadMetadataForClass($parent, $parentMetadata);
if ($parentMetadata->isMappedSuperclass) {
foreach ($parentMetadata->getAssociationMappings() as $key => $value) {
if ($this->hasRelation($value['type'])) {
$metadata->associationMappings[$key] = $value;
}
}
}
}
}
}
示例9: setAssociationMappings
/**
* @param ClassMetadataInfo $metadata
* @param $configuration
*/
private function setAssociationMappings(ClassMetadataInfo $metadata, $configuration)
{
foreach (class_parents($metadata->getName()) as $parent) {
if (false === in_array($parent, $configuration->getMetadataDriverImpl()->getAllClassNames())) {
continue;
}
$parentMetadata = new ClassMetadata($parent, $configuration->getNamingStrategy());
// Wakeup Reflection
$parentMetadata->wakeupReflection($this->getReflectionService());
// Load Metadata
$configuration->getMetadataDriverImpl()->loadMetadataForClass($parent, $parentMetadata);
if (false === $this->isResource($parentMetadata)) {
continue;
}
if ($parentMetadata->isMappedSuperclass) {
foreach ($parentMetadata->getAssociationMappings() as $key => $value) {
if ($this->hasRelation($value['type'])) {
$metadata->associationMappings[$key] = $value;
}
}
}
}
}
示例10: setAssociationMappings
/**
* @param ClassMetadataInfo $metadata
* @param Configuration $configuration
*/
private function setAssociationMappings(ClassMetadataInfo $metadata, Configuration $configuration)
{
if (!class_exists($metadata->getName())) {
return;
}
foreach (class_parents($metadata->getName()) as $parent) {
$parentMetadata = new ClassMetadata($parent, $configuration->getNamingStrategy());
if (!in_array($parent, $this->getAllClassNames($configuration))) {
continue;
}
$configuration->getMetadataDriverImpl()->loadMetadataForClass($parent, $parentMetadata);
if (!$parentMetadata->isMappedSuperclass) {
continue;
}
// map relations
foreach ($parentMetadata->getAssociationMappings() as $key => $value) {
if ($this->hasRelation($value['type'])) {
$value['sourceEntity'] = $metadata->getName();
$metadata->associationMappings[$key] = $value;
}
}
}
}
示例11: getPrimaryKeyName
public static function getPrimaryKeyName(ClassMetadataInfo $metadata)
{
$fieldMappings = $metadata->fieldMappings;
foreach ($fieldMappings as $mapping) {
if (array_key_exists('id', $mapping) && $mapping['id']) {
return $mapping['fieldName'];
}
}
throw new \Exception(sprintf('Primary key not defined for %s', $metadata->getName()));
}
示例12: hasEntityConfigs
/**
* @param ClassMetadataInfo $metadata
* @return bool
*/
protected function hasEntityConfigs(ClassMetadataInfo $metadata)
{
$classMetadata = $this->configManager->getEntityMetadata($metadata->getName());
return $classMetadata && $classMetadata->configurable;
}
示例13: getBaseQueryCollectionClassName
public function getBaseQueryCollectionClassName(ClassMetadataInfo $metadata)
{
return $this->getQueryCollectionClassNameByEntityClass($metadata->getName());
}
示例14: setClass
/**
* Sets the type of the entity this manager is responsible for
*
* @param string $entityClass The FQCN of an entity
*/
public function setClass($entityClass)
{
$this->metadata = $this->om->getClassMetadata($entityClass);
$this->class = $this->metadata->getName();
}
示例15: dumpFile
/**
* @param ClassMetadataInfo $classMetadataInfo
* @param string $dumpDirectory
*
* return void
*/
private function dumpFile(ClassMetadataInfo $classMetadataInfo, $dumpDirectory)
{
$this->output->writeln("[" . date('c') . "] dumping {$classMetadataInfo->getName()} ...");
$this->dumper->setClassMetadataInfo($classMetadataInfo);
$file = $this->dumper->dumpToYaml($dumpDirectory);
$this->output->writeln("[" . date('c') . "] successfully dumped in file {$file}");
$this->output->writeln(PHP_EOL);
}