/**
  * {@inheritdoc}
  */
 public function count()
 {
     if ($this->mapping['isInverseSide']) {
         $this->initialize();
     }
     return count($this->mongoData) + $this->coll->count();
 }
 function it_applies_choice_filter_on_datasource_for_collection_value(FilterDatasourceAdapterInterface $datasource, Collection $collection, $utility)
 {
     $collection->count()->willReturn(2);
     $collection->getValues()->willReturn(['foo', 'bar']);
     $utility->applyFilter($datasource, 'data_name_key', 'IN', ['foo', 'bar'])->shouldBeCalled();
     $this->apply($datasource, ['value' => $collection, 'type' => AjaxChoiceFilterType::TYPE_CONTAINS]);
 }
Esempio n. 3
0
 public function testCount()
 {
     $this->_coll[] = 'one';
     $this->_coll[] = 'two';
     $this->assertEquals($this->_coll->count(), 2);
     $this->assertEquals(count($this->_coll), 2);
 }
 /**
  * Resets previous photo collection
  *
  * @param Collection $collection
  */
 protected function clearPreviousCollection(Collection $collection)
 {
     if ($collection->count()) {
         foreach ($collection as $item) {
             $collection->removeElement($item);
         }
     }
 }
Esempio n. 5
0
 /**
  * @param User $user
  *
  * @return Conversation
  */
 public function addUser($user)
 {
     if ($this->users->count() >= self::LIMIT_USERS) {
         throw new \BadMethodCallException('Conversations are only composed of ' . self::LIMIT_USERS . ' users');
     }
     $this->users->add($user);
     return $this;
 }
 /**
  * Returns product statuses
  *
  * @param int    $limit
  * @param string $orderBy
  * @param string $orderDir
  *
  * @return array
  */
 public function getProductReviewAverage(Collection $collection)
 {
     $totalRating = 0;
     $reviewsTotal = $collection->count();
     $collection->map(function (ProductReviewInterface $review) use(&$totalRating) {
         $totalRating += $review->getRating();
     });
     return $reviewsTotal > 0 ? round($totalRating / $reviewsTotal, 2) : 0;
 }
 /**
  * {@inheritdoc}
  */
 public function count()
 {
     if ($this->mapping['isInverseSide'] && !$this->initialized) {
         $documentPersister = $this->uow->getDocumentPersister(get_class($this->owner));
         $count = empty($this->mapping['repositoryMethod']) ? $documentPersister->createReferenceManyInverseSideQuery($this)->count() : $documentPersister->createReferenceManyWithRepositoryMethodCursor($this)->count();
     } else {
         $count = $this->coll->count();
     }
     return count($this->mongoData) + $count;
 }
 /**
  * {@inheritdoc}
  */
 public function count()
 {
     $count = $this->coll->count();
     // If this collection is inversed and not initialized, add the count returned from the database
     if ($this->mapping['isInverseSide'] && !$this->initialized) {
         $documentPersister = $this->uow->getDocumentPersister(get_class($this->owner));
         $count += empty($this->mapping['repositoryMethod']) ? $documentPersister->createReferenceManyInverseSideQuery($this)->count() : $documentPersister->createReferenceManyWithRepositoryMethodCursor($this)->count();
     }
     return $count + ($this->initialized ? 0 : count($this->mongoData));
 }
 /**
  * Transforms an ArrayCollection of Level entities to a
  * multi-line string showing the level names.
  *
  * @param Collection $levels
  *
  * @return string
  */
 public function transform($levels)
 {
     $serialized = '';
     if (!$levels instanceof Collection || $levels->count() === 0) {
         return $serialized;
     }
     foreach ($levels as $level) {
         $serialized .= $level->getName() . "\n";
     }
     return $serialized;
 }
Esempio n. 10
0
 /**
  * Transforms a collection of recipients into a string
  *
  * @param Collection $recipients
  *
  * @return string
  */
 public function transform($recipients)
 {
     if ($recipients->count() == 0) {
         return "";
     }
     $usernames = array();
     foreach ($recipients as $recipient) {
         $usernames[] = $this->userToUsernameTransformer->transform($recipient);
     }
     return implode(', ', $usernames);
 }
Esempio n. 11
0
 /**
  * Is all document signatures are completed
  *
  * @return bool
  */
 public function isDocumentSignaturesCompleted()
 {
     if (!$this->documentSignatures->count()) {
         return false;
     }
     foreach ($this->getDocumentSignatures() as $signature) {
         if (!$signature->isCompleted()) {
             return false;
         }
     }
     return true;
 }
Esempio n. 12
0
 function it_stores_only_unique_values(Collection $internal)
 {
     $container = [];
     $internal->add(Argument::type('string'))->will(function ($argument) use(&$container) {
         $container[] = $argument;
     });
     $internal->count()->will(function () use(&$container) {
         return count($container);
     });
     $internal->contains(Argument::type('string'))->will(function ($argument) use(&$container) {
         return in_array($argument, $container, true);
     });
     $this->add('t');
     $this->add('t');
     $this->add('d');
     $this->count()->shouldBe(2);
 }
Esempio n. 13
0
 /**
  * {@inheritdoc}
  */
 public function getShippingUnitCount()
 {
     return $this->units->count();
 }
Esempio n. 14
0
 /**
  * {@inheritdoc}
  */
 public function getShippingItemCount()
 {
     return $this->items->count();
 }
Esempio n. 15
0
 /**
  * Tells if this product has variants.
  *
  * @return bool Product has variants
  */
 public function hasVariants()
 {
     return $this->variants->count() > 0;
 }
Esempio n. 16
0
 /**
  * @return bool
  */
 public function hasJournals()
 {
     $totalJournals = $this->journals->count();
     return $totalJournals > 0;
 }
Esempio n. 17
0
 /**
  * {@inheritdoc}
  */
 public function countItems()
 {
     return $this->items->count();
 }
Esempio n. 18
0
 public static function extractPage(Collection $collection, $from)
 {
     return ['from' => $from, 'entities' => $collection->slice($from, self::getEntitiesPerPage()), 'total_count' => $collection->count(), 'entities_per_page' => self::getEntitiesPerPage()];
 }
 /**
  * {@inheritDoc}
  */
 public function count()
 {
     $this->initialize();
     return $this->collection->count();
 }
Esempio n. 20
0
 /**
  * {@inheritdoc}
  */
 public function isEmpty()
 {
     return 0 === $this->products->count();
 }
 /**
  * @param Collection $collection
  * @return SimpleXMLElement
  */
 public function buildElement(Collection $collection)
 {
     $feed = $this->xmlBuilder->setVersion('1.0')->setEncoding('UTF-8')->setRoot('feed')->setNamespace('http://www.ixtens.com/xml/mp/offer/R1.1')->create();
     $data = array();
     for ($i = 0; $i < $collection->count(); $i++) {
         $product = $collection[$i];
         $currency = $product->getCurrency();
         $marketplace = $product->getMeta()->offsetGet('marketplace');
         // Build attributes
         $attributes = array();
         $attributeLists = array();
         if ($category = $product->getMeta()->offsetGet('category')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'CategoryID'), '_values' => $category);
         }
         if ($product instanceof VariationInterface) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'StyleCode'), '_values' => $product->getProduct()->getSku());
         }
         if ($title = $product->getTitle()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'SKU Name'), '_values' => $title);
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Title'), '_values' => $title);
         }
         if ($description = $product->getDescription()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Description'), '_values' => $description);
         }
         if ($brand = $product->getMeta()->offsetGet('brand')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Brand'), '_values' => $brand);
         }
         if ($upc = $product->getUpc()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'UPC'), '_values' => $upc);
         }
         if ($ean = $product->getEan()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'EAN'), '_values' => $ean);
         }
         if ($manufacturer = $product->getMeta()->offsetGet('manufacturer')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Manufacturer'), '_values' => $manufacturer);
         }
         if ($mpn = $product->getMpn()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'MfrPartNumber'), '_values' => $mpn);
         }
         if ($length = $product->getLength()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'SKU Length'), '_values' => $length);
         }
         if ($width = $product->getWidth()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'SKU Width'), '_values' => $width);
         }
         if ($height = $product->getHeight()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'SKU Height'), '_values' => $height);
         }
         if ($dimensionUnit = $product->getDimensionUnit()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'SKU Dimensional Unit of Measure'), '_values' => $dimensionUnit);
         }
         if ($weight = $product->getWeight()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'SKU Weight (Number)'), '_values' => $weight);
         }
         if ($weightUnit = $product->getWeightUnit()) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'SKU Weight Unit of Measure'), '_values' => $weightUnit);
         }
         if ($link = $product->getMeta()->offsetGet('link')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Item Link'), '_values' => $link);
         }
         if ($startDate = $product->getMeta()->offsetGet('startDate')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Reservation Date'), '_values' => $startDate);
         }
         if ($endDate = $product->getMeta()->offsetGet('endDate')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Reservation End Date'), '_values' => $endDate);
         }
         if ($shipper = $product->getMeta()->offsetGet('shipper')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Shipper Responsibility'), '_values' => $shipper);
         }
         if ($size = $product->getMeta()->offsetGet('size')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Size'), '_values' => $size);
             $attributeLists[] = array('_name' => 'attributeList', '_attributes' => array('name' => 'VariationTheme'), '_values' => 'Size');
         }
         if ($color = $product->getMeta()->offsetGet('color')) {
             $attributes[] = array('_name' => 'attribute', '_attributes' => array('name' => 'Color'), '_values' => $color);
             $attributeLists[] = array('_name' => 'attributeList', '_attributes' => array('name' => 'VariationTheme'), '_values' => 'Color');
         }
         $this->addCategorySpecificAttributes($attributes);
         // Start building XML feed
         // First three elements are <SKU>, <stateMachineEvent> and <attributes>
         $values = array(array('_name' => 'SKU', '_values' => $product->getSku()), array('_name' => 'stateMachineEvent', '_values' => $product->getStatus()), array('_name' => 'attributes', '_values' => $attributes));
         if (count($attributeLists) > 0) {
             $values[] = array('_name' => 'attributeLists', '_values' => $attributeLists);
         }
         // Next element is <images>
         $images = $product->getImages();
         if ($images->count() > 0) {
             $imageValues = array();
             $imageType = 'Main';
             $imageCount = 0;
             foreach ($images as $image) {
                 $imageValues[] = array('_name' => 'image', '_attributes' => array('type' => $imageType), '_values' => $image->getSource());
                 $imageCount++;
                 $imageType = 'PT' . $imageCount;
             }
             $values[] = array('_name' => 'images', '_images' => array('type' => 'Main'), '_values' => $imageValues);
         }
         // Prices and fees each get their own element, ex <MSRP> 1.99 </MSRP>
         if ($msrp = $product->getMsrp()) {
             $formattedPrice = $this->formatPrice($msrp, $currency);
             $priceValues = array(array('_name' => 'price', '_values' => $formattedPrice));
             $values[] = array('_name' => 'MSRP', '_attributes' => array('currency' => strtoupper($currency)), '_values' => $priceValues);
         }
         if ($strikeThroughPrice = $product->getMeta()->offsetGet('strikeThroughPrice')) {
             $formattedPrice = $this->formatPrice($strikeThroughPrice, $currency);
             $priceValues = array(array('_name' => 'price', '_values' => $formattedPrice));
             $values[] = array('_name' => 'strikethroughPrice', '_attributes' => array('currency' => strtoupper($currency)), '_values' => $priceValues);
         }
         if ($price = $product->getPrice()) {
             $formattedPrice = $this->formatPrice($price, $currency);
             $priceValues = array(array('_name' => 'price', '_values' => $formattedPrice));
             $values[] = array('_name' => 'listPrice', '_attributes' => array('currency' => strtoupper($currency)), '_values' => $priceValues);
         }
         if ($basicCost = $product->getMeta()->offsetGet('basicCost')) {
             $formattedPrice = $this->formatPrice($basicCost, $currency);
             $priceValues = array(array('_name' => 'price', '_values' => $formattedPrice));
             $values[] = array('_name' => 'basicCost', '_attributes' => array('currency' => strtoupper($currency)), '_values' => $priceValues);
         }
         if ($mapPrice = $product->getMeta()->offsetGet('mapPrice')) {
             $formattedPrice = $this->formatPrice($mapPrice, $currency);
             $priceValues = array(array('_name' => 'price', '_values' => $formattedPrice));
             $mapAttributes = array('currency' => strtoupper($currency));
             if ($marketplace) {
                 $mapAttributes['marketplaceID'] = $marketplace;
             }
             $values[] = array('_name' => 'MAPPrice', '_attributes' => $mapAttributes, '_values' => $priceValues);
         }
         if ($dropshipFee = $product->getMeta()->offsetGet('dropshipFee')) {
             $formattedPrice = $this->formatPrice($dropshipFee, $currency);
             $priceValues = array(array('_name' => 'price', '_values' => $formattedPrice));
             $dropshipAttributes = array('currency' => strtoupper($currency));
             if ($marketplace) {
                 $dropshipAttributes['marketplaceID'] = $marketplace;
             }
             $values[] = array('_name' => 'dropshipFee', '_attributes' => $dropshipAttributes, '_values' => $priceValues);
         }
         // Quantity gets its own element, ex. <Quantity>100</Quantity>
         if ($quantity = $product->getQuantity()) {
             $inventoryValues = array(array('_name' => 'quantity', '_values' => $quantity));
             if ($fulfillmentLatency = $product->getMeta()->offsetGet('fulfillmentLatency')) {
                 $inventoryValues[] = array('_name' => 'inventoryAttribute', '_attributes' => array('name' => 'FulfillmentLatency'), '_values' => $fulfillmentLatency);
             }
             $values[] = array('_name' => 'inventory', '_values' => $inventoryValues);
         }
         // Having build all these additional elements (images, prices, quantity) add them.
         $productData = array('_name' => 'product', '_values' => $values);
         $data[$i] = $productData;
     }
     $this->xmlBuilder->add($feed, $data);
     return $feed;
 }
 public static function extractCommentsPage(Collection $comments, $from)
 {
     return ['from' => $from, 'entities' => $comments->slice($from, AbstractCommentRepository::COMMENTS_PER_PAGE), 'total_count' => $comments->count(), 'entities_per_page' => self::COMMENTS_PER_PAGE];
 }
 /**
  * {@inheritdoc}
  */
 public function count()
 {
     $this->_initialize();
     return $this->_coll->count();
 }
 /**
  * {@inheritdoc}
  */
 public function count()
 {
     if (!$this->initialized && $this->association['fetch'] == Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY) {
         return $this->em->getUnitOfWork()->getCollectionPersister($this->association)->count($this) + ($this->isDirty ? $this->coll->count() : 0);
     }
     $this->initialize();
     return $this->coll->count();
 }
Esempio n. 25
0
 /**
  * Has systemAccounts
  *
  * @return bool
  */
 public function hasSystemAccounts()
 {
     return $this->systemAccounts->count() > 0;
 }
Esempio n. 26
0
 /**
  * @return \Doctrine\Common\Collections\Collection
  */
 public function getInheritedStateLicense()
 {
     if ($this->state_license->count() == 0) {
         $this->getInheritedCollection('state_license', $this->site->getParentSite());
     }
     return $this->state_license;
 }
Esempio n. 27
0
 /**
  * @override
  */
 public function count()
 {
     if (!$this->_initialized) {
         //TODO: Initialize
     }
     return parent::count();
 }
Esempio n. 28
0
 public function countSystems()
 {
     return $this->systems->count();
 }
Esempio n. 29
0
 /**
  * @return bool
  */
 public function isSimple()
 {
     return 1 === $this->variants->count() && !$this->hasOptions();
 }
 /**
  * @param \Sudoux\EagleBundle\Entity\EagleBorrower $borrower
  * @author Eric Haynes
  */
 public function removeIncomeMonthlyByBorrower(\Sudoux\EagleBundle\Entity\EagleBorrower $borrower)
 {
     if ($this->income_monthly->count() > 0) {
         foreach ($this->income_monthly as $income) {
             if ($income->getBorrower()->getId() == $borrower->getId()) {
                 $this->removeIncomeMonthly($income);
             }
         }
     }
 }