/** * {@inheritdoc} */ protected function addMetadataFor(\SimpleXMLElement $xmlRoot, MergeableClassMetadata $classMetadata) { foreach ($xmlRoot->xpath('//cubiche:valueobject') as $item) { // get the field tag $field = $item->xpath('..')[0]; $fieldMapping = $this->getMappingAttributes($field); $fieldName = $fieldMapping['name']; $itemMapping = $this->getMappingAttributes($item); foreach ($item->attributes() as $key => $value) { $itemMapping[$key] = (string) $value; } if (!isset($itemMapping['type'])) { throw MappingException::inField('The cubiche:valueobject definition should have a "type" value', $classMetadata->name, $fieldName); } $valueObjectType = $itemMapping['type']; if ($field->getName() == 'field') { if (isset($fieldMapping['id']) && $fieldMapping['id'] !== false) { throw MappingException::inField('The cubiche:valueobject configuration is only for field tags that is not an id', $classMetadata->name, $fieldName); } if (!isset($fieldMapping['type']) || isset($fieldMapping['type']) && $fieldMapping['type'] !== 'CubicheType') { throw MappingException::inField('The cubiche:valueobject parent should have a "type" value equal to CubicheType', $classMetadata->name, $fieldName); } $propertyMetadata = new PropertyMetadata($classMetadata->name, $fieldName, 'valueobject'); $propertyMetadata->setType($valueObjectType); $classMetadata->addPropertyMetadata($propertyMetadata); } else { throw MappingException::inField('The cubiche:valueobject configuration is only for field tags that is not an id', $classMetadata->name, $fieldName); } } }
/** * @param \ReflectionClass $class */ public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new MergeableClassMetadata($class->getName()); foreach ($this->drivers as $driver) { if (null !== ($metadata = $driver->loadMetadataForClass($class))) { $classMetadata->merge($metadata); } } return $classMetadata; }
public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new MergeableClassMetadata($class->getName()); foreach ($class->getProperties() as $property) { $field = $this->reader->getPropertyAnnotation($property, self::MOGRIFY); if (!is_null($field)) { $propertyMetadata = new MogrifyMetadata($class->getName(), $property->getName()); $propertyMetadata->params = $field->params; $classMetadata->addPropertyMetadata($propertyMetadata); } } return $classMetadata; }
/** * {@inheritdoc} */ protected function loadMetadataFromFile(\ReflectionClass $class, $file) { $classMetadata = new MergeableClassMetadata($class->getName()); // load xml file // TODO xsd validation $xmlDoc = XmlUtils::loadFile($file); $xpath = new \DOMXPath($xmlDoc); $xpath->registerNamespace('x', 'http://schemas.sulu.io/class/general'); $xpath->registerNamespace('list', 'http://schemas.sulu.io/class/list'); foreach ($xpath->query('/x:class/x:properties/x:*') as $propertyNode) { $classMetadata->addPropertyMetadata($this->getPropertyMetadata($xpath, $propertyNode, $class->getName())); } return $classMetadata; }
public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new MergeableClassMetadata($class->getName()); foreach ($class->getProperties() as $reflectionProperty) { $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName()); $annotation = $this->reader->getPropertyAnnotation($reflectionProperty, 'Tapir\\AnnotationBundle\\Annotation\\Descripcion'); if (null !== $annotation) { // Un @Descripcion fue encontrado $propertyMetadata->descripcion = $annotation->value; } $classMetadata->addPropertyMetadata($propertyMetadata); } return $classMetadata; }
/** * {@inheritdoc} */ public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new MergeableClassMetadata($class->getName()); foreach ($class->getMethods() as $method) { $annotation = $this->reader->getMethodAnnotation($method, static::ANNOTATION_CLASS); if ($annotation instanceof LoggerAware) { $this->checkParameters($method, $annotation->getParameter()); $propertyMetadata = new MethodMetadata($class->getName(), $method->getName()); $propertyMetadata->setArgument($annotation->getParameter()); $classMetadata->addMethodMetadata($propertyMetadata); } } return $classMetadata; }
/** * @inheritdoc */ public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new MergeableClassMetadata($class->getName()); foreach ($class->getMethods() as $method) { $annotations = $this->reader->getMethodAnnotations($method); foreach ($annotations as $annotation) { if ($annotation instanceof Transactional) { $propertyMetadata = new MethodMetadata($class->getName(), $method->getName()); $propertyMetadata->setEm($annotation->getEmName())->setOnError($annotation->getOnError())->setOnSuccess($annotation->getOnSuccess()); $classMetadata->addMethodMetadata($propertyMetadata); } } } return $classMetadata; }
/** * {@inheritdoc} */ public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new MergeableClassMetadata($class->getName()); foreach ($class->getProperties() as $reflectionProperty) { $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName()); /** @var \Integrated\Bundle\SlugBundle\Mapping\Annotations\Slug $annotation */ $annotation = $this->reader->getPropertyAnnotation($reflectionProperty, 'Integrated\\Bundle\\SlugBundle\\Mapping\\Annotations\\Slug'); if (null !== $annotation) { $propertyMetadata->slugFields = $annotation->fields; $propertyMetadata->slugSeparator = $annotation->separator; } $classMetadata->addPropertyMetadata($propertyMetadata); } return $classMetadata; }
/** * @inheritdoc */ public function merge(MergeableInterface $object) { parent::merge($object); if ($object instanceof ClassMetadata) { $this->setNamespace($object->getNamespace()); } }
/** * {@inheritdoc} */ public function loadMetadataForClass(\ReflectionClass $class) { $classMetadata = new MergeableClassMetadata($class->getName()); foreach ($class->getMethods() as $method) { $annotation = $this->reader->getMethodAnnotation($method, static::ANNOTATION_CLASS); if ($annotation instanceof SemLock) { $propertyMetadata = new MethodMetadata($class->getName(), $method->getName()); if (!$annotation->getKey()) { throw new \Exception('Lock key not specified'); } $propertyMetadata->setKey($annotation->getKey()); $propertyMetadata->setWaitTimeout($annotation->getWaitTimeout()); $classMetadata->addMethodMetadata($propertyMetadata); } } return $classMetadata; }
/** * Merge metadata. * * @param MergeableInterface $object */ public function merge(MergeableInterface $object) { parent::merge($object); $this->frame = $object->frame; $this->parentClasses = $object->parentClasses; $this->options = $object->options; $this->types = $object->types; }
public function merge(MergeableInterface $object) { if (!$object instanceof ClassMetadata) { throw new \InvalidArgumentException('object must be an instance of FSC\\HateoasBundle\\Metadata\\ClassMetadata.'); } parent::merge($object); $this->relations = array_merge($this->relations, $object->getRelations()); }
/** * {@inheritdoc} */ public function merge(MergeableInterface $object) { if (!$object instanceof self) { throw new \InvalidArgumentException(sprintf('Object must be an instance of %s.', __CLASS__)); } parent::merge($object); $this->relations = array_merge($this->relations, $object->getRelations()); $this->relationProviders = array_merge($this->relationProviders, $object->getRelationProviders()); }
/** * {@inheritDoc} */ public function merge(MergeableInterface $object) { if (!$object instanceof ClassMetadata) { throw new MetadataParseException(); } parent::merge($object); if ($object->objectIdentifier !== null) { $this->objectIdentifier = $object->objectIdentifier; } }
/** * {@inheritdoc} */ public function unserialize($str) { list($this->targetEntity, $translatable, $locale, $parent) = unserialize($str); parent::unserialize($parent); if ($translatable) { $this->translatable = $this->propertyMetadata[$translatable]; } if ($locale) { $this->locale = $this->propertyMetadata[$locale]; } }
public function testMerge() { $parentMetadata = new MergeableClassMetadata('Metadata\\Tests\\Fixtures\\TestParent'); $parentMetadata->propertyMetadata['foo'] = 'bar'; $parentMetadata->propertyMetadata['baz'] = 'baz'; $parentMetadata->methodMetadata['foo'] = 'bar'; $parentMetadata->createdAt = 2; $parentMetadata->fileResources[] = 'foo'; $childMetadata = new MergeableClassMetadata('Metadata\\Tests\\Fixtures\\TestObject'); $childMetadata->propertyMetadata['foo'] = 'baz'; $childMetadata->methodMetadata['foo'] = 'baz'; $childMetadata->createdAt = 1; $childMetadata->fileResources[] = 'bar'; $parentMetadata->merge($childMetadata); $this->assertEquals('Metadata\\Tests\\Fixtures\\TestObject', $parentMetadata->name); $this->assertEquals('Metadata\\Tests\\Fixtures\\TestObject', $parentMetadata->reflection->name); $this->assertEquals(array('foo' => 'baz', 'baz' => 'baz'), $parentMetadata->propertyMetadata); $this->assertEquals(array('foo' => 'baz'), $parentMetadata->methodMetadata); $this->assertEquals(1, $parentMetadata->createdAt); $this->assertEquals(array('foo', 'bar'), $parentMetadata->fileResources); }
/** * {@inheritdoc} */ protected function addMetadataForType($type, \SimpleXMLElement $xmlRoot, MergeableClassMetadata $classMetadata) { foreach ($xmlRoot->xpath('//cubiche:' . $type) as $item) { // get the field tag $field = $item->xpath('..')[0]; $fieldMapping = $this->getMappingAttributes($field); $fieldName = $fieldMapping['name']; if ($field->getName() == 'field') { if (isset($fieldMapping['id']) && $fieldMapping['id'] !== false) { throw MappingException::inField('The cubiche:' . $type . ' configuration is only for field tags that is not an id', $classMetadata->name, $fieldName); } if (!isset($fieldMapping['type']) || isset($fieldMapping['type']) && $fieldMapping['type'] !== 'CubicheType') { throw MappingException::inField('The cubiche:' . $type . ' parent should have a "type" value equal to CubicheType', $classMetadata->name, $fieldName); } $propertyMetadata = new PropertyMetadata($classMetadata->name, $fieldName, $type); $classMetadata->addPropertyMetadata($propertyMetadata); } else { throw MappingException::inField('The cubiche:' . $type . ' configuration is only for id fields', $classMetadata->name, $fieldName); } } }
private function doAddPropertyMetadata(PsiPropertyMetadata $metadata) { parent::addPropertyMetadata($metadata); if (!$metadata->getRole()) { return; } if (isset($this->roles[$metadata->getRole()])) { $propertyName = $this->roles[$metadata->getRole()]; throw new \InvalidArgumentException(sprintf('Role "%s" has already been assigned to property "%s" (on property "%s")', $metadata->getRole(), $propertyName, $metadata->getName())); } $this->roles[$metadata->getRole()] = $metadata->name; }
/** * {@inheritdoc} */ protected function addMetadataFor(\SimpleXMLElement $xmlRoot, MergeableClassMetadata $classMetadata) { foreach ($xmlRoot->xpath('//cubiche:collection') as $item) { // get the field tag $field = $item->xpath('..')[0]; $fieldMapping = $this->getMappingAttributes($field); $fieldName = isset($fieldMapping['name']) ? $fieldMapping['name'] : $fieldMapping['field']; $itemMapping = $this->getMappingAttributes($item, array('of' => null)); if (!isset($itemMapping['type'])) { throw MappingException::inField('The cubiche:collection definition should have a "type" value', $classMetadata->name, $fieldName); } $collectionType = $itemMapping['type']; $collectionOf = $itemMapping['of']; if ($field->getName() == 'field') { if (isset($fieldMapping['id']) && $fieldMapping['id'] !== false) { throw MappingException::inField('The cubiche:collection configuration is only for field tags that is not an id', $classMetadata->name, $fieldName); } if (!isset($fieldMapping['type']) || isset($fieldMapping['type']) && $fieldMapping['type'] !== 'CubicheType') { throw MappingException::inField('The cubiche:collection parent should have a "type" value equal to CubicheType', $classMetadata->name, $fieldName); } $propertyMetadata = new CollectionPropertyMetadata($classMetadata->name, $fieldName); $propertyMetadata->setType($collectionType); $propertyMetadata->setOf($collectionOf); $classMetadata->addPropertyMetadata($propertyMetadata); } elseif ($field->getName() == 'embed-many' || $field->getName() == 'reference-many') { if (isset($fieldMapping['field'])) { $field = $fieldMapping['field']; } else { throw MappingException::inField('Cannot infer a field', $classMetadata->name, $fieldName); } $propertyMetadata = new CollectionPropertyMetadata($classMetadata->name, $field); $propertyMetadata->setType($collectionType); $classMetadata->addPropertyMetadata($propertyMetadata); } else { throw MappingException::inField('The cubiche:collection configuration is only for field, embed-many or reference-many tags', $classMetadata->name, $fieldName); } } }
/** * {@inheritdoc} */ public function unserialize($str) { list($this->targetEntity, $currentLocale, $fallbackLocale, $translations, $parent) = unserialize($str); parent::unserialize($parent); if ($currentLocale) { $this->currentLocale = $this->propertyMetadata[$currentLocale]; } if ($fallbackLocale) { $this->fallbackLocale = $this->propertyMetadata[$fallbackLocale]; } if ($translations) { $this->translations = $this->propertyMetadata[$translations]; } }
public function merge(MergeableInterface $metadata) { if (!$metadata instanceof ClassMetadata) { throw new InvalidArgumentException('$metadata must be an instance of ClassMetadata.'); } foreach ($this->methodMetadata as $name => $methodMetadata) { // check if metadata was declared on an interface if (!$metadata->reflection->hasMethod($name)) { continue; } if ($metadata->reflection->getMethod($name)->getDeclaringClass()->name !== $methodMetadata->class) { if (!isset($metadata->methodMetadata[$name])) { if ($methodMetadata->reflection->isAbstract()) { continue; } throw new RuntimeException(sprintf('You have overridden a secured method "%s::%s" in "%s". ' . 'Please copy over the applicable security metadata, and ' . 'also add @SatisfiesParentSecurityPolicy.', $methodMetadata->reflection->class, $name, $metadata->reflection->name)); } if (!$metadata->methodMetadata[$name]->satisfiesParentSecurityPolicy) { throw new RuntimeException(sprintf('Unresolved security metadata conflict for method "%s::%s" in "%s". Please copy the respective annotations, and add @SatisfiesParentSecurityPolicy to the child method.', $metadata->reflection->name, $name, $methodMetadata->reflection->getDeclaringClass()->getFilename())); } } } parent::merge($metadata); }
public function unserialize($str) { list($this->preSerializeMethods, $this->postSerializeMethods, $this->postDeserializeMethods, $this->xmlRootName, $this->accessorOrder, $this->customOrder, $parentStr) = unserialize($str); parent::unserialize($parentStr); }
public function unserialize($str) { list($this->preSerializeMethods, $this->postSerializeMethods, $this->postDeserializeMethods, $this->xmlRootName, $this->xmlRootNamespace, $this->xmlNamespaces, $this->accessorOrder, $this->customOrder, $this->handlerCallbacks, $this->discriminatorDisabled, $this->discriminatorBaseClass, $this->discriminatorFieldName, $this->discriminatorValue, $this->discriminatorMap, $parentStr) = unserialize($str); parent::unserialize($parentStr); }
/** * Constructor * * @param string $name */ public function __construct($name) { parent::__construct($name); $this->namespaces = []; $this->nodes = []; }
public function unserialize($str) { list($this->schema, $this->inherit, $parentStr) = unserialize($str); parent::unserialize($parentStr); }
/** * Merge metadata. * * @param MergeableInterface $object */ public function merge(MergeableInterface $object) { parent::merge($object); $this->types = array_merge($this->types, $object->types); $this->uriPattern = $object->uriPattern; }
/** * {@inheritdoc} */ public function unserialize($str) { list($this->resource, $this->idField, $this->relationships, $parentStr) = unserialize($str); parent::unserialize($parentStr); }
/** * Merges another ClassMetadata into the current metadata. * * Caution: the registered token providers will be overriden when the new * ClassMetadata has a token provider with the same name. * * The URL schema will be overriden, you can use {parent} to refer to the * previous URL schema. * * @param ClassMetadata $metadata */ public function merge(MergeableInterface $metadata) { parent::merge($metadata); $this->uriSchema = str_replace('{parent}', $this->uriSchema, $metadata->getUriSchema()); foreach ($metadata->getTokenProviders() as $tokenName => $provider) { $this->addTokenProvider($tokenName, $provider, true); } if ($defunctRouteHandler = $metadata->getDefunctRouteHandler()) { $this->setDefunctRouteHandler($defunctRouteHandler); } if ($conflictResolver = $metadata->getConflictResolver()) { $this->setConflictResolver($conflictResolver); } }
/** * {@inheritdoc} */ public function unserialize($str) { list($this->configurable, $this->defaultValues, $this->routeName, $this->routeView, $this->routeCreate, $this->mode, $parentStr) = unserialize($str); parent::unserialize($parentStr); }
/** * {@inheritDoc} */ public function unserialize($str) { list($this->relations, $this->relationProviders, $parentStr) = unserialize($str); parent::unserialize($parentStr); }