當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。