当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadata::enableAssociationCache方法代码示例

本文整理汇总了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::enableAssociationCache方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::enableAssociationCache方法的具体用法?PHP ClassMetadata::enableAssociationCache怎么用?PHP ClassMetadata::enableAssociationCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Persistence\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::enableAssociationCache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadMetadataForClass


//.........这里部分代码省略.........
             if (isset($oneToOneElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . $oneToOneElement['fetch']);
             }
             if (isset($oneToOneElement['mappedBy'])) {
                 $mapping['mappedBy'] = $oneToOneElement['mappedBy'];
             } else {
                 if (isset($oneToOneElement['inversedBy'])) {
                     $mapping['inversedBy'] = $oneToOneElement['inversedBy'];
                 }
                 $joinColumns = array();
                 if (isset($oneToOneElement['joinColumn'])) {
                     $joinColumns[] = $this->joinColumnToArray($oneToOneElement['joinColumn']);
                 } else {
                     if (isset($oneToOneElement['joinColumns'])) {
                         foreach ($oneToOneElement['joinColumns'] as $joinColumnName => $joinColumnElement) {
                             if (!isset($joinColumnElement['name'])) {
                                 $joinColumnElement['name'] = $joinColumnName;
                             }
                             $joinColumns[] = $this->joinColumnToArray($joinColumnElement);
                         }
                     }
                 }
                 $mapping['joinColumns'] = $joinColumns;
             }
             if (isset($oneToOneElement['cascade'])) {
                 $mapping['cascade'] = $oneToOneElement['cascade'];
             }
             if (isset($oneToOneElement['orphanRemoval'])) {
                 $mapping['orphanRemoval'] = (bool) $oneToOneElement['orphanRemoval'];
             }
             $metadata->mapOneToOne($mapping);
             // Evaluate second level cache
             if (isset($oneToOneElement['cache'])) {
                 $metadata->enableAssociationCache($mapping['fieldName'], $this->cacheToArray($oneToOneElement['cache']));
             }
         }
     }
     // Evaluate oneToMany relationships
     if (isset($element['oneToMany'])) {
         foreach ($element['oneToMany'] as $name => $oneToManyElement) {
             $mapping = array('fieldName' => $name, 'targetEntity' => $oneToManyElement['targetEntity'], 'mappedBy' => $oneToManyElement['mappedBy']);
             if (isset($oneToManyElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . $oneToManyElement['fetch']);
             }
             if (isset($oneToManyElement['cascade'])) {
                 $mapping['cascade'] = $oneToManyElement['cascade'];
             }
             if (isset($oneToManyElement['orphanRemoval'])) {
                 $mapping['orphanRemoval'] = (bool) $oneToManyElement['orphanRemoval'];
             }
             if (isset($oneToManyElement['orderBy'])) {
                 $mapping['orderBy'] = $oneToManyElement['orderBy'];
             }
             if (isset($oneToManyElement['indexBy'])) {
                 $mapping['indexBy'] = $oneToManyElement['indexBy'];
             }
             $metadata->mapOneToMany($mapping);
             // Evaluate second level cache
             if (isset($oneToManyElement['cache'])) {
                 $metadata->enableAssociationCache($mapping['fieldName'], $this->cacheToArray($oneToManyElement['cache']));
             }
         }
     }
     // Evaluate manyToOne relationships
     if (isset($element['manyToOne'])) {
         foreach ($element['manyToOne'] as $name => $manyToOneElement) {
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:67,代码来源:YamlDriver.php

示例2: loadMetadataForClass


//.........这里部分代码省略.........
             if (isset($associationIds[$mapping['fieldName']])) {
                 $mapping['id'] = true;
             }
             if (isset($oneToOneElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . (string) $oneToOneElement['fetch']);
             }
             if (isset($oneToOneElement['mapped-by'])) {
                 $mapping['mappedBy'] = (string) $oneToOneElement['mapped-by'];
             } else {
                 if (isset($oneToOneElement['inversed-by'])) {
                     $mapping['inversedBy'] = (string) $oneToOneElement['inversed-by'];
                 }
                 $joinColumns = array();
                 if (isset($oneToOneElement->{'join-column'})) {
                     $joinColumns[] = $this->joinColumnToArray($oneToOneElement->{'join-column'});
                 } else {
                     if (isset($oneToOneElement->{'join-columns'})) {
                         foreach ($oneToOneElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
                             $joinColumns[] = $this->joinColumnToArray($joinColumnElement);
                         }
                     }
                 }
                 $mapping['joinColumns'] = $joinColumns;
             }
             if (isset($oneToOneElement->cascade)) {
                 $mapping['cascade'] = $this->_getCascadeMappings($oneToOneElement->cascade);
             }
             if (isset($oneToOneElement['orphan-removal'])) {
                 $mapping['orphanRemoval'] = $this->evaluateBoolean($oneToOneElement['orphan-removal']);
             }
             $metadata->mapOneToOne($mapping);
             // Evaluate second level cache
             if (isset($oneToOneElement->cache)) {
                 $metadata->enableAssociationCache($mapping['fieldName'], $this->cacheToArray($oneToOneElement->cache));
             }
         }
     }
     // Evaluate <one-to-many ...> mappings
     if (isset($xmlRoot->{'one-to-many'})) {
         foreach ($xmlRoot->{'one-to-many'} as $oneToManyElement) {
             $mapping = array('fieldName' => (string) $oneToManyElement['field'], 'targetEntity' => (string) $oneToManyElement['target-entity'], 'mappedBy' => (string) $oneToManyElement['mapped-by']);
             if (isset($oneToManyElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . (string) $oneToManyElement['fetch']);
             }
             if (isset($oneToManyElement->cascade)) {
                 $mapping['cascade'] = $this->_getCascadeMappings($oneToManyElement->cascade);
             }
             if (isset($oneToManyElement['orphan-removal'])) {
                 $mapping['orphanRemoval'] = $this->evaluateBoolean($oneToManyElement['orphan-removal']);
             }
             if (isset($oneToManyElement->{'order-by'})) {
                 $orderBy = array();
                 foreach ($oneToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) {
                     $orderBy[(string) $orderByField['name']] = (string) $orderByField['direction'];
                 }
                 $mapping['orderBy'] = $orderBy;
             }
             if (isset($oneToManyElement['index-by'])) {
                 $mapping['indexBy'] = (string) $oneToManyElement['index-by'];
             } else {
                 if (isset($oneToManyElement->{'index-by'})) {
                     throw new \InvalidArgumentException("<index-by /> is not a valid tag");
                 }
             }
             $metadata->mapOneToMany($mapping);
             // Evaluate second level cache
开发者ID:Dren-x,项目名称:mobitnew,代码行数:67,代码来源:XmlDriver.php

示例3: loadMetadataForClass


//.........这里部分代码省略.........
                                 $joinTable = array('name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema);
                                 foreach ($joinTableAnnot->joinColumns as $joinColumn) {
                                     $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn);
                                 }
                                 foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) {
                                     $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumn);
                                 }
                             }
                             $mapping['joinTable'] = $joinTable;
                             $mapping['targetEntity'] = $manyToManyAnnot->targetEntity;
                             $mapping['mappedBy'] = $manyToManyAnnot->mappedBy;
                             $mapping['inversedBy'] = $manyToManyAnnot->inversedBy;
                             $mapping['cascade'] = $manyToManyAnnot->cascade;
                             $mapping['indexBy'] = $manyToManyAnnot->indexBy;
                             $mapping['orphanRemoval'] = $manyToManyAnnot->orphanRemoval;
                             $mapping['fetch'] = $this->getFetchMode($className, $manyToManyAnnot->fetch);
                             if ($orderByAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OrderBy')) {
                                 $mapping['orderBy'] = $orderByAnnot->value;
                             }
                             $metadata->mapManyToMany($mapping);
                         } else {
                             if ($embeddedAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Embedded')) {
                                 $mapping['class'] = $embeddedAnnot->class;
                                 $mapping['columnPrefix'] = $embeddedAnnot->columnPrefix;
                                 $metadata->mapEmbedded($mapping);
                             }
                         }
                     }
                 }
             }
         }
         // Evaluate @Cache annotation
         if (($cacheAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Cache')) !== null) {
             $metadata->enableAssociationCache($mapping['fieldName'], array('usage' => constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), 'region' => $cacheAnnot->region));
         }
     }
     // Evaluate AssociationOverrides annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\AssociationOverrides'])) {
         $associationOverridesAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\AssociationOverrides'];
         foreach ($associationOverridesAnnot->value as $associationOverride) {
             $override = array();
             $fieldName = $associationOverride->name;
             // Check for JoinColumn/JoinColumns annotations
             if ($associationOverride->joinColumns) {
                 $joinColumns = array();
                 foreach ($associationOverride->joinColumns as $joinColumn) {
                     $joinColumns[] = $this->joinColumnToArray($joinColumn);
                 }
                 $override['joinColumns'] = $joinColumns;
             }
             // Check for JoinTable annotations
             if ($associationOverride->joinTable) {
                 $joinTableAnnot = $associationOverride->joinTable;
                 $joinTable = array('name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema);
                 foreach ($joinTableAnnot->joinColumns as $joinColumn) {
                     $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn);
                 }
                 foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) {
                     $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumn);
                 }
                 $override['joinTable'] = $joinTable;
             }
             $metadata->setAssociationOverride($fieldName, $override);
         }
     }
     // Evaluate AttributeOverrides annotation
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:67,代码来源:AnnotationDriver.php

示例4: build

 /**
  * Execute the build process
  */
 public function build()
 {
     $this->metadata->enableAssociationCache($this->field, ['usage' => $this->getUsage(), 'region' => $this->getRegion()]);
 }
开发者ID:guiwoda,项目名称:fluent,代码行数:7,代码来源:AssociationCache.php


注:本文中的Doctrine\Common\Persistence\Mapping\ClassMetadata::enableAssociationCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。