本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::hasField方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::hasField方法的具体用法?PHP ClassMetadataInfo::hasField怎么用?PHP ClassMetadataInfo::hasField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadataInfo
的用法示例。
在下文中一共展示了ClassMetadataInfo::hasField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: let
function let(PropertyTransformerInterface $transformer, ColumnInfoInterface $columnInfo, ClassMetadataInfo $metadata)
{
$this->beConstructedWith($transformer, 'array');
$columnInfo->getPropertyPath()->willReturn('property_path');
$metadata->hasField('property_path')->willReturn(true);
$metadata->getTypeOfField('property_path')->willReturn('array');
}
示例2: readExtendedMetadata
/**
* (non-PHPdoc)
* @see Gedmo\Mapping.Driver::readExtendedMetadata()
*/
public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
{
require_once __DIR__ . '/../Annotations.php';
$reader = new AnnotationReader();
$reader->setAnnotationNamespaceAlias('Gedmo\\Timestampable\\Mapping\\', 'gedmo');
$class = $meta->getReflectionClass();
// property annotations
foreach ($class->getProperties() as $property) {
if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
continue;
}
if ($timestampable = $reader->getPropertyAnnotation($property, self::ANNOTATION_TIMESTAMPABLE)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw MappingException::fieldMustBeMapped($field, $meta->name);
}
if (!$this->_isValidField($meta, $field)) {
throw MappingException::notValidFieldType($field, $meta->name);
}
if (!in_array($timestampable->on, array('update', 'create', 'change'))) {
throw MappingException::triggerTypeInvalid($field, $meta->name);
}
if ($timestampable->on == 'change') {
if (!isset($timestampable->field) || !isset($timestampable->value)) {
throw MappingException::parametersMissing($field, $meta->name);
}
$field = array('field' => $field, 'trackedField' => $timestampable->field, 'value' => $timestampable->value);
}
// properties are unique and mapper checks that, no risk here
$config[$timestampable->on][] = $field;
}
}
}
示例3: readExtendedMetadata
/**
* (non-PHPdoc)
* @see Gedmo\Mapping.Driver::readExtendedMetadata()
*/
public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
{
require_once __DIR__ . '/../Annotations.php';
$reader = new AnnotationReader();
$reader->setAnnotationNamespaceAlias('Gedmo\\Tree\\Mapping\\', 'gedmo');
$class = $meta->getReflectionClass();
// property annotations
foreach ($class->getProperties() as $property) {
if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
continue;
}
// left
if ($left = $reader->getPropertyAnnotation($property, self::ANNOTATION_LEFT)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw MappingException::fieldMustBeMapped($field, $meta->name);
}
if (!$this->_isValidField($meta, $field)) {
throw MappingException::notValidFieldType($field, $meta->name);
}
$config['left'] = $field;
}
// right
if ($right = $reader->getPropertyAnnotation($property, self::ANNOTATION_RIGHT)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw MappingException::fieldMustBeMapped($field, $meta->name);
}
if (!$this->_isValidField($meta, $field)) {
throw MappingException::notValidFieldType($field, $meta->name);
}
$config['right'] = $field;
}
// ancestor/parent
if ($parent = $reader->getPropertyAnnotation($property, self::ANNOTATION_PARENT)) {
$field = $property->getName();
if (!$meta->isSingleValuedAssociation($field)) {
throw MappingException::parentFieldNotMappedOrRelated($field, $meta->name);
}
$config['parent'] = $field;
}
// level
if ($parent = $reader->getPropertyAnnotation($property, self::ANNOTATION_LEVEL)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw MappingException::fieldMustBeMapped($field, $meta->name);
}
if (!$this->_isValidField($meta, $field)) {
throw MappingException::notValidFieldType($field, $meta->name);
}
$config['level'] = $field;
}
}
}
示例4: readExtendedMetadata
/**
* (non-PHPdoc)
* @see Gedmo\Mapping.Driver::readExtendedMetadata()
*/
public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
{
require_once __DIR__ . '/../Annotations.php';
$reader = new AnnotationReader();
$reader->setAnnotationNamespaceAlias('Gedmo\\Translatable\\Mapping\\', 'gedmo');
$class = $meta->getReflectionClass();
// class annotations
$classAnnotations = $reader->getClassAnnotations($class);
if (isset($classAnnotations[self::ANNOTATION_ENTITY_CLASS])) {
$annot = $classAnnotations[self::ANNOTATION_ENTITY_CLASS];
if (!class_exists($annot->class)) {
throw MappingException::translationClassNotFound($annot->class);
}
$config['translationClass'] = $annot->class;
}
// property annotations
foreach ($class->getProperties() as $property) {
if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
continue;
}
// translatable property
if ($translatable = $reader->getPropertyAnnotation($property, self::ANNOTATION_TRANSLATABLE)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw MappingException::fieldMustBeMapped($field, $meta->name);
}
if (!$this->_isValidField($meta, $field)) {
throw MappingException::notValidFieldType($field, $meta->name);
}
// fields cannot be overrided and throws mapping exception
$config['fields'][] = $field;
}
// locale property
if ($locale = $reader->getPropertyAnnotation($property, self::ANNOTATION_LOCALE)) {
$field = $property->getName();
if ($meta->hasField($field)) {
throw MappingException::fieldMustNotBeMapped($field, $meta->name);
}
$config['locale'] = $field;
} elseif ($language = $reader->getPropertyAnnotation($property, self::ANNOTATION_LANGUAGE)) {
$field = $property->getName();
if ($meta->hasField($field)) {
throw MappingException::fieldMustNotBeMapped($field, $meta->name);
}
$config['locale'] = $field;
}
}
}
示例5: readExtendedMetadata
/**
* (non-PHPdoc)
* @see Gedmo\Mapping.Driver::readExtendedMetadata()
*/
public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config)
{
require_once __DIR__ . '/../Annotations.php';
$reader = new AnnotationReader();
$reader->setAnnotationNamespaceAlias('Gedmo\\Sluggable\\Mapping\\', 'gedmo');
$class = $meta->getReflectionClass();
// property annotations
foreach ($class->getProperties() as $property) {
if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || $meta->isInheritedAssociation($property->name)) {
continue;
}
// sluggable property
if ($sluggable = $reader->getPropertyAnnotation($property, self::ANNOTATION_SLUGGABLE)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw MappingException::fieldMustBeMapped($field, $meta->name);
}
if (!$this->_isValidField($meta, $field)) {
throw MappingException::notValidFieldType($field, $meta->name);
}
$config['fields'][] = $field;
}
// slug property
if ($slug = $reader->getPropertyAnnotation($property, self::ANNOTATION_SLUG)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw MappingException::slugFieldMustBeMapped($field, $meta->name);
}
if (!$this->_isValidField($meta, $field)) {
throw MappingException::notValidFieldType($field, $meta->name);
}
if (isset($config['slug'])) {
throw MappingException::slugFieldIsDuplicate($field, $meta->name);
}
$config['slug'] = $field;
$config['style'] = $slug->style;
$config['updatable'] = $slug->updatable;
$config['unique'] = $slug->unique;
$config['separator'] = $slug->separator;
}
}
}
示例6: mapField
/**
* Adds mapping to single field
*
* @param string $field
*/
protected function mapField($field)
{
if (!$this->classMetadata->hasField($field)) {
$this->classMetadata->mapField(['fieldName' => $field, 'type' => 'datetime', 'nullable' => true]);
}
}