本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getName方法的具体用法?PHP ClassMetadata::getName怎么用?PHP ClassMetadata::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_processes_the_lcm_event(LoadClassMetadataEventArgs $eventArgs, ClassMetadata $classMetadata)
{
$this->beConstructedWith('Your\\Custom\\Entity');
$classMetadata->getName()->willReturn(UserPermission::class);
$classMetadata->getName()->shouldBeCalled();
$eventArgs->getClassMetadata()->willReturn($classMetadata);
$this->loadClassMetadata($eventArgs);
}
示例2: testLoadClassMetadataWithoutParent
public function testLoadClassMetadataWithoutParent()
{
$this->loadClassMetadataEvent->getClassMetadata()->willReturn($this->classMetadata->reveal());
$this->classMetadata->getName()->willReturn(get_class($this->object->reveal()));
$this->classMetadata->setCustomRepositoryClass('Sulu\\Bundle\\ContactBundle\\Entity\\ContactRepository')->shouldNotBeCalled();
$this->loadClassMetadataEvent->getEntityManager()->willReturn($this->entityManager->reveal());
$this->entityManager->getConfiguration()->willReturn($this->configuration->reveal());
$this->configuration->getNamingStrategy()->willReturn(null);
/** @var \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver $mappingDriver */
$mappingDriver = $this->prophesize('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver');
$this->configuration->getMetadataDriverImpl()->willReturn($mappingDriver->reveal());
$mappingDriver->getAllClassNames()->willReturn([get_class($this->parentObject->reveal())]);
$mappingDriver->loadMetadataForClass(get_class($this->parentObject->reveal()), Argument::type('Doctrine\\ORM\\Mapping\\ClassMetadata'))->shouldBeCalled();
$this->subscriber->loadClassMetadata($this->loadClassMetadataEvent->reveal());
}
示例3: processDiscriminatorValues
/**
* Collecting discriminator map entries from child classes for entities with inheritance not equals NONE
*
* @param ClassMetadata $class
* @param EntityManager $em
*
* @throws MappingException
*/
protected function processDiscriminatorValues(ClassMetadata $class, EntityManager $em)
{
if (!$class->isInheritanceTypeNone()) {
if ($class->isRootEntity()) {
$allClasses = $em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
$FQCN = $class->getName();
$map = $class->discriminatorMap ?: [];
$duplicates = [];
foreach ($allClasses as $subClassCandidate) {
if (is_subclass_of($subClassCandidate, $FQCN) && !in_array($subClassCandidate, $map, true)) {
$value = $this->getDiscriminatorValue($em->getMetadataFactory(), $subClassCandidate);
if (null !== $value) {
if (isset($map[$value])) {
$duplicates[] = $value;
}
$map[$value] = $subClassCandidate;
}
}
}
if ($duplicates) {
throw MappingException::duplicateDiscriminatorEntry($class->getName(), $duplicates, $map);
}
$class->setDiscriminatorMap($map);
$this->collectedMaps = array_merge($this->collectedMaps, array_fill_keys(array_values($map), $map));
} elseif (isset($this->collectedMaps[$class->name]) && $class->discriminatorMap !== $this->collectedMaps[$class->name]) {
$class->setDiscriminatorMap($this->collectedMaps[$class->name]);
}
}
}
示例4: convertMetadata
/**
* @param ClassMetadata $metadata
* @return JavaScript\Metadata
*/
private function convertMetadata(ClassMetadata $metadata)
{
$meta = new JavaScript\Metadata();
$meta->originalName = $metadata->getName();
$meta->namespace = str_replace('\\', '_', $metadata->getReflectionClass()->getNamespaceName());
$meta->functionName = $metadata->getReflectionClass()->getShortName();
$parent = $metadata->getReflectionClass()->getParentClass();
$meta->superFunctionName = $parent ? $parent->getShortName() : 'DBEntity';
// Convert fields.
foreach ($metadata->getFieldNames() as $fieldName) {
$field = new JavaScript\Field();
$field->name = $fieldName;
$field->methodName = ucfirst($fieldName);
$field->type = $this->convertDoctrineType($metadata->getTypeOfField($fieldName));
$field->isIdentifier = $metadata->isIdentifier($fieldName);
$meta->fields[] = $field;
}
// Convert associations.
foreach ($metadata->getAssociationNames() as $assocName) {
$assoc = new JavaScript\Association();
$assoc->name = $assocName;
$assoc->methodName = ucfirst($assocName);
$assoc->isCollection = $metadata->isCollectionValuedAssociation($assocName);
$assoc->isSingle = $metadata->isSingleValuedAssociation($assocName);
$assoc->singleName = Inflector::singularize($assoc->methodName);
$assoc->invertedField = $metadata->getAssociationMappedByTargetField($assocName);
$targetClass = new \ReflectionClass($metadata->getAssociationTargetClass($assocName));
$assoc->singleType = $targetClass->getShortName();
$assoc->type = $assoc->singleType . ($assoc->isCollection ? '[]' : '');
$meta->associations[] = $assoc;
}
return $meta;
}
示例5: addFilterConstraint
/**
* {@inheritdoc}
*/
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
$className = $targetEntity->getName();
if (isset(self::$disabled[$className])) {
return '';
} elseif (array_key_exists($targetEntity->rootEntityName, self::$disabled)) {
return '';
}
$dataKey = $className . '|' . $targetTableAlias;
if (!isset(self::$data[$dataKey])) {
$annotation = $this->getReflectionService()->getClassAnnotation($className, SoftDeletable::class);
if ($annotation !== null) {
$existingProperties = $this->getReflectionService()->getClassPropertyNames($className);
if (!in_array($annotation->deleteProperty, $existingProperties)) {
throw new PropertyNotFoundException("Property '" . $annotation->deleteProperty . "' not found for '" . $className . "'", 1439207432);
}
$conn = $this->getEntityManager()->getConnection();
$platform = $conn->getDatabasePlatform();
$column = $targetEntity->getQuotedColumnName($annotation->deleteProperty, $platform);
$addCondSql = $platform->getIsNullExpression($targetTableAlias . '.' . $column);
if ($annotation->timeAware) {
$addCondSql .= ' OR ' . $targetTableAlias . '.' . $column . ' > ' . $conn->quote(date('Y-m-d H:i:s'));
}
self::$data[$dataKey] = $addCondSql;
} else {
self::$data[$dataKey] = false;
}
}
return self::$data[$dataKey] ? self::$data[$dataKey] : '';
}
示例6: getNewInstance
protected function getNewInstance()
{
$className = $this->entityMetadata->getName();
if (class_exists($className) === false) {
throw new \Exception('Unable to create new instance of ' . $className);
}
return new $className();
}
示例7: getRepository
/**
* @param ClassMetadata $classMetadata
* @return \Doctrine\Common\Persistence\ObjectRepository
*/
protected function getRepository(ClassMetadata $classMetadata)
{
$repository = $this->managerRegistry->getRepository($classMetadata->getName());
if (!$repository instanceof ManagedRepositoryInterface) {
return false;
}
return $repository;
}
示例8: addFilterConstraint
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
if ($targetEntity->hasField('del_flg') && !in_array($targetEntity->getName(), $this->getExcludes())) {
return $targetTableAlias . '.del_flg = 0';
} else {
return "";
}
}
示例9: getResourceType
public static function getResourceType($entityManager, ClassMetadata $meta, $level = 0)
{
if (isset(self::$resourceTypes[$meta->getName()])) {
return self::$resourceTypes[$meta->getName()];
}
$refClass = $meta->getReflectionClass();
$namespace = null;
$resourceType = new ResourceType($refClass, ResourceTypeKind::ENTITY, $refClass->getShortName(), $namespace);
$addedProperties = array();
foreach ($meta->fieldMappings as $fieldName => $data) {
$type = $resourceType->getPrimitiveResourceType(DataTypeMapper::fromDoctrineToOData($data['type']));
$kind = ResourcePropertyKind::PRIMITIVE;
$resourceProperty = new ResourceProperty($fieldName, null, $kind, $type);
$resourceType->addProperty($resourceProperty);
$addedProperties[$fieldName] = $resourceProperty;
}
if ($level < self::LEVEL_MAX) {
foreach ($meta->associationMappings as $fieldName => $data) {
if ($associationMeta = $entityManager->getClassMetadata($data['targetEntity'])) {
$type = self::getResourceType($entityManager, $associationMeta, self::$level++);
$kind = ResourcePropertyKind::RESOURCE_REFERENCE;
$resourceProperty = new ResourceProperty($fieldName, null, $kind, $type);
$resourceType->addProperty($resourceProperty);
$fkFieldName = self::getForeignKeyFieldName($data, $entityManager);
if (!$fkFieldName) {
$fkFieldName = $data['fieldName'] . 'Id';
}
if ($fkFieldName) {
if (!isset($addedProperties[$fkFieldName])) {
//*
$type = $resourceType->getPrimitiveResourceType(DataTypeMapper::fromDoctrineToOData('integer'));
$kind = ResourcePropertyKind::PRIMITIVE;
$resourceProperty = new ResourceProperty($fkFieldName, null, $kind, $type);
$resourceType->addProperty($resourceProperty);
$addedProperties[$fieldName] = $resourceProperty;
//*/
}
}
// break;
}
}
}
self::$level = 1;
return self::$resourceTypes[$meta->getName()] = $resourceType;
}
示例10: array
function it_should_throw_an_exception_if_no_existence(EntityResolver $resolver, TableNode $tableNode, $repository, $manager, ClassMetadata $metadata)
{
$resolver->resolve(Argument::cetera())->willReturn([$metadata]);
$metadata->getName()->willReturn("EntityStub");
$tableNode->getRows()->willReturn(array(array('firstName', 'lastName', 'number', 'nullValue'), array('John', 'DOE', 0, '')));
$manager->getRepository(Argument::any())->willReturn($repository);
$repository->findOneBy(['firstName' => 'John', 'lastName' => 'DOE', 'number' => 0, 'nullValue' => null])->willReturn(null);
$this->shouldThrow(new \Exception("There is no object for the following criteria: {\"firstName\":\"John\",\"lastName\":\"DOE\",\"number\":0,\"nullValue\":null}"))->duringExistLikeFollowing(1, "Class", $tableNode);
}
示例11: createProxyFile
private function createProxyFile(ClassMetadata $classMetadata)
{
$fileName = str_replace('\\', '_', $classMetadata->getName());
$reflection = $classMetadata->getReflectionClass();
$filecontent = $this->getFileContent($classMetadata->getName());
foreach ($reflection->getProperties() as $property) {
/* @var $property \ReflectionProperty */
$annotation = $this->getPropertyAnnotation($property);
if (!is_null($annotation)) {
$filecontent .= ' $obj->' . $property->getName() . ' = ' . $annotation->getFixture() . "\n";
}
}
foreach ($classMetadata->getAssociationMappings() as $association) {
$filecontent .= ' $obj->' . $association['fieldName'] . ' = array_key_exists("' . $association['fieldName'] . '", $dpdc) ? $dpdc["' . $association['fieldName'] . '"] : null;' . "\n";
}
$filecontent .= ' return $obj;' . "\n" . ' }' . "\n" . '}';
file_put_contents($this->_cacheDir . DIRECTORY_SEPARATOR . $fileName, $filecontent);
}
示例12: __construct
/**
* @param EntityManager $em
* @param Mapping\ClassMetadata $class
*/
public function __construct(EntityManager $em, Mapping\ClassMetadata $class)
{
$className = $class->getName();
if ($className != 'Supra\\Package\\Cms\\Entity\\Abstraction\\File') {
throw new LogicException("File repository should be called for file abstraction entity only, requested for '{$className}'");
}
parent::__construct($em, $class);
$this->nestedSetRepository = new DoctrineRepository($em, $class);
}
示例13: setSelect
/**
* Set select statement.
*
* @return DatatableData
*/
private function setSelect()
{
foreach ($this->selectFields as $key => $value) {
// example: $qb->select('partial comment.{id, title}, partial post.{id, title}');
$this->qb->addSelect('partial ' . $key . '.{' . implode(',', $this->selectFields[$key]) . '}');
}
$this->qb->from($this->metadata->getName(), $this->tableName);
return $this;
}
示例14: getFallbackResult
protected function getFallbackResult(ClassMetadata $classMetadata, array $options)
{
$parts = explode('\\', $classMetadata->getName());
$className = array_pop($parts);
$humanized = $this->inflector->humanize($this->inflector->underscore($className));
if (!empty($options['plural'])) {
$humanized = $this->inflector->pluralize($humanized);
}
return $humanized;
}
示例15: setCustomRepositoryClass
/**
* @param ClassMetadata $metadata
*/
private function setCustomRepositoryClass(ClassMetadata $metadata)
{
try {
$resourceMetadata = $this->resourceRegistry->getByClass($metadata->getName());
} catch (\InvalidArgumentException $exception) {
return;
}
if ($resourceMetadata->hasClass('repository')) {
$metadata->setCustomRepositoryClass($resourceMetadata->getClass('repository'));
}
}