本文整理汇总了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::skipTransientField方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::skipTransientField方法的具体用法?PHP ClassMetadata::skipTransientField怎么用?PHP ClassMetadata::skipTransientField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::skipTransientField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadMetadataForClass
/**
* Loads the metadata for the specified class into the provided container.
*
* @param string $className
* @param CommonClassMetadata $metadata
*
* @return void
*/
public function loadMetadataForClass($className, CommonClassMetadata $metadata)
{
/** @var \Doctrine\KeyValueStore\Mapping\ClassMetadata $metadata */
try {
$element = $this->getElement($className);
} catch (MappingException $exception) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
$class = new \ReflectionClass($className);
if (isset($element['storageName'])) {
$metadata->storageName = $element['storageName'];
}
$ids = [];
if (isset($element['id'])) {
$ids = $element['id'];
}
$transients = [];
if (isset($element['transient'])) {
$transients = $element['transient'];
}
foreach ($class->getProperties() as $property) {
if (in_array($property->getName(), $ids)) {
$metadata->mapIdentifier($property->getName());
continue;
}
if (in_array($property->getName(), $transients)) {
$metadata->skipTransientField($property->getName());
continue;
}
$metadata->mapField(array('fieldName' => $property->getName()));
}
}
示例2: loadMetadataForClass
/**
* Loads the metadata for the specified class into the provided container.
*
* @param string $className
* @param ClassMetadata $metadata
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
$class = $metadata->getReflectionClass();
if (!$class) {
// this happens when running annotation driver in combination with
// static reflection services. This is not the nicest fix
$class = new \ReflectionClass($metadata->name);
}
$entityAnnot = $this->reader->getClassAnnotation($class, 'Doctrine\\KeyValueStore\\Mapping\\Annotations\\Entity');
if (!$entityAnnot) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
$metadata->storageName = $entityAnnot->storageName;
// Evaluate annotations on properties/fields
foreach ($class->getProperties() as $property) {
$idAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\KeyValueStore\\Mapping\\Annotations\\Id');
$transientAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\KeyValueStore\\Mapping\\Annotations\\Transient');
if ($idAnnot) {
$metadata->mapIdentifier($property->getName());
} elseif ($transientAnnot) {
$metadata->skipTransientField($property->getName());
} else {
$metadata->mapField(['fieldName' => $property->getName()]);
}
}
}
示例3: loadMetadataForClass
/**
* Loads the metadata for the specified class into the provided container.
*
* @param string $className
* @param CommonClassMetadata $metadata
*
* @return void
*/
public function loadMetadataForClass($className, CommonClassMetadata $metadata)
{
try {
$xmlRoot = $this->getElement($className);
} catch (MappingException $exception) {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
if ($xmlRoot->getName() != 'entity') {
throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
}
$class = new \ReflectionClass($className);
if (isset($xmlRoot['storage-name'])) {
$metadata->storageName = $xmlRoot['storage-name'];
}
$ids = [];
if (isset($xmlRoot->id)) {
foreach ($xmlRoot->id as $id) {
$ids[] = (string) $id;
}
}
$transients = [];
if (isset($xmlRoot->transient)) {
foreach ($xmlRoot->transient as $transient) {
$transients[] = (string) $transient;
}
}
foreach ($class->getProperties() as $property) {
if (in_array($property->getName(), $ids)) {
$metadata->mapIdentifier($property->getName());
continue;
}
if (in_array($property->getName(), $transients)) {
$metadata->skipTransientField($property->getName());
continue;
}
$metadata->mapField(array('fieldName' => $property->getName()));
}
}