本文整理汇总了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getName方法的具体用法?PHP ClassMetadata::getName怎么用?PHP ClassMetadata::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslatableRepository
/**
* @return TranslatableRepositoryInterface
* @throws Exception\AnnotationException
*/
public function getTranslatableRepository()
{
$repository = $this->objectManager->getRepository($this->classMetadata->getName());
if (!$repository instanceof TranslatableRepositoryInterface) {
throw new Exception\AnnotationException(sprintf('Entity "%s" has "%s" as its "repositoryClass" which does not implement \\FSi\\DoctrineExtensions\\Translatable\\Model\\TranslatableRepositoryInterface', $this->classMetadata->getName(), get_class($repository)));
}
return $repository;
}
示例2: execute
/**
* Insert one new record using the Entity class.
*/
public function execute($manager, $insertedEntities)
{
$class = $this->class->getName();
$obj = new $class();
foreach ($this->columnFormatters as $field => $format) {
if (null !== $format) {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
$this->class->reflFields[$field]->setValue($obj, $value);
}
}
$manager->persist($obj);
return $obj;
}
示例3: mapHierarchy
/**
* {@inheritDoc}
*/
public function mapHierarchy(ClassMetadata $meta)
{
if ($meta->isMappedSuperclass || !$meta->isRootEntity()) {
return;
}
$rc = $meta->getReflectionClass();
if ($rc->hasProperty('parent') && !$meta->hasAssociation('parent')) {
$meta->mapManyToOne(['targetEntity' => $meta->getName(), 'fieldName' => 'parent', 'inversedBy' => 'children', 'cascade' => ['persist']]);
}
if ($rc->hasProperty('children') && !$meta->hasAssociation('children')) {
$meta->mapOneToMany(['targetEntity' => $meta->getName(), 'fieldName' => 'children', 'mappedBy' => 'parent', 'cascade' => ['persist', 'remove'], 'fetch' => 'EXTRA_LAZY']);
}
}
示例4: __construct
/**
* Creates a new entity choice list.
*
* @param ObjectManager $manager An EntityManager instance
* @param string $class The class name
* @param string $labelPath The property path used for the label
* @param EntityLoaderInterface $entityLoader An optional query builder
* @param array $entities An array of choices
* @param string $groupPath A property path pointing to the property used
* to group the choices. Only allowed if
* the choices are given as flat array.
*/
public function __construct(ObjectManager $manager, $class, $labelPath = null, EntityLoaderInterface $entityLoader = null, $entities = null, $groupPath = null)
{
$this->em = $manager;
$this->entityLoader = $entityLoader;
$this->classMetadata = $manager->getClassMetadata($class);
$this->class = $this->classMetadata->getName();
$this->identifier = $this->classMetadata->getIdentifierFieldNames();
$this->loaded = is_array($entities) || $entities instanceof \Traversable;
if (!$this->loaded) {
// Make sure the constraints of the parent constructor are
// fulfilled
$entities = array();
}
parent::__construct($entities, $labelPath, array(), $groupPath);
}
示例5: let
/**
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @param \Doctrine\Common\Persistence\ManagerRegistry $doctrine
* @param \Doctrine\Common\Persistence\ObjectManager $manager
* @param \Behat\Behat\Hook\Scope\ScenarioScope $event
* @param \Behat\Gherkin\Node\FeatureNode $feature
* @param \Behat\Gherkin\Node\ScenarioNode $scenario
* @param \Knp\FriendlyContexts\Alice\Loader\Yaml $loader
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory $metadataFactory
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $userMetadata
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $placeMetadata
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $productMetadata
*/
function let($container, $doctrine, $manager, $event, $loader, $feature, $scenario, $metadataFactory, $userMetadata, $placeMetadata, $productMetadata)
{
$doctrine->getManager()->willReturn($manager);
$feature->getTags()->willReturn(['alice(Place)', 'admin']);
$scenario->getTags()->willReturn(['alice(User)']);
$event->getFeature()->willReturn($feature);
$event->getScenario()->willReturn($scenario);
$loader->load('user.yml')->willReturn([]);
$loader->load('product.yml')->willReturn([]);
$loader->load('place.yml')->willReturn([]);
$loader->getCache()->willReturn([]);
$loader->clearCache()->willReturn(null);
$fixtures = ['User' => 'user.yml', 'Product' => 'product.yml', 'Place' => 'place.yml'];
$config = ['alice' => ['fixtures' => $fixtures, 'dependencies' => []]];
$container->has(Argument::any())->willReturn(true);
$container->hasParameter(Argument::any())->willReturn(true);
$container->get('friendly.alice.loader.yaml')->willReturn($loader);
$container->get('doctrine')->willReturn($doctrine);
$container->getParameter('friendly.alice.fixtures')->willReturn($fixtures);
$container->getParameter('friendly.alice.dependencies')->willReturn([]);
$manager->getMetadataFactory()->willReturn($metadataFactory);
$metadataFactory->getAllMetadata()->willReturn([$userMetadata, $placeMetadata, $productMetadata]);
$userMetadata->getName()->willReturn('User');
$placeMetadata->getName()->willReturn('Place');
$productMetadata->getName()->willReturn('Product');
$this->initialize($config, $container);
}
示例6: __construct
/**
* Creates a new entity choice list.
*
* @param ObjectManager $manager An EntityManager instance
* @param string $class The class name
* @param string $labelPath The property path used for the label
* @param EntityLoaderInterface $entityLoader An optional query builder
* @param array $entities An array of choices
* @param string $groupPath A property path pointing to the property used
* to group the choices. Only allowed if
* the choices are given as flat array.
*/
public function __construct(ObjectManager $manager, $class, $labelPath = null, EntityLoaderInterface $entityLoader = null, $entities = null, $groupPath = null)
{
$this->em = $manager;
$this->entityLoader = $entityLoader;
$this->classMetadata = $manager->getClassMetadata($class);
$this->class = $this->classMetadata->getName();
$this->loaded = is_array($entities) || $entities instanceof \Traversable;
$identifier = $this->classMetadata->getIdentifierFieldNames();
if (1 === count($identifier)) {
$this->idField = $identifier[0];
$this->idAsValue = true;
if ('integer' === $this->classMetadata->getTypeOfField($this->idField)) {
$this->idAsIndex = true;
}
}
if (!$this->loaded) {
// Make sure the constraints of the parent constructor are
// fulfilled
$entities = array();
}
if (version_compare(Kernel::VERSION, '2.1') <= 0) {
$this->labelPath = $labelPath ? new DepPropertyPath($labelPath) : null;
$this->groupPath = $groupPath ? new DepPropertyPath($groupPath) : null;
} else {
$this->labelPath = $labelPath ? new PropertyPath($labelPath) : null;
$this->groupPath = $groupPath ? new PropertyPath($groupPath) : null;
}
parent::__construct($entities, array(), array());
}
示例7: getTransformerInfo
/**
* {@inheritdoc}
*/
public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
{
if ($this->class !== $metadata->getName() || !$columnInfo->getAttribute() || $this->backendType !== $columnInfo->getAttribute()->getBackendType()) {
return;
}
return array($this->transformer, array());
}
示例8: mapManyToMany
/**
* @param ClassMetadata $metadata
*/
private function mapManyToMany(ClassMetadata $metadata)
{
foreach ($this->variables as $variable => $class) {
if ($class['variant']['model'] !== $metadata->getName()) {
continue;
}
$metadata->mapManyToOne(array('fieldName' => 'object', 'targetEntity' => $class['variable'], 'inversedBy' => 'variants', 'joinColumns' => array(array('name' => $variable . '_id', 'referencedColumnName' => 'id', 'nullable' => false, 'onDelete' => 'CASCADE'))));
$metadata->mapManyToMany(array('fieldName' => 'options', 'type' => ClassMetadataInfo::MANY_TO_MANY, 'targetEntity' => $class['option_value']['model'], 'joinTable' => array('name' => sprintf('sylius_%s_variant_option_value', $variable), 'joinColumns' => array(array('name' => 'variant_id', 'referencedColumnName' => 'id', 'unique' => false, 'nullable' => false, 'onDelete' => 'CASCADE')), 'inverseJoinColumns' => array(array('name' => 'option_value_id', 'referencedColumnName' => 'id', 'unique' => false, 'nullable' => false, 'onDelete' => 'CASCADE')))));
}
}
示例9: getSingleIdentifierValue
/**
* Returns the first (and only) value of the identifier fields of an entity.
*
* Doctrine must know about this entity, that is, the entity must already
* be persisted or added to the identity map before. Otherwise an
* exception is thrown.
*
* @param object $entity The entity for which to get the identifier
*
* @return array The identifier values
*
* @throws RuntimeException If the entity does not exist in Doctrine's identity map
*/
private function getSingleIdentifierValue($entity)
{
$value = current($this->getIdentifierValues($entity));
if ($this->idClassMetadata) {
$class = $this->idClassMetadata->getName();
if ($value instanceof $class) {
$value = current($this->idClassMetadata->getIdentifierValues($value));
}
}
return $value;
}
示例10: getSqlConstraint
/**
* Note: The result of this method cannot be cached, as the target table alias might change for different query scenarios
*
* @param ClassMetadata $targetEntity
* @param string $targetTableAlias
* @return string
*/
public function getSqlConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
$this->evaluateMatcher();
/** @var EntityManager $entityManager */
$entityManager = $this->objectManager->get(ObjectManager::class);
$sqlFilter = new SqlFilter($entityManager);
if (!$this->matchesEntityType($targetEntity->getName())) {
return null;
}
return $this->conditionGenerator->getSql($sqlFilter, $targetEntity, $targetTableAlias);
}
示例11: getTransformerInfo
/**
* {@inheritdoc}
*/
public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
{
if ($this->class !== $metadata->getName()) {
return;
}
foreach ($this->regexps as $regexp) {
if (preg_match($regexp, $columnInfo->getLabel())) {
return array($this->transformer, $this->options);
}
}
return;
}
示例12: generateConstructor
/**
* @param $entity
* @param ClassMetadata $classMetadata
* @return array
*/
private function generateConstructor($entity, $classMetadata)
{
$fields = [];
$fields[] = sprintf("\t\tfunction %s(data) {\n", $entity);
$fields[] = "\t\t\tif (angular.isDefined(data)) {\n";
foreach ($classMetadata->getFieldNames() as $item) {
$item = $this->handleField($item, $classMetadata->getName(), true);
if ($item !== null) {
$fields[] = $item;
}
}
$fields[] = "\t\t\t} else {\n";
foreach ($classMetadata->getFieldNames() as $item) {
$item = $this->handleField($item, $classMetadata->getName(), false);
if ($item !== null) {
$fields[] = $item;
}
}
$fields[] = "\t\t\t}\n";
$fields[] = "\t\t}\n\n";
return $fields;
}
示例13: readMetadata
/**
* {@inheritdoc}
*/
public function readMetadata(ClassMetadata $doctrineMeta, array &$meta)
{
if (!isset($meta['user'])) {
$meta['user'] = [];
}
foreach ($doctrineMeta->getReflectionClass()->getProperties() as $property) {
$annotation = $this->reader->getPropertyAnnotation($property, User::ANNOTATION);
if (!$annotation instanceof User) {
continue;
}
if (!empty($meta['user'])) {
if ($meta['user']['property'] === $property->getName()) {
continue;
}
throw $this->createPropertyAnnotationInvalidException(User::ANNOTATION, $doctrineMeta->getName(), $property->getName(), sprintf('property "%s" is already annotated with this annotation', $meta['user']['property']));
}
if (!$doctrineMeta->hasAssociation($property->getName())) {
throw $this->createPropertyAnnotationInvalidException(User::ANNOTATION, $doctrineMeta->getName(), $property->getName(), 'property must be mapped association');
}
$meta['user'] = ['property' => $property->getName(), 'roles' => $annotation->roles];
}
}
示例14: getTransformerInfo
/**
* {@inheritdoc}
*/
public function getTransformerInfo(ColumnInfoInterface $columnInfo, ClassMetadata $metadata)
{
if ($this->valueClass != $metadata->getName() || !in_array($columnInfo->getPropertyPath(), array('option', 'options'))) {
return;
}
$info = parent::getTransformerInfo($columnInfo, $metadata);
if ($info) {
list($transformer, $options) = $info;
$options['reference_prefix'] = $columnInfo->getName();
return array($transformer, $options);
}
return null;
}
示例15: readMetadata
/**
* {@inheritdoc}
*/
public function readMetadata(ClassMetadata $doctrineMeta, array &$meta)
{
if (!isset($meta['customObjects'])) {
$meta['customObjects'] = [];
}
foreach ($doctrineMeta->getReflectionClass()->getProperties() as $reflectionProperty) {
$customObjectAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, CustomObject::ANNOTATION);
if (!$customObjectAnnotation instanceof CustomObject) {
continue;
}
$this->validateAnnotation($customObjectAnnotation, $doctrineMeta->getName(), $reflectionProperty->getName());
$meta['customObjects'][$reflectionProperty->getName()] = get_object_vars($customObjectAnnotation);
}
}