init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
252
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Annotation.php
vendored
Normal file
252
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Annotation.php
vendored
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
<?php
|
||||
|
||||
namespace Gedmo\Tree\Mapping\Driver;
|
||||
|
||||
use Gedmo\Mapping\Driver\AbstractAnnotationDriver;
|
||||
use Gedmo\Exception\InvalidMappingException;
|
||||
use Gedmo\Tree\Mapping\Validator;
|
||||
|
||||
/**
|
||||
* This is an annotation mapping driver for Tree
|
||||
* behavioral extension. Used for extraction of extended
|
||||
* metadata from Annotations specifically for Tree
|
||||
* extension.
|
||||
*
|
||||
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
||||
* @author <rocco@roccosportal.com>
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
class Annotation extends AbstractAnnotationDriver
|
||||
{
|
||||
/**
|
||||
* Annotation to define the tree type
|
||||
*/
|
||||
const TREE = 'Gedmo\\Mapping\\Annotation\\Tree';
|
||||
|
||||
/**
|
||||
* Annotation to mark field as one which will store left value
|
||||
*/
|
||||
const LEFT = 'Gedmo\\Mapping\\Annotation\\TreeLeft';
|
||||
|
||||
/**
|
||||
* Annotation to mark field as one which will store right value
|
||||
*/
|
||||
const RIGHT = 'Gedmo\\Mapping\\Annotation\\TreeRight';
|
||||
|
||||
/**
|
||||
* Annotation to mark relative parent field
|
||||
*/
|
||||
const PARENT = 'Gedmo\\Mapping\\Annotation\\TreeParent';
|
||||
|
||||
/**
|
||||
* Annotation to mark node level
|
||||
*/
|
||||
const LEVEL = 'Gedmo\\Mapping\\Annotation\\TreeLevel';
|
||||
|
||||
/**
|
||||
* Annotation to mark field as tree root
|
||||
*/
|
||||
const ROOT = 'Gedmo\\Mapping\\Annotation\\TreeRoot';
|
||||
|
||||
/**
|
||||
* Annotation to specify closure tree class
|
||||
*/
|
||||
const CLOSURE = 'Gedmo\\Mapping\\Annotation\\TreeClosure';
|
||||
|
||||
/**
|
||||
* Annotation to specify path class
|
||||
*/
|
||||
const PATH = 'Gedmo\\Mapping\\Annotation\\TreePath';
|
||||
|
||||
/**
|
||||
* Annotation to specify path source class
|
||||
*/
|
||||
const PATH_SOURCE = 'Gedmo\\Mapping\\Annotation\\TreePathSource';
|
||||
|
||||
/**
|
||||
* Annotation to specify path hash class
|
||||
*/
|
||||
const PATH_HASH = 'Gedmo\\Mapping\\Annotation\\TreePathHash';
|
||||
|
||||
/**
|
||||
* Annotation to mark the field to be used to hold the lock time
|
||||
*/
|
||||
const LOCK_TIME = 'Gedmo\\Mapping\\Annotation\\TreeLockTime';
|
||||
|
||||
/**
|
||||
* List of tree strategies available
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $strategies = array(
|
||||
'nested',
|
||||
'closure',
|
||||
'materializedPath',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function readExtendedMetadata($meta, array &$config)
|
||||
{
|
||||
$validator = new Validator();
|
||||
$class = $this->getMetaReflectionClass($meta);
|
||||
// class annotations
|
||||
if ($annot = $this->reader->getClassAnnotation($class, self::TREE)) {
|
||||
if (!in_array($annot->type, $this->strategies)) {
|
||||
throw new InvalidMappingException("Tree type: {$annot->type} is not available.");
|
||||
}
|
||||
$config['strategy'] = $annot->type;
|
||||
$config['activate_locking'] = $annot->activateLocking;
|
||||
$config['locking_timeout'] = (int) $annot->lockingTimeout;
|
||||
|
||||
if ($config['locking_timeout'] < 1) {
|
||||
throw new InvalidMappingException("Tree Locking Timeout must be at least of 1 second.");
|
||||
}
|
||||
}
|
||||
if ($annot = $this->reader->getClassAnnotation($class, self::CLOSURE)) {
|
||||
if (!$cl = $this->getRelatedClassName($meta, $annot->class)) {
|
||||
throw new InvalidMappingException("Tree closure class: {$annot->class} does not exist.");
|
||||
}
|
||||
$config['closure'] = $cl;
|
||||
}
|
||||
|
||||
// property annotations
|
||||
foreach ($class->getProperties() as $property) {
|
||||
if ($meta->isMappedSuperclass && !$property->isPrivate() ||
|
||||
$meta->isInheritedField($property->name) ||
|
||||
isset($meta->associationMappings[$property->name]['inherited'])
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
// left
|
||||
if ($this->reader->getPropertyAnnotation($property, self::LEFT)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'left' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree left field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['left'] = $field;
|
||||
}
|
||||
// right
|
||||
if ($this->reader->getPropertyAnnotation($property, self::RIGHT)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'right' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree right field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['right'] = $field;
|
||||
}
|
||||
// ancestor/parent
|
||||
if ($this->reader->getPropertyAnnotation($property, self::PARENT)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->isSingleValuedAssociation($field)) {
|
||||
throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['parent'] = $field;
|
||||
}
|
||||
// root
|
||||
if ($this->reader->getPropertyAnnotation($property, self::ROOT)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->isSingleValuedAssociation($field)) {
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'root' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
|
||||
if (!$validator->isValidFieldForRoot($meta, $field)) {
|
||||
throw new InvalidMappingException(
|
||||
"Tree root field should be either a literal property ('integer' types or 'string') or a many-to-one association through root field - [{$field}] in class - {$meta->name}"
|
||||
);
|
||||
}
|
||||
}
|
||||
$annotation = $this->reader->getPropertyAnnotation($property, self::ROOT);
|
||||
$config['rootIdentifierMethod'] = $annotation->identifierMethod;
|
||||
$config['root'] = $field;
|
||||
}
|
||||
// level
|
||||
if ($this->reader->getPropertyAnnotation($property, self::LEVEL)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'level' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree level field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['level'] = $field;
|
||||
}
|
||||
// path
|
||||
if ($pathAnnotation = $this->reader->getPropertyAnnotation($property, self::PATH)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'path' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
if (!$validator->isValidFieldForPath($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree Path field - [{$field}] type is not valid. It must be string or text in class - {$meta->name}");
|
||||
}
|
||||
if (strlen($pathAnnotation->separator) > 1) {
|
||||
throw new InvalidMappingException("Tree Path field - [{$field}] Separator {$pathAnnotation->separator} is invalid. It must be only one character long.");
|
||||
}
|
||||
$config['path'] = $field;
|
||||
$config['path_separator'] = $pathAnnotation->separator;
|
||||
$config['path_append_id'] = $pathAnnotation->appendId;
|
||||
$config['path_starts_with_separator'] = $pathAnnotation->startsWithSeparator;
|
||||
$config['path_ends_with_separator'] = $pathAnnotation->endsWithSeparator;
|
||||
}
|
||||
// path source
|
||||
if ($this->reader->getPropertyAnnotation($property, self::PATH_SOURCE)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'path_source' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
if (!$validator->isValidFieldForPathSource($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree PathSource field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}");
|
||||
}
|
||||
$config['path_source'] = $field;
|
||||
}
|
||||
|
||||
// path hash
|
||||
if ($this->reader->getPropertyAnnotation($property, self::PATH_HASH)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'path_hash' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
if (!$validator->isValidFieldForPathHash($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree PathHash field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}");
|
||||
}
|
||||
$config['path_hash'] = $field;
|
||||
}
|
||||
// lock time
|
||||
|
||||
if ($this->reader->getPropertyAnnotation($property, self::LOCK_TIME)) {
|
||||
$field = $property->getName();
|
||||
if (!$meta->hasField($field)) {
|
||||
throw new InvalidMappingException("Unable to find 'lock_time' - [{$field}] as mapped property in entity - {$meta->name}");
|
||||
}
|
||||
if (!$validator->isValidFieldForLockTime($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree PathSource field - [{$field}] type is not valid. It must be \"date\" in class - {$meta->name}");
|
||||
}
|
||||
$config['lock_time'] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['activate_locking']) && $config['activate_locking'] && !isset($config['lock_time'])) {
|
||||
throw new InvalidMappingException("You need to map a date field as the tree lock time field to activate locking support.");
|
||||
}
|
||||
|
||||
if (!$meta->isMappedSuperclass && $config) {
|
||||
if (isset($config['strategy'])) {
|
||||
if (is_array($meta->identifier) && count($meta->identifier) > 1) {
|
||||
throw new InvalidMappingException("Tree does not support composite identifiers in class - {$meta->name}");
|
||||
}
|
||||
$method = 'validate'.ucfirst($config['strategy']).'TreeMetadata';
|
||||
$validator->$method($meta, $config);
|
||||
} else {
|
||||
throw new InvalidMappingException("Cannot find Tree type for class: {$meta->name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
267
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Xml.php
vendored
Normal file
267
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Xml.php
vendored
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
|
||||
namespace Gedmo\Tree\Mapping\Driver;
|
||||
|
||||
use Gedmo\Mapping\Driver\Xml as BaseXml;
|
||||
use Gedmo\Exception\InvalidMappingException;
|
||||
use Gedmo\Tree\Mapping\Validator;
|
||||
|
||||
/**
|
||||
* This is a xml mapping driver for Tree
|
||||
* behavioral extension. Used for extraction of extended
|
||||
* metadata from xml specifically for Tree
|
||||
* extension.
|
||||
*
|
||||
* @author Gustavo Falco <comfortablynumb84@gmail.com>
|
||||
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
||||
* @author Miha Vrhovnik <miha.vrhovnik@gmail.com>
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
class Xml extends BaseXml
|
||||
{
|
||||
/**
|
||||
* List of tree strategies available
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $strategies = array(
|
||||
'nested',
|
||||
'closure',
|
||||
'materializedPath',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function readExtendedMetadata($meta, array &$config)
|
||||
{
|
||||
/**
|
||||
* @var \SimpleXmlElement $xml
|
||||
*/
|
||||
$xml = $this->_getMapping($meta->name);
|
||||
$xmlDoctrine = $xml;
|
||||
$xml = $xml->children(self::GEDMO_NAMESPACE_URI);
|
||||
$validator = new Validator();
|
||||
|
||||
if (isset($xml->tree) && $this->_isAttributeSet($xml->tree, 'type')) {
|
||||
$strategy = $this->_getAttribute($xml->tree, 'type');
|
||||
if (!in_array($strategy, $this->strategies)) {
|
||||
throw new InvalidMappingException("Tree type: $strategy is not available.");
|
||||
}
|
||||
$config['strategy'] = $strategy;
|
||||
$config['activate_locking'] = $this->_getAttribute($xml->tree, 'activate-locking') === 'true' ? true : false;
|
||||
|
||||
if ($lockingTimeout = $this->_getAttribute($xml->tree, 'locking-timeout')) {
|
||||
$config['locking_timeout'] = (int) $lockingTimeout;
|
||||
|
||||
if ($config['locking_timeout'] < 1) {
|
||||
throw new InvalidMappingException("Tree Locking Timeout must be at least of 1 second.");
|
||||
}
|
||||
} else {
|
||||
$config['locking_timeout'] = 3;
|
||||
}
|
||||
}
|
||||
if (isset($xml->{'tree-closure'}) && $this->_isAttributeSet($xml->{'tree-closure'}, 'class')) {
|
||||
$class = $this->_getAttribute($xml->{'tree-closure'}, 'class');
|
||||
if (!$cl = $this->getRelatedClassName($meta, $class)) {
|
||||
throw new InvalidMappingException("Tree closure class: {$class} does not exist.");
|
||||
}
|
||||
$config['closure'] = $cl;
|
||||
}
|
||||
if (isset($xmlDoctrine->field)) {
|
||||
foreach ($xmlDoctrine->field as $mapping) {
|
||||
$mappingDoctrine = $mapping;
|
||||
$mapping = $mapping->children(self::GEDMO_NAMESPACE_URI);
|
||||
|
||||
$field = $this->_getAttribute($mappingDoctrine, 'name');
|
||||
if (isset($mapping->{'tree-left'})) {
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree left field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['left'] = $field;
|
||||
} elseif (isset($mapping->{'tree-right'})) {
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree right field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['right'] = $field;
|
||||
} elseif (isset($mapping->{'tree-root'})) {
|
||||
if (!$validator->isValidFieldForRoot($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree root field - [{$field}] type is not valid and must be any of the 'integer' types or 'string' in class - {$meta->name}");
|
||||
}
|
||||
$config['root'] = $field;
|
||||
} elseif (isset($mapping->{'tree-level'})) {
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree level field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['level'] = $field;
|
||||
} elseif (isset($mapping->{'tree-path'})) {
|
||||
if (!$validator->isValidFieldForPath($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree Path field - [{$field}] type is not valid. It must be string or text in class - {$meta->name}");
|
||||
}
|
||||
|
||||
$separator = $this->_getAttribute($mapping->{'tree-path'}, 'separator');
|
||||
|
||||
if (strlen($separator) > 1) {
|
||||
throw new InvalidMappingException("Tree Path field - [{$field}] Separator {$separator} is invalid. It must be only one character long.");
|
||||
}
|
||||
|
||||
$appendId = $this->_getAttribute($mapping->{'tree-path'}, 'append_id');
|
||||
|
||||
if (!$appendId) {
|
||||
$appendId = true;
|
||||
} else {
|
||||
$appendId = strtolower($appendId) == 'false' ? false : true;
|
||||
}
|
||||
|
||||
$startsWithSeparator = $this->_getAttribute($mapping->{'tree-path'}, 'starts_with_separator');
|
||||
|
||||
if (!$startsWithSeparator) {
|
||||
$startsWithSeparator = false;
|
||||
} else {
|
||||
$startsWithSeparator = strtolower($startsWithSeparator) == 'false' ? false : true;
|
||||
}
|
||||
|
||||
$endsWithSeparator = $this->_getAttribute($mapping->{'tree-path'}, 'ends_with_separator');
|
||||
|
||||
if (!$endsWithSeparator) {
|
||||
$endsWithSeparator = true;
|
||||
} else {
|
||||
$endsWithSeparator = strtolower($endsWithSeparator) == 'false' ? false : true;
|
||||
}
|
||||
|
||||
$config['path'] = $field;
|
||||
$config['path_separator'] = $separator;
|
||||
$config['path_append_id'] = $appendId;
|
||||
$config['path_starts_with_separator'] = $startsWithSeparator;
|
||||
$config['path_ends_with_separator'] = $endsWithSeparator;
|
||||
} elseif (isset($mapping->{'tree-path-source'})) {
|
||||
if (!$validator->isValidFieldForPathSource($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree PathSource field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}");
|
||||
}
|
||||
$config['path_source'] = $field;
|
||||
} elseif (isset($mapping->{'tree-lock-time'})) {
|
||||
if (!$validator->isValidFieldForLockTime($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree LockTime field - [{$field}] type is not valid. It must be \"date\" in class - {$meta->name}");
|
||||
}
|
||||
$config['lock_time'] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['activate_locking']) && $config['activate_locking'] && !isset($config['lock_time'])) {
|
||||
throw new InvalidMappingException("You need to map a date field as the tree lock time field to activate locking support.");
|
||||
}
|
||||
|
||||
if ($xmlDoctrine->getName() == 'mapped-superclass') {
|
||||
if (isset($xmlDoctrine->{'many-to-one'})) {
|
||||
foreach ($xmlDoctrine->{'many-to-one'} as $manyToOneMapping) {
|
||||
/**
|
||||
* @var \SimpleXMLElement $manyToOneMapping
|
||||
*/
|
||||
$manyToOneMappingDoctrine = $manyToOneMapping;
|
||||
$manyToOneMapping = $manyToOneMapping->children(self::GEDMO_NAMESPACE_URI);
|
||||
if (isset($manyToOneMapping->{'tree-parent'})) {
|
||||
$field = $this->_getAttribute($manyToOneMappingDoctrine, 'field');
|
||||
$targetEntity = $meta->associationMappings[$field]['targetEntity'];
|
||||
if (!$cl = $this->getRelatedClassName($meta, $targetEntity)) {
|
||||
throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['parent'] = $field;
|
||||
}
|
||||
if (isset($manyToOneMapping->{'tree-root'})) {
|
||||
$field = $this->_getAttribute($manyToOneMappingDoctrine, 'field');
|
||||
$targetEntity = $meta->associationMappings[$field]['targetEntity'];
|
||||
if (!$cl = $this->getRelatedClassName($meta, $targetEntity)) {
|
||||
throw new InvalidMappingException("Unable to find root descendant relation through root field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['root'] = $field;
|
||||
}
|
||||
}
|
||||
} elseif (isset($xmlDoctrine->{'reference-one'})) {
|
||||
foreach ($xmlDoctrine->{'reference-one'} as $referenceOneMapping) {
|
||||
/**
|
||||
* @var \SimpleXMLElement $referenceOneMapping
|
||||
*/
|
||||
$referenceOneMappingDoctrine = $referenceOneMapping;
|
||||
$referenceOneMapping = $referenceOneMapping->children(self::GEDMO_NAMESPACE_URI);
|
||||
if (isset($referenceOneMapping->{'tree-parent'})) {
|
||||
$field = $this->_getAttribute($referenceOneMappingDoctrine, 'field');
|
||||
if (!$cl = $this->getRelatedClassName($meta, $this->_getAttribute($referenceOneMappingDoctrine, 'target-document'))) {
|
||||
throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['parent'] = $field;
|
||||
}
|
||||
if (isset($referenceOneMapping->{'tree-root'})) {
|
||||
$field = $this->_getAttribute($referenceOneMappingDoctrine, 'field');
|
||||
if (!$cl = $this->getRelatedClassName($meta, $this->_getAttribute($referenceOneMappingDoctrine, 'target-document'))) {
|
||||
throw new InvalidMappingException("Unable to find root descendant relation through root field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['root'] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($xmlDoctrine->getName() == 'entity') {
|
||||
if (isset($xmlDoctrine->{'many-to-one'})) {
|
||||
foreach ($xmlDoctrine->{'many-to-one'} as $manyToOneMapping) {
|
||||
/**
|
||||
* @var \SimpleXMLElement $manyToOneMapping
|
||||
*/
|
||||
$manyToOneMappingDoctrine = $manyToOneMapping;
|
||||
$manyToOneMapping = $manyToOneMapping->children(self::GEDMO_NAMESPACE_URI);
|
||||
if (isset($manyToOneMapping->{'tree-parent'})) {
|
||||
$field = $this->_getAttribute($manyToOneMappingDoctrine, 'field');
|
||||
$targetEntity = $meta->associationMappings[$field]['targetEntity'];
|
||||
if (!$cl = $this->getRelatedClassName($meta, $targetEntity)) {
|
||||
throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['parent'] = $field;
|
||||
}
|
||||
if (isset($manyToOneMapping->{'tree-root'})) {
|
||||
$field = $this->_getAttribute($manyToOneMappingDoctrine, 'field');
|
||||
$targetEntity = $meta->associationMappings[$field]['targetEntity'];
|
||||
if (!$cl = $this->getRelatedClassName($meta, $targetEntity)) {
|
||||
throw new InvalidMappingException("Unable to find root descendant relation through root field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['root'] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($xmlDoctrine->getName() == 'document') {
|
||||
if (isset($xmlDoctrine->{'reference-one'})) {
|
||||
foreach ($xmlDoctrine->{'reference-one'} as $referenceOneMapping) {
|
||||
/**
|
||||
* @var \SimpleXMLElement $referenceOneMapping
|
||||
*/
|
||||
$referenceOneMappingDoctrine = $referenceOneMapping;
|
||||
$referenceOneMapping = $referenceOneMapping->children(self::GEDMO_NAMESPACE_URI);
|
||||
if (isset($referenceOneMapping->{'tree-parent'})) {
|
||||
$field = $this->_getAttribute($referenceOneMappingDoctrine, 'field');
|
||||
if (!$cl = $this->getRelatedClassName($meta, $this->_getAttribute($referenceOneMappingDoctrine, 'target-document'))) {
|
||||
throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['parent'] = $field;
|
||||
}
|
||||
if (isset($referenceOneMapping->{'tree-root'})) {
|
||||
$field = $this->_getAttribute($referenceOneMappingDoctrine, 'field');
|
||||
if (!$cl = $this->getRelatedClassName($meta, $this->_getAttribute($referenceOneMappingDoctrine, 'target-document'))) {
|
||||
throw new InvalidMappingException("Unable to find root descendant relation through root field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['root'] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$meta->isMappedSuperclass && $config) {
|
||||
if (isset($config['strategy'])) {
|
||||
if (is_array($meta->identifier) && count($meta->identifier) > 1) {
|
||||
throw new InvalidMappingException("Tree does not support composite identifiers in class - {$meta->name}");
|
||||
}
|
||||
$method = 'validate'.ucfirst($config['strategy']).'TreeMetadata';
|
||||
$validator->$method($meta, $config);
|
||||
} else {
|
||||
throw new InvalidMappingException("Cannot find Tree type for class: {$meta->name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
215
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Yaml.php
vendored
Normal file
215
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Yaml.php
vendored
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
|
||||
namespace Gedmo\Tree\Mapping\Driver;
|
||||
|
||||
use Gedmo\Mapping\Driver\File;
|
||||
use Gedmo\Mapping\Driver;
|
||||
use Gedmo\Exception\InvalidMappingException;
|
||||
use Gedmo\Tree\Mapping\Validator;
|
||||
|
||||
/**
|
||||
* This is a yaml mapping driver for Tree
|
||||
* behavioral extension. Used for extraction of extended
|
||||
* metadata from yaml specifically for Tree
|
||||
* extension.
|
||||
*
|
||||
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
class Yaml extends File implements Driver
|
||||
{
|
||||
/**
|
||||
* File extension
|
||||
* @var string
|
||||
*/
|
||||
protected $_extension = '.dcm.yml';
|
||||
|
||||
/**
|
||||
* List of tree strategies available
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $strategies = array(
|
||||
'nested',
|
||||
'closure',
|
||||
'materializedPath',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function readExtendedMetadata($meta, array &$config)
|
||||
{
|
||||
$mapping = $this->_getMapping($meta->name);
|
||||
$validator = new Validator();
|
||||
|
||||
if (isset($mapping['gedmo'])) {
|
||||
$classMapping = $mapping['gedmo'];
|
||||
if (isset($classMapping['tree']['type'])) {
|
||||
$strategy = $classMapping['tree']['type'];
|
||||
if (!in_array($strategy, $this->strategies)) {
|
||||
throw new InvalidMappingException("Tree type: $strategy is not available.");
|
||||
}
|
||||
$config['strategy'] = $strategy;
|
||||
$config['activate_locking'] = isset($classMapping['tree']['activateLocking']) ?
|
||||
$classMapping['tree']['activateLocking'] : false;
|
||||
$config['locking_timeout'] = isset($classMapping['tree']['lockingTimeout']) ?
|
||||
(int) $classMapping['tree']['lockingTimeout'] : 3;
|
||||
|
||||
if ($config['locking_timeout'] < 1) {
|
||||
throw new InvalidMappingException("Tree Locking Timeout must be at least of 1 second.");
|
||||
}
|
||||
}
|
||||
if (isset($classMapping['tree']['closure'])) {
|
||||
if (!$class = $this->getRelatedClassName($meta, $classMapping['tree']['closure'])) {
|
||||
throw new InvalidMappingException("Tree closure class: {$classMapping['tree']['closure']} does not exist.");
|
||||
}
|
||||
$config['closure'] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($mapping['id'])) {
|
||||
foreach($mapping['id'] as $field => $fieldMapping) {
|
||||
if (isset($fieldMapping['gedmo'])) {
|
||||
if (in_array('treePathSource', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidFieldForPathSource($meta, $field)) {
|
||||
throw new InvalidMappingException(
|
||||
"Tree PathSource field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}"
|
||||
);
|
||||
}
|
||||
$config['path_source'] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($mapping['fields'])) {
|
||||
foreach ($mapping['fields'] as $field => $fieldMapping) {
|
||||
if (isset($fieldMapping['gedmo'])) {
|
||||
if (in_array('treeLeft', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree left field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['left'] = $field;
|
||||
} elseif (in_array('treeRight', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree right field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['right'] = $field;
|
||||
} elseif (in_array('treeLevel', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidField($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree level field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
|
||||
}
|
||||
$config['level'] = $field;
|
||||
} elseif (in_array('treeRoot', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidFieldForRoot($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree root field - [{$field}] type is not valid and must be any of the 'integer' types or 'string' in class - {$meta->name}");
|
||||
}
|
||||
$config['root'] = $field;
|
||||
} elseif (in_array('treePath', $fieldMapping['gedmo']) || isset($fieldMapping['gedmo']['treePath'])) {
|
||||
if (!$validator->isValidFieldForPath($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree Path field - [{$field}] type is not valid. It must be string or text in class - {$meta->name}");
|
||||
}
|
||||
|
||||
$treePathInfo = isset($fieldMapping['gedmo']['treePath']) ? $fieldMapping['gedmo']['treePath'] :
|
||||
$fieldMapping['gedmo'][array_search('treePath', $fieldMapping['gedmo'])];
|
||||
|
||||
if (is_array($treePathInfo) && isset($treePathInfo['separator'])) {
|
||||
$separator = $treePathInfo['separator'];
|
||||
} else {
|
||||
$separator = '|';
|
||||
}
|
||||
|
||||
if (strlen($separator) > 1) {
|
||||
throw new InvalidMappingException("Tree Path field - [{$field}] Separator {$separator} is invalid. It must be only one character long.");
|
||||
}
|
||||
|
||||
if (is_array($treePathInfo) && isset($treePathInfo['appendId'])) {
|
||||
$appendId = $treePathInfo['appendId'];
|
||||
} else {
|
||||
$appendId = null;
|
||||
}
|
||||
|
||||
if (is_array($treePathInfo) && isset($treePathInfo['startsWithSeparator'])) {
|
||||
$startsWithSeparator = $treePathInfo['startsWithSeparator'];
|
||||
} else {
|
||||
$startsWithSeparator = false;
|
||||
}
|
||||
|
||||
if (is_array($treePathInfo) && isset($treePathInfo['endsWithSeparator'])) {
|
||||
$endsWithSeparator = $treePathInfo['endsWithSeparator'];
|
||||
} else {
|
||||
$endsWithSeparator = true;
|
||||
}
|
||||
|
||||
$config['path'] = $field;
|
||||
$config['path_separator'] = $separator;
|
||||
$config['path_append_id'] = $appendId;
|
||||
$config['path_starts_with_separator'] = $startsWithSeparator;
|
||||
$config['path_ends_with_separator'] = $endsWithSeparator;
|
||||
} elseif (in_array('treePathSource', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidFieldForPathSource($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree PathSource field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}");
|
||||
}
|
||||
$config['path_source'] = $field;
|
||||
} elseif (in_array('treePathHash', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidFieldForPathSource($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree PathHash field - [{$field}] type is not valid and must be 'string' in class - {$meta->name}");
|
||||
}
|
||||
$config['path_hash'] = $field;
|
||||
} elseif (in_array('treeLockTime', $fieldMapping['gedmo'])) {
|
||||
if (!$validator->isValidFieldForLocktime($meta, $field)) {
|
||||
throw new InvalidMappingException("Tree LockTime field - [{$field}] type is not valid. It must be \"date\" in class - {$meta->name}");
|
||||
}
|
||||
$config['lock_time'] = $field;
|
||||
} elseif (in_array('treeParent', $fieldMapping['gedmo'])) {
|
||||
$config['parent'] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['activate_locking']) && $config['activate_locking'] && !isset($config['lock_time'])) {
|
||||
throw new InvalidMappingException("You need to map a date|datetime|timestamp field as the tree lock time field to activate locking support.");
|
||||
}
|
||||
|
||||
if (isset($mapping['manyToOne'])) {
|
||||
foreach ($mapping['manyToOne'] as $field => $relationMapping) {
|
||||
if (isset($relationMapping['gedmo'])) {
|
||||
if (in_array('treeParent', $relationMapping['gedmo'])) {
|
||||
if (!$rel = $this->getRelatedClassName($meta, $relationMapping['targetEntity'])) {
|
||||
throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['parent'] = $field;
|
||||
}
|
||||
if (in_array('treeRoot', $relationMapping['gedmo'])) {
|
||||
if (!$rel = $this->getRelatedClassName($meta, $relationMapping['targetEntity'])) {
|
||||
throw new InvalidMappingException("Unable to find root-descendant relation through root field - [{$field}] in class - {$meta->name}");
|
||||
}
|
||||
$config['root'] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$meta->isMappedSuperclass && $config) {
|
||||
if (isset($config['strategy'])) {
|
||||
if (is_array($meta->identifier) && count($meta->identifier) > 1) {
|
||||
throw new InvalidMappingException("Tree does not support composite identifiers in class - {$meta->name}");
|
||||
}
|
||||
$method = 'validate'.ucfirst($config['strategy']).'TreeMetadata';
|
||||
$validator->$method($meta, $config);
|
||||
} else {
|
||||
throw new InvalidMappingException("Cannot find Tree type for class: {$meta->name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function _loadMappingFile($file)
|
||||
{
|
||||
return \Symfony\Component\Yaml\Yaml::parse(file_get_contents($file));
|
||||
}
|
||||
}
|
||||
18
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Event/Adapter/ODM.php
vendored
Normal file
18
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Event/Adapter/ODM.php
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Gedmo\Tree\Mapping\Event\Adapter;
|
||||
|
||||
use Gedmo\Mapping\Event\Adapter\ODM as BaseAdapterODM;
|
||||
use Gedmo\Tree\Mapping\Event\TreeAdapter;
|
||||
|
||||
/**
|
||||
* Doctrine event adapter for ODM adapted
|
||||
* for Tree behavior
|
||||
*
|
||||
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
final class ODM extends BaseAdapterODM implements TreeAdapter
|
||||
{
|
||||
// Nothing specific yet
|
||||
}
|
||||
18
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Event/Adapter/ORM.php
vendored
Normal file
18
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Event/Adapter/ORM.php
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Gedmo\Tree\Mapping\Event\Adapter;
|
||||
|
||||
use Gedmo\Mapping\Event\Adapter\ORM as BaseAdapterORM;
|
||||
use Gedmo\Tree\Mapping\Event\TreeAdapter;
|
||||
|
||||
/**
|
||||
* Doctrine event adapter for ORM adapted
|
||||
* for Tree behavior
|
||||
*
|
||||
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
final class ORM extends BaseAdapterORM implements TreeAdapter
|
||||
{
|
||||
// Nothing specific yet
|
||||
}
|
||||
16
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Event/TreeAdapter.php
vendored
Normal file
16
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Event/TreeAdapter.php
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Gedmo\Tree\Mapping\Event;
|
||||
|
||||
use Gedmo\Mapping\Event\AdapterInterface;
|
||||
|
||||
/**
|
||||
* Doctrine event adapter interface
|
||||
* for Tree behavior
|
||||
*
|
||||
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
interface TreeAdapter extends AdapterInterface
|
||||
{
|
||||
}
|
||||
240
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Validator.php
vendored
Normal file
240
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Validator.php
vendored
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
|
||||
namespace Gedmo\Tree\Mapping;
|
||||
|
||||
use Gedmo\Exception\InvalidMappingException;
|
||||
|
||||
/**
|
||||
* This is a validator for all mapping drivers for Tree
|
||||
* behavioral extension, containing methods to validate
|
||||
* mapping information
|
||||
*
|
||||
* @author Gustavo Falco <comfortablynumb84@gmail.com>
|
||||
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
||||
* @author <rocco@roccosportal.com>
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
class Validator
|
||||
{
|
||||
/**
|
||||
* List of types which are valid for tree fields
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $validTypes = array(
|
||||
'integer',
|
||||
'smallint',
|
||||
'bigint',
|
||||
'int',
|
||||
);
|
||||
|
||||
/**
|
||||
* List of types which are valid for the path (materialized path strategy)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $validPathTypes = array(
|
||||
'string',
|
||||
'text',
|
||||
);
|
||||
|
||||
/**
|
||||
* List of types which are valid for the path source (materialized path strategy)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $validPathSourceTypes = array(
|
||||
'id',
|
||||
'integer',
|
||||
'smallint',
|
||||
'bigint',
|
||||
'string',
|
||||
'int',
|
||||
'float',
|
||||
);
|
||||
|
||||
/**
|
||||
* List of types which are valid for the path hash (materialized path strategy)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $validPathHashTypes = array(
|
||||
'string',
|
||||
);
|
||||
|
||||
/**
|
||||
* List of types which are valid for the path source (materialized path strategy)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $validRootTypes = array(
|
||||
'integer',
|
||||
'smallint',
|
||||
'bigint',
|
||||
'int',
|
||||
'string',
|
||||
'guid',
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks if $field type is valid
|
||||
*
|
||||
* @param object $meta
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidField($meta, $field)
|
||||
{
|
||||
$mapping = $meta->getFieldMapping($field);
|
||||
|
||||
return $mapping && in_array($mapping['type'], $this->validTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if $field type is valid for Path field
|
||||
*
|
||||
* @param object $meta
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidFieldForPath($meta, $field)
|
||||
{
|
||||
$mapping = $meta->getFieldMapping($field);
|
||||
|
||||
return $mapping && in_array($mapping['type'], $this->validPathTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if $field type is valid for PathSource field
|
||||
*
|
||||
* @param object $meta
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidFieldForPathSource($meta, $field)
|
||||
{
|
||||
$mapping = $meta->getFieldMapping($field);
|
||||
|
||||
return $mapping && in_array($mapping['type'], $this->validPathSourceTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if $field type is valid for PathHash field
|
||||
*
|
||||
* @param object $meta
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidFieldForPathHash($meta, $field)
|
||||
{
|
||||
$mapping = $meta->getFieldMapping($field);
|
||||
|
||||
return $mapping && in_array($mapping['type'], $this->validPathHashTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if $field type is valid for LockTime field
|
||||
*
|
||||
* @param object $meta
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidFieldForLockTime($meta, $field)
|
||||
{
|
||||
$mapping = $meta->getFieldMapping($field);
|
||||
|
||||
return $mapping && ($mapping['type'] === 'date' || $mapping['type'] === 'datetime' || $mapping['type'] === 'timestamp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if $field type is valid for Root field
|
||||
*
|
||||
* @param object $meta
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValidFieldForRoot($meta, $field)
|
||||
{
|
||||
$mapping = $meta->getFieldMapping($field);
|
||||
|
||||
return $mapping && in_array($mapping['type'], $this->validRootTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates metadata for nested type tree
|
||||
*
|
||||
* @param object $meta
|
||||
* @param array $config
|
||||
*
|
||||
* @throws InvalidMappingException
|
||||
*/
|
||||
public function validateNestedTreeMetadata($meta, array $config)
|
||||
{
|
||||
$missingFields = array();
|
||||
if (!isset($config['parent'])) {
|
||||
$missingFields[] = 'ancestor';
|
||||
}
|
||||
if (!isset($config['left'])) {
|
||||
$missingFields[] = 'left';
|
||||
}
|
||||
if (!isset($config['right'])) {
|
||||
$missingFields[] = 'right';
|
||||
}
|
||||
if ($missingFields) {
|
||||
throw new InvalidMappingException("Missing properties: ".implode(', ', $missingFields)." in class - {$meta->name}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates metadata for closure type tree
|
||||
*
|
||||
* @param object $meta
|
||||
* @param array $config
|
||||
*
|
||||
* @throws InvalidMappingException
|
||||
*/
|
||||
public function validateClosureTreeMetadata($meta, array $config)
|
||||
{
|
||||
$missingFields = array();
|
||||
if (!isset($config['parent'])) {
|
||||
$missingFields[] = 'ancestor';
|
||||
}
|
||||
if (!isset($config['closure'])) {
|
||||
$missingFields[] = 'closure class';
|
||||
}
|
||||
if ($missingFields) {
|
||||
throw new InvalidMappingException("Missing properties: ".implode(', ', $missingFields)." in class - {$meta->name}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates metadata for materialized path type tree
|
||||
*
|
||||
* @param object $meta
|
||||
* @param array $config
|
||||
*
|
||||
* @throws InvalidMappingException
|
||||
*/
|
||||
public function validateMaterializedPathTreeMetadata($meta, array $config)
|
||||
{
|
||||
$missingFields = array();
|
||||
if (!isset($config['parent'])) {
|
||||
$missingFields[] = 'ancestor';
|
||||
}
|
||||
if (!isset($config['path'])) {
|
||||
$missingFields[] = 'path';
|
||||
}
|
||||
if (!isset($config['path_source'])) {
|
||||
$missingFields[] = 'path_source';
|
||||
}
|
||||
if ($missingFields) {
|
||||
throw new InvalidMappingException("Missing properties: ".implode(', ', $missingFields)." in class - {$meta->name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue