当前位置: 首页>>代码示例>>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;未经允许,请勿转载。