當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PersistentCollection::count方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\PersistentCollection::count方法的典型用法代碼示例。如果您正苦於以下問題:PHP PersistentCollection::count方法的具體用法?PHP PersistentCollection::count怎麽用?PHP PersistentCollection::count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\PersistentCollection的用法示例。


在下文中一共展示了PersistentCollection::count方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getValidUserApi

 /**
  * Get valid UserApi for given token
  *
  * @param TokenInterface       $token
  * @param PersistentCollection $secrets
  * @param User                 $user
  *
  * @return bool|UserApi
  */
 protected function getValidUserApi(TokenInterface $token, PersistentCollection $secrets, User $user)
 {
     $currentIteration = 0;
     $nonce = $token->getAttribute('nonce');
     $secretsCount = $secrets->count();
     /** @var UserApi $userApi */
     foreach ($secrets as $userApi) {
         $currentIteration++;
         $isSecretValid = $this->validateDigest($token->getAttribute('digest'), $nonce, $token->getAttribute('created'), $userApi->getApiKey(), $this->getSalt($user));
         if ($isSecretValid && !$userApi->getUser()->getOrganizations()->contains($userApi->getOrganization())) {
             throw new BadCredentialsException('Wrong API key.');
         }
         if ($isSecretValid && !$userApi->getOrganization()->isEnabled()) {
             throw new BadCredentialsException('Organization is not active.');
         }
         // delete nonce from cache because user have another api keys
         if (!$isSecretValid && $secretsCount !== $currentIteration) {
             $this->getNonceCache()->delete($nonce);
         }
         if ($isSecretValid) {
             return $userApi;
         }
     }
     return false;
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:34,代碼來源:WsseAuthProvider.php

示例2: clearPreviousCollection

 /**
  * Resets previous photo collection
  *
  * @param PersistentCollection $collection
  */
 protected function clearPreviousCollection(PersistentCollection $collection)
 {
     if ($collection->count()) {
         foreach ($collection as $item) {
             $collection->removeElement($item);
         }
     }
 }
開發者ID:raizeta,項目名稱:WellCommerce,代碼行數:13,代碼來源:ProductPhotoCollectionToArrayTransformer.php

示例3: numberComputersAndNumberEnabled

 public function numberComputersAndNumberEnabled(PersistentCollection $computers)
 {
     $nbComputersEnabled = 0;
     foreach ($computers as $computer) {
         if ($computer->isEnabled()) {
             $nbComputersEnabled++;
         }
     }
     return sprintf("%d computers (%d enabled)", $computers->count(), $nbComputersEnabled);
 }
開發者ID:GegrLmtte,項目名稱:Formation-Symfony,代碼行數:10,代碼來源:ComputerExtension.php

示例4: validateCount

 /**
  * Check that number of categories not less than minimum defined number.
  *
  * @param PersistentCollection $value
  * @param CategoriesConstraint $constraint
  * @return bool
  */
 protected function validateCount(PersistentCollection $value, CategoriesConstraint $constraint)
 {
     if ($value->count() >= self::MIN_CATEGORIES_COUNT) {
         return true;
     }
     $this->context->addViolationAt($constraint->getType(), $constraint->countMessage, ['%count%' => self::MIN_CATEGORIES_COUNT]);
     return false;
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:15,代碼來源:CategoriesValidator.php

示例5: hasChildren

 /**
  * (PHP 5 &gt;= 5.1.0)<br/>
  * Returns if an iterator can be created for the current entry.
  * @link http://php.net/manual/en/recursiveiterator.haschildren.php
  * @return bool true if the current entry can be iterated over, otherwise returns false.
  */
 public function hasChildren()
 {
     return $this->children->count() > 0;
 }
開發者ID:saoke,項目名稱:RbacUserDoctrineOrm,代碼行數:10,代碼來源:Role.php


注:本文中的Doctrine\ORM\PersistentCollection::count方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。