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


PHP Finder::addOrderCol方法代码示例

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


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

示例1: importEntities

 private function importEntities()
 {
     $file = Singleton::create("DOMXmlFactory")->fromFile("config/service.xml");
     $root = $file->getRootElement();
     $entityEls = $root->getChildren("entity");
     $this->entities = array();
     foreach ($entityEls as $entityEl) {
         $name = $entityEl->getAttribute("name");
         $table = $entityEl->getAttribute("table");
         $entity = new Entity($name, $table);
         // Insert properties
         foreach ($entityEl->getChildren("column") as $property) {
             $propertyName = $property->getAttribute("name");
             $type = $property->getAttribute("type");
             $size = $property->getAttribute("size");
             $entityName = $property->getAttribute("entity");
             $mappingTable = $property->getAttribute("mapping-table");
             $primary = $property->getAttribute("primary") == "true";
             $autoIncrement = $property->getAttribute("auto-increment") == "true";
             if ($primary) {
                 $entity->addPKProperty(new PrimaryKeyProperty($propertyName, $type, $size, $autoIncrement));
             } elseif ($type == "Object") {
                 $entity->addOneToOneProperty(new OneToOneProperty($propertyName, $entityName));
             } elseif ($type == "Collection" && !$mappingTable) {
                 $entity->addOneManyProperty(new OneToManyProperty($propertyName, $entityName));
             } elseif ($mappingTable) {
                 $entity->addManyToManyProperty(new ManyToManyProperty($propertyName, $entityName, $mappingTable));
             } else {
                 $entity->addProperty(new Property($propertyName, $type, $size));
             }
         }
         // Insert finders
         foreach ($entityEl->getChildren("finder") as $finderEl) {
             $finderName = $finderEl->getAttribute("name");
             $unique = $finderEl->getAttribute("unique");
             $cacheable = $finderEl->getAttribute("cacheable");
             $unique = $unique === "true";
             $cacheable = !($cacheable === "false");
             $finder = new Finder($entity, $finderName, $unique, $cacheable);
             foreach ($finderEl->getChildren("finder-column") as $fcEl) {
                 $name = $fcEl->getAttribute("name");
                 $comparator = $fcEl->getAttribute("comparator");
                 if (empty($comparator)) {
                     $comparator = "=";
                 }
                 $finder->addFinderColumn(new FinderColumn($name, $comparator));
             }
             $orderEls = $finderEl->getChildren("order");
             if ($orderEls->size() > 1) {
                 throw new ServiceBuilderException("Multiple order elements defined for finder {$finderName}");
             }
             if ($orderEls->size() == 1) {
                 $orderEl = $orderEls->getFirst();
                 foreach ($orderEl->getChildren("order-column") as $ocEl) {
                     $ocName = $ocEl->getAttribute("name");
                     $ocOrderBy = $ocEl->getAttribute("order-by");
                     $finder->addOrderCol(new OrderColumn($ocName, $ocOrderBy));
                 }
             }
             $entity->addFinder($finder);
         }
         // Insert order
         $orderEls = $entityEl->getChildren("order");
         if ($orderEls->size() > 1) {
             throw new ServiceBuilderException("Multiple order elements defined for entity {$entity->getName()}");
         }
         if ($orderEls->size() == 1) {
             $orderEl = $orderEls->get(0);
             foreach ($orderEl->getChildren("order-column") as $ocEl) {
                 $ocName = $ocEl->getAttribute("name");
                 $ocOrderBy = $ocEl->getAttribute("order-by");
                 $entity->addOrderCol(new OrderColumn($ocName, $ocOrderBy));
             }
         }
         $entity->validate();
         // Add entity
         $this->entities[$entity->getName()] = $entity;
     }
 }
开发者ID:aeberh,项目名称:php-movico,代码行数:79,代码来源:ServiceBuilder.php


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