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


PHP ArrayCollection::getIterator方法代碼示例

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


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

示例1: getWidgets

 /**
  * Get widgets
  *
  * @return \Doctrine\Common\Collections\ArrayCollection
  */
 public function getWidgets()
 {
     // we order by position value.
     $iterator = $this->widgets->getIterator();
     $iterator->uasort(function ($first, $second) {
         if ($first === $second) {
             return 0;
         }
         return (int) $first->getPosition() < (int) $second->getPosition() ? -1 : 1;
     });
     $this->widgets = new \Doctrine\Common\Collections\ArrayCollection(iterator_to_array($iterator));
     return $this->widgets;
 }
開發者ID:pigroupe,項目名稱:SfynxCmfBundle,代碼行數:18,代碼來源:Block.php

示例2: sortCollection

 protected function sortCollection()
 {
     $iterator = $this->collection->getIterator();
     $iterator->uasort(function (ShippingMethodCostInterface $a, ShippingMethodCostInterface $b) {
         return $a->getCost()->getGrossAmount() < $b->getCost()->getGrossAmount() ? -1 : 1;
     });
     return new ArrayCollection(iterator_to_array($iterator));
 }
開發者ID:raizeta,項目名稱:WellCommerce,代碼行數:8,代碼來源:ProductShippingMethodProvider.php

示例3: createComponent

 public function createComponent($pres, $name)
 {
     $c = new PublicMenuControl($pres, $name, $this->sportGroupService, $this->sportTypeService);
     $iterator = $this->items->getIterator();
     $iterator->uasort(function ($a, $b) {
         return $a->getLabel() < $b->getLabel() ? -1 : 1;
     });
     $this->items = new ArrayCollection(iterator_to_array($iterator));
     $c->setBrands($this->items);
     $c->setTreeData($this->getTreeData());
     return $c;
 }
開發者ID:fuca,項目名稱:sportsclub,代碼行數:12,代碼來源:PublicMenuControlFactory.php

示例4: use

 function it_normalizes_the_properties_of_the_product($filter, $serializer, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value, FamilyInterface $family, ArrayCollection $values, \ArrayIterator $iterator, ProductValueInterface $identifier)
 {
     $values->getIterator()->willReturn($iterator);
     $family->getCode()->willReturn('my_family');
     $product->getFamily()->willReturn($family);
     $product->getGroupCodes()->willReturn([]);
     $product->getVariantGroup()->willReturn(null);
     $product->getCategoryCodes()->willReturn([]);
     $product->isEnabled()->willReturn(true);
     $value->getAttribute()->willReturn($attribute);
     $attribute->getCode()->willReturn('name');
     $product->getIdentifier()->willReturn($identifier);
     $identifier->getData()->willReturn('my_code');
     $product->getValues()->willReturn($values);
     $filter->filterCollection($values, 'pim.transform.product_value.structured', Argument::type('array'))->shouldBeCalled()->willReturn($values);
     $iterator->rewind()->willReturn(null);
     $valueCount = 1;
     $iterator->valid()->will(function () use(&$valueCount) {
         return $valueCount-- > 0;
     });
     $iterator->current()->willReturn($value);
     $iterator->next()->willReturn(null);
     $context = ['filter_types' => ['pim.transform.product_value.structured']];
     $serializer->normalize($value, 'standard', $context)->willReturn(['locale' => null, 'scope' => null, 'value' => 'foo']);
     $created = new \DateTime('2010-06-23');
     $product->getCreated()->willReturn($created);
     $serializer->normalize($created, 'standard')->willReturn('2010-06-23T00:00:00+01:00');
     $updated = new \DateTime('2010-06-23 23:00:00');
     $product->getUpdated()->willReturn($updated);
     $serializer->normalize($updated, 'standard')->willReturn('2010-06-23T23:00:00+01:00');
     $this->normalize($product, 'standard', $context)->shouldReturn(['identifier' => 'my_code', 'family' => 'my_family', 'groups' => [], 'variant_group' => null, 'categories' => [], 'enabled' => true, 'values' => ['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]], 'created' => '2010-06-23T00:00:00+01:00', 'updated' => '2010-06-23T23:00:00+01:00']);
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:32,代碼來源:PropertiesNormalizerSpec.php

示例5: use

 function it_normalizes_groups($normalizer, $structureVersionProvider, $versionManager, $versionNormalizer, $localizedConverter, GroupInterface $tshirt, GroupTypeInterface $groupType, Version $oldestLog, Version $newestLog, ArrayCollection $products, ProductInterface $product, \ArrayIterator $productsIterator)
 {
     $options = ['decimal_separator' => ',', 'date_format' => 'dd/MM/yyyy'];
     $tshirt->getType()->willReturn($groupType);
     $groupType->isVariant()->willReturn(true);
     $variantNormalized = ['code' => 'my_variant', 'axis' => ['color', 'size'], 'type' => 'variant', 'values' => ['number' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'metric' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'prices' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'date' => ['data' => '2015-01-31', 'locale' => null, 'scope' => null]]];
     $valuesLocalized = ['number' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'metric' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'prices' => ['data' => '12,50', 'locale' => null, 'scope' => null], 'date' => ['data' => '31/01/2015', 'locale' => null, 'scope' => null]];
     $normalizer->normalize($tshirt, 'json', $options)->willReturn($variantNormalized);
     $localizedConverter->convertToLocalizedFormats($variantNormalized['values'], $options)->willReturn($valuesLocalized);
     $structureVersionProvider->getStructureVersion()->willReturn(1);
     $versionManager->getOldestLogEntry($tshirt)->willReturn($oldestLog);
     $versionManager->getNewestLogEntry($tshirt)->willReturn($newestLog);
     $versionNormalizer->normalize($oldestLog, 'internal_api')->willReturn('normalized_oldest_log');
     $versionNormalizer->normalize($newestLog, 'internal_api')->willReturn('normalized_newest_log');
     $products->getIterator()->willReturn($productsIterator);
     $productsIterator->rewind()->shouldBeCalled();
     $productsCount = 1;
     $productsIterator->valid()->will(function () use(&$productsCount) {
         return $productsCount-- > 0;
     });
     $productsIterator->next()->shouldBeCalled();
     $productsIterator->current()->will(new ReturnPromise([$product]));
     $product->getId()->willReturn(42);
     $tshirt->getId()->willReturn(12);
     $tshirt->getProducts()->willReturn($products);
     $this->normalize($tshirt, 'internal_api', $options)->shouldReturn(['code' => 'my_variant', 'axis' => ['color', 'size'], 'type' => 'variant', 'values' => $valuesLocalized, 'products' => [42], 'meta' => ['id' => 12, 'form' => 'pim-variant-group-edit-form', 'structure_version' => 1, 'model_type' => 'variant_group', 'created' => 'normalized_oldest_log', 'updated' => 'normalized_newest_log']]);
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:27,代碼來源:GroupNormalizerSpec.php

示例6: getIterator

 public function getIterator()
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->getIterator();
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:7,代碼來源:AggregateEntryCollection.php

示例7: use

 function it_allows_to_get_errors_if_the_copy_went_wrong($mediaFetcher, $filesystemProvider, $fileExporterPath, FileInfoInterface $fileInfo, FileInfoInterface $fileInfo2, ArrayCollection $productValuesCollection, \ArrayIterator $valuesIterator, ProductValueInterface $productValue, ProductValueInterface $productValue2, AttributeInterface $attribute, FilesystemInterface $filesystem)
 {
     $fileInfo->getStorage()->willReturn('storageAlias');
     $fileInfo->getKey()->willReturn('a/b/c/d/product.jpg');
     $fileInfo->getOriginalFilename()->willReturn('my product.jpg');
     $fileInfo2->getStorage()->willReturn('storageAlias');
     $fileInfo2->getKey()->willReturn('wrong-path.jpg');
     $fileInfo2->getOriginalFilename()->willReturn('my-second-media.jpg');
     $productValue->getAttribute()->willReturn($attribute);
     $productValue->getMedia()->willReturn($fileInfo);
     $productValue->getLocale()->willReturn('en_US');
     $productValue->getScope()->willReturn(null);
     $productValue2->getAttribute()->willReturn($attribute);
     $productValue2->getMedia()->willReturn($fileInfo2);
     $productValue2->getLocale()->willReturn('fr_FR');
     $productValue2->getScope()->willReturn('ecommerce');
     $attribute->getAttributeType()->willReturn('pim_catalog_image');
     $attribute->getCode()->willReturn('my_picture');
     $productValuesCollection->getIterator()->willReturn($valuesIterator);
     $valuesIterator->rewind()->shouldBeCalled();
     $valuesCount = 2;
     $valuesIterator->valid()->will(function () use(&$valuesCount) {
         return $valuesCount-- > 0;
     });
     $valuesIterator->next()->shouldBeCalled();
     $valuesIterator->current()->will(new ReturnPromise([$productValue, $productValue2]));
     $filesystemProvider->getFilesystem('storageAlias')->willReturn($filesystem);
     $mediaFetcher->fetch($filesystem, 'a/b/c/d/product.jpg', ['filePath' => $this->directory . 'files/the_sku/my_picture/en_US/', 'filename' => 'my product.jpg'])->willThrow(new FileTransferException());
     $fileExporterPath->generate(['locale' => 'en_US', 'scope' => null], ['identifier' => 'the_sku', 'code' => 'my_picture'])->willReturn('files/the_sku/my_picture/en_US/');
     $mediaFetcher->fetch($filesystem, 'wrong-path.jpg', ['filePath' => $this->directory . 'files/the_sku/my_picture/fr_FR/ecommerce/', 'filename' => 'my-second-media.jpg'])->willThrow(new \LogicException('Something went wrong.'));
     $fileExporterPath->generate(['locale' => 'fr_FR', 'scope' => 'ecommerce'], ['identifier' => 'the_sku', 'code' => 'my_picture'])->willReturn('files/the_sku/my_picture/fr_FR/ecommerce/');
     $this->fetchAll($productValuesCollection, $this->directory, 'the_sku');
     $this->getErrors()->shouldBeEqualTo([['message' => 'The media has not been found or is not currently available', 'media' => ['from' => 'a/b/c/d/product.jpg', 'to' => ['filePath' => $this->directory . 'files/the_sku/my_picture/en_US/', 'filename' => 'my product.jpg'], 'storage' => 'storageAlias']], ['message' => 'The media has not been copied. Something went wrong.', 'media' => ['from' => 'wrong-path.jpg', 'to' => ['filePath' => $this->directory . 'files/the_sku/my_picture/fr_FR/ecommerce/', 'filename' => 'my-second-media.jpg'], 'storage' => 'storageAlias']]]);
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:34,代碼來源:BulkMediaFetcherSpec.php

示例8: getGroups

 /**
  * @return array
  */
 public function getGroups()
 {
     $groups = [];
     /** @var AbstractGroup $group */
     foreach ($this->groups->getIterator() as $group) {
         if ($group->isActive()) {
             $groups[] = $group;
         }
     }
     return $groups;
 }
開發者ID:ampisoft,項目名稱:user-bundle,代碼行數:14,代碼來源:AbstractUser.php

示例9: use

 function it_normalizes_the_values_of_product(AbstractProduct $product, AbstractAttribute $attribute, ProductValueInterface $value, ArrayCollection $values, \ArrayIterator $iterator, $filter, $serializer)
 {
     $values->getIterator()->willReturn($iterator);
     $product->getAssociations()->willReturn([]);
     $product->getFamily()->willReturn(null);
     $product->getGroupCodes()->willReturn([]);
     $product->getCategoryCodes()->willReturn([]);
     $product->isEnabled()->willReturn(true);
     $value->getAttribute()->willReturn($attribute);
     $attribute->getCode()->willReturn('name');
     $product->getValues()->willReturn($values);
     $filter->filter($values, Argument::any())->shouldBeCalled()->willReturn($values);
     $iterator->rewind()->willReturn(null);
     $valueCount = 1;
     $iterator->valid()->will(function () use(&$valueCount) {
         return $valueCount-- > 0;
     });
     $iterator->current()->willReturn($value);
     $iterator->next()->willReturn(null);
     $serializer->normalize($value, 'json', Argument::any())->willReturn(['locale' => null, 'scope' => null, 'value' => 'foo']);
     $this->normalize($product, 'json')->shouldReturn(['family' => null, 'groups' => [], 'categories' => [], 'enabled' => true, 'associations' => [], 'values' => ['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]]]);
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:22,代碼來源:ProductNormalizerSpec.php

示例10: use

 function it_normalizes_the_properties_of_the_product(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value, ArrayCollection $values, \ArrayIterator $iterator, $filter, $normalizer)
 {
     $values->getIterator()->willReturn($iterator);
     $product->getFamily()->willReturn(null);
     $product->getGroupCodes()->willReturn([]);
     $product->getVariantGroup()->willReturn(null);
     $product->getCategoryCodes()->willReturn([]);
     $product->isEnabled()->willReturn(true);
     $value->getAttribute()->willReturn($attribute);
     $attribute->getCode()->willReturn('name');
     $product->getValues()->willReturn($values);
     $filter->filterCollection($values, 'pim.transform.product_value.structured', Argument::type('array'))->shouldBeCalled()->willReturn($values);
     $iterator->rewind()->willReturn(null);
     $valueCount = 1;
     $iterator->valid()->will(function () use(&$valueCount) {
         return $valueCount-- > 0;
     });
     $iterator->current()->willReturn($value);
     $iterator->next()->willReturn(null);
     $normalizer->normalize($values, 'json', Argument::any())->willReturn(['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]]);
     $this->normalize($product, 'json')->shouldReturn(['family' => null, 'groups' => [], 'variant_group' => null, 'categories' => [], 'enabled' => true, 'values' => ['name' => [['locale' => null, 'scope' => null, 'value' => 'foo']]]]);
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:22,代碼來源:ProductPropertiesNormalizerSpec.php

示例11: testIterator

 /**
  * @dataProvider provideDifferentElements
  */
 public function testIterator($elements)
 {
     $collection = new ArrayCollection($elements);
     $iterations = 0;
     foreach ($collection->getIterator() as $key => $item) {
         $this->assertSame($elements[$key], $item, "Item {$key} not match");
         $iterations++;
     }
     $this->assertEquals(count($elements), $iterations, "Number of iterations not match");
 }
開發者ID:tccLaravel,項目名稱:test4,代碼行數:13,代碼來源:ArrayCollectionTest.php

示例12: sortPrivileges

 /**
  * Sorts the given privileges by name in alphabetical order.
  * The root privilege is moved at the top of the list.
  *
  * @param ArrayCollection|AclPrivilege[] $privileges [input/output]
  */
 protected function sortPrivileges(ArrayCollection &$privileges)
 {
     /** @var \ArrayIterator $iterator */
     $iterator = $privileges->getIterator();
     $iterator->uasort(function (AclPrivilege $a, AclPrivilege $b) {
         if (strpos($a->getIdentity()->getId(), ObjectIdentityFactory::ROOT_IDENTITY_TYPE)) {
             return -1;
         }
         if (strpos($b->getIdentity()->getId(), ObjectIdentityFactory::ROOT_IDENTITY_TYPE)) {
             return 1;
         }
         return strcmp($this->translator->trans($a->getIdentity()->getName()), $this->translator->trans($b->getIdentity()->getName()));
     });
     $result = new ArrayCollection();
     foreach ($iterator as $item) {
         $result->add($item);
     }
     $privileges = $result;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:25,代碼來源:AclPrivilegeRepository.php

示例13: getIterator

 /**
  * Required by interface IteratorAggregate.
  *
  * {@inheritDoc}
  */
 public function getIterator()
 {
     return $this->collection->getIterator();
 }
開發者ID:wotek,項目名稱:response-builder,代碼行數:9,代碼來源:Fields.php

示例14: getIterator

 /**
  * {@inheritDoc}
  */
 public function getIterator()
 {
     return $this->features->getIterator();
 }
開發者ID:christaggart,項目名稱:FeatureToggle,代碼行數:7,代碼來源:FeatureContainer.php

示例15: it_will_return_null_if_no_branch_with_name_exists_on_repo

 /**
  * @param \Doctrine\Common\Collections\ArrayCollection $collection
  */
 public function it_will_return_null_if_no_branch_with_name_exists_on_repo($collection)
 {
     $collection->getIterator()->willReturn(new \ArrayIterator([]));
     $this->setBranches($collection);
     $this->getBranchByName('dev')->shouldReturn(null);
 }
開發者ID:brankol,項目名稱:devboard,代碼行數:9,代碼來源:GithubRepoSpec.php


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