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


PHP Collection::matching方法代码示例

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


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

示例1: sort

 /**
  * Sort existing value collection utility.
  *
  * @param Collection $values
  * @param string $sortKey
  * @return Collection
  */
 public static function sort(Collection $values, $sortKey)
 {
     $criteria = new Criteria();
     switch ($sortKey) {
         case self::BY_ALPHA_ASC:
             $criteria->orderBy(array('value' => Criteria::ASC));
             break;
         case self::BY_ALPHA_DESC:
             $criteria->orderBy(array('value' => Criteria::DESC));
             break;
         case self::BY_ID_ASC:
             $criteria->orderBy(array('id' => Criteria::ASC));
             break;
         case self::BY_ID_DESC:
             $criteria->orderBy(array('id' => Criteria::DESC));
             break;
         case self::BY_NUMBER:
         default:
             $criteria->orderBy(array('order' => Criteria::ASC));
             break;
     }
     return $values->matching($criteria);
 }
开发者ID:upenn-dag,项目名称:dag-framework,代码行数:30,代码来源:OptionOrder.php

示例2: findData

 /**
  * Finds a data entity
  *
  * @param string $key
  *
  * @return object|null
  */
 protected function findData($key)
 {
     $criteria = Criteria::create()->where(Criteria::expr()->eq('key', $key));
     $result = $this->data->matching($criteria);
     if (is_array($result)) {
         $result = reset($result);
         return $result;
     }
 }
开发者ID:indigophp,项目名称:doctrine-extensions,代码行数:16,代码来源:Entity.php

示例3: testMatchingSlice

 /**
  * @group DDC-1637
  */
 public function testMatchingSlice()
 {
     $this->fillMatchingFixture();
     $col = $this->_coll->matching(new Criteria(null, null, 1, 1));
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $col);
     $this->assertNotSame($col, $this->_coll);
     $this->assertEquals(1, count($col));
     $this->assertEquals('baz', $col[0]->foo);
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:12,代码来源:CollectionTest.php

示例4: getFilteredCollection

 /**
  * @return Collection
  */
 private function getFilteredCollection()
 {
     return $this->data_source->matching($this->criteria);
 }
开发者ID:ublaboo,项目名称:datagrid,代码行数:7,代码来源:DoctrineCollectionDataSource.php

示例5: getPriceListCurrencyByCode

 /**
  * @param string $currency
  * @return PriceListCurrency
  */
 public function getPriceListCurrencyByCode($currency)
 {
     $criteria = Criteria::create()->where(Criteria::expr()->eq('currency', $currency));
     return $this->currencies->matching($criteria)->first();
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:9,代码来源:PriceList.php

示例6: matching

 /**
  * Selects all elements from a selectable that match the expression and
  * return a new collection containing these elements.
  *
  * @param \Doctrine\Common\Collections\Criteria $criteria
  *
  * @return Collection
  *
  * @throws \RuntimeException
  */
 public function matching(Criteria $criteria)
 {
     if ($this->isDirty) {
         $this->initialize();
     }
     if ($this->initialized) {
         return $this->coll->matching($criteria);
     }
     if ($this->association['type'] === ClassMetadata::MANY_TO_MANY) {
         $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association);
         return new ArrayCollection($persister->loadCriteria($this, $criteria));
     }
     $builder = Criteria::expr();
     $ownerExpression = $builder->eq($this->backRefFieldName, $this->owner);
     $expression = $criteria->getWhereExpression();
     $expression = $expression ? $builder->andX($expression, $ownerExpression) : $ownerExpression;
     $criteria->where($expression);
     $persister = $this->em->getUnitOfWork()->getEntityPersister($this->association['targetEntity']);
     return $this->association['fetch'] === ClassMetadataInfo::FETCH_EXTRA_LAZY ? new LazyCriteriaCollection($persister, $criteria) : new ArrayCollection($persister->loadCriteria($criteria));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:30,代码来源:PersistentCollection.php

示例7: matching

 /**
  * Select all elements from a selectable that match the expression and
  * return a new collection containing these elements.
  *
  * @param \Doctrine\Common\Collections\Criteria $criteria
  * @return Collection
  */
 public function matching(Criteria $criteria)
 {
     if ($this->isDirty) {
         $this->initialize();
     }
     if ($this->initialized) {
         return $this->coll->matching($criteria);
     }
     if ($this->association['type'] !== ClassMetadata::ONE_TO_MANY) {
         throw new \RuntimeException("Matching Criteria on PersistentCollection only works on OneToMany assocations at the moment.");
     }
     $id = $this->em->getClassMetadata(get_class($this->owner))->getSingleIdReflectionProperty()->getValue($this->owner);
     $builder = Criteria::expr();
     $ownerExpression = $builder->eq($this->backRefFieldName, $id);
     $expression = $criteria->getWhereExpression();
     $expression = $expression ? $builder->andX($expression, $ownerExpression) : $ownerExpression;
     $criteria->where($expression);
     $persister = $this->em->getUnitOfWork()->getEntityPersister($this->association['targetEntity']);
     return new ArrayCollection($persister->loadCriteria($criteria));
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:27,代码来源:PersistentCollection.php

示例8: hasPermission

 /**
  * {@inheritDoc}
  */
 public function hasPermission($permission)
 {
     $criteria = Criteria::create()->where(Criteria::expr()->eq('name', (string) $permission));
     $result = $this->permissions->matching($criteria);
     return count($result) > 0;
 }
开发者ID:PrimeAltis,项目名称:armasquads,代码行数:9,代码来源:Role.php

示例9: getParameters

 /**
  * @return ParameterInterface[]
  */
 public function getParameters()
 {
     return $this->parameters->matching(Criteria::create()->where(Criteria::expr()->isNull('parent')));
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:7,代码来源:Page.php

示例10: getProductsCountChecked

 public function getProductsCountChecked()
 {
     $criteria = Criteria::create();
     $criteria->where(Criteria::expr()->eq('checked', true));
     return $this->products->matching($criteria)->count();
 }
开发者ID:Hley,项目名称:SupplierCheck,代码行数:6,代码来源:Campaign.php

示例11: getActiveChildren

 /**
  * @return Collection
  */
 public function getActiveChildren()
 {
     $criteria = Criteria::create()->where(Criteria::expr()->eq("isActive", true));
     $result = $this->children->matching($criteria);
     return $result;
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:9,代码来源:Department.php

示例12: getAcceptedReviews

 /**
  * {@inheritdoc}
  */
 public function getAcceptedReviews()
 {
     $criteria = Criteria::create()->where(Criteria::expr()->eq('status', ReviewInterface::STATUS_ACCEPTED));
     return $this->reviews->matching($criteria);
 }
开发者ID:sylius,项目名称:sylius,代码行数:8,代码来源:Product.php

示例13: getLatestActivities

 public function getLatestActivities($type = Activity::ACTIVITY_TYPE_COMMIT)
 {
     if (!in_array($type, array(Activity::ACTIVITY_TYPE_COMMIT, Activity::ACTIVITY_TYPE_RECOMMEND, Activity::ACTIVITY_TYPE_TRAVIS_BUILD))) {
         throw new \InvalidArgumentException();
     }
     $criteria = Criteria::create()->where(Criteria::expr()->eq('type', $type))->orderBy(array("createdAt" => "DESC"))->setFirstResult(0)->setMaxResults(30);
     return $this->activities->matching($criteria);
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:8,代码来源:Bundle.php

示例14: getCurrentRegistrationStatus

 /**
  * 
  * @return RegistrationStatus
  */
 public function getCurrentRegistrationStatus()
 {
     $criteria = Criteria::create()->where(Criteria::expr()->eq("isCurrent", true))->setMaxResults(1);
     $result = $this->registrationStatus->matching($criteria);
     return $result->toArray()[0];
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:10,代码来源:Registration.php

示例15: getEpisodes

 /**
  * @return Episode[]
  */
 public function getEpisodes()
 {
     $criteria = Criteria::create();
     $criteria->orderBy(['number' => Criteria::ASC]);
     return $this->episodes->matching($criteria)->toArray();
 }
开发者ID:legendik,项目名称:DwarfSearch,代码行数:9,代码来源:Season.php


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