当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::toArray方法代码示例

本文整理汇总了PHP中Doctrine\Common\Collections\Collection::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::toArray方法的具体用法?PHP Collection::toArray怎么用?PHP Collection::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Collections\Collection的用法示例。


在下文中一共展示了Collection::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getOrderedSteps

 /**
  * Get steps sorted by order.
  *
  * @return Collection|Step[]
  */
 public function getOrderedSteps()
 {
     $steps = $this->steps->toArray();
     usort($steps, function (Step $stepOne, Step $stepTwo) {
         return $stepOne->getOrder() >= $stepTwo->getOrder() ? 1 : -1;
     });
     return new ArrayCollection($steps);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:StepManager.php

示例2: getRoles

 /**
  * Get roles
  *
  * @return \Doctrine\Common\Collections\Collection
  */
 public function getRoles()
 {
     $rolesArray = $this->roles->toArray();
     $stringRoles = array();
     for ($i = 0; $i < sizeof($rolesArray); $i++) {
         $stringRoles[$i] = $rolesArray[$i]->getRolename();
     }
     return $stringRoles;
 }
开发者ID:alduleacristi,项目名称:stock-manager,代码行数:14,代码来源:User.php

示例3: getEntities

 /**
  * @return array
  */
 public function getEntities($modifyValue = true)
 {
     // Modify the value to illustrate the difference between by value and by reference
     if ($modifyValue) {
         foreach ($this->entities as $entity) {
             $entity->setField('Modified from getEntities getter', false);
         }
     }
     return $this->entities->toArray();
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:13,代码来源:OneToManyArrayEntity.php

示例4: getMutations

 /**
  * @return ClientMutation[]
  */
 public function getMutations()
 {
     $mutations = $this->mutations->toArray();
     usort($mutations, function (ClientMutation $ma, ClientMutation $mb) {
         if ($ma->getId() === $mb->getId()) {
             return 0;
         }
         return $ma->getId() > $mb->getId() ? -1 : 1;
     });
     return $mutations;
 }
开发者ID:hostnet,项目名称:entity-mutation-component,代码行数:14,代码来源:Client.php

示例5: __construct

 public function __construct(PageMediaCollectionAdminType $type, Collection $mediaSet)
 {
     parent::__construct(['media_set' => $type]);
     $this->type = $type;
     $this->mediaSet = $mediaSet;
     $this->toDelete = $mediaSet->toArray();
 }
开发者ID:syzygypl,项目名称:page-media-set-bundle,代码行数:7,代码来源:FormWidget.php

示例6: getOptions

 /**
  * {@inheritdoc}
  */
 public function getOptions()
 {
     if (!$this->hasParent()) {
         return $this->options;
     }
     return new ArrayCollection(array_merge($this->parent->getOptions()->toArray(), $this->options->toArray()));
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:10,代码来源:Archetype.php

示例7: getTotalItemNumber

 /**
  * Return the total amount of items
  * added to the Cart
  *
  * @return integer
  */
 public function getTotalItemNumber()
 {
     $totalItems = array_reduce($this->cartLines->toArray(), function ($previousTotal, CartLineInterface $current) {
         return $previousTotal + $current->getQuantity();
     });
     return is_null($totalItems) ? 0 : $totalItems;
 }
开发者ID:hd-deman,项目名称:elcodi,代码行数:13,代码来源:Cart.php

示例8: serializeCollection

 public function serializeCollection(VisitorInterface $visitor, Collection $collection, array $type, Context $context)
 {
     $viewModelClass = null;
     if ($this->viewModel !== null) {
         $viewModelClass = get_class($this->viewModel);
     }
     // Only serialize to HalCollection when:
     // 1. We're not rendering a view model (viewModel is NULL). So we are respecting the defined type.
     // 2. We're actually rendering to Hal.
     // Note that we're using the class name because other view models might inherit from HalJsonModel...
     if ($viewModelClass == 'ZF\\Hal\\View\\HalJsonModel') {
         return new HalCollection($collection->toArray());
     }
     // We change the base type, and pass through possible parameters.
     $type['name'] = 'array';
     return $visitor->visitArray($collection->toArray(), $type, $context);
 }
开发者ID:detailnet,项目名称:dfw-apigility-module,代码行数:17,代码来源:HalCollectionHandler.php

示例9: getAlternateNamesArray

 /**
  * Get alternate names as a simple array
  *
  * @return string[]
  */
 public function getAlternateNamesArray()
 {
     if (empty($this->alternateNamesArray)) {
         return array_map(function (AlternateName $alternateName) {
             return $alternateName->getName();
         }, $this->alternateNames->toArray());
     }
     return $this->alternateNamesArray;
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:14,代码来源:Toponym.php

示例10: getRoles

 public function getRoles()
 {
     $rolesArray = [];
     foreach ($this->roles->toArray() as $role) {
         if ($role instanceof Role) {
             $rolesArray[] = $role->getRole();
         }
     }
     return $rolesArray;
 }
开发者ID:jducro,项目名称:music-school,代码行数:10,代码来源:User.php

示例11: transform

 /**
  * Transforms a collection into an array.
  *
  * @param Collection $collection A collection of entities
  *
  * @return mixed An array of entities
  *
  * @throws TransformationFailedException
  */
 public function transform($collection)
 {
     if (null === $collection) {
         return array();
     }
     if (!$collection instanceof Collection) {
         throw new TransformationFailedException('Expected a Doctrine\\Common\\Collections\\Collection object.');
     }
     return $collection->toArray();
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:19,代码来源:CollectionToArrayTransformer.php

示例12: transform

 /**
  * Transforms a collection into an array.
  *
  * @param Collection $collection A collection of entities
  *
  * @return mixed An array of entities
  *
  * @throws UnexpectedTypeException
  */
 public function transform($collection)
 {
     if (null === $collection) {
         return array();
     }
     if (!$collection instanceof Collection) {
         throw new UnexpectedTypeException($collection, 'Doctrine\\Common\\Collections\\Collection');
     }
     return $collection->toArray();
 }
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:19,代码来源:CollectionToArrayTransformer.php

示例13: clearContainers

 /**
  * Clear containers, that were not submitted
  */
 protected function clearContainers()
 {
     if (!$this->getPresenter(FALSE) || !$this->getForm()->isSubmitted()) {
         return;
         // only if attached to presenter & submitted
     }
     foreach ($this->collection->toArray() as $entity) {
         if (!$this->getMapper()->getComponent($entity)) {
             $this->getMapper()->remove($entity);
         }
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:15,代码来源:CollectionContainer.php

示例14: removeElement

 /**
  * Removes the specified element from the collection, if it is found.
  *
  * @param mixed $element The element to remove.
  *
  * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  */
 function removeElement($element)
 {
     $this->checkType($element);
     $this->initialize();
     /** @var $eTerm EntityTerm */
     foreach ($this->collection->toArray() as $eTerm) {
         if ($eTerm->getTerm() === $element) {
             $this->setDirty(true);
             return $this->collection->removeElement($eTerm);
         }
     }
     return false;
 }
开发者ID:activelamp,项目名称:taxonomy,代码行数:20,代码来源:PluralVocabularyField.php

示例15: serializeCollection

 public function serializeCollection(VisitorInterface $visitor, Collection $collection, array $type, Context $context)
 {
     // We change the base type, and pass through possible parameters.
     $type['name'] = 'array';
     //don't include items that will produce null elements
     $dataArray = [];
     foreach ($collection->toArray() as $element) {
         if (!$context->isVisiting($element)) {
             $dataArray[] = $element;
         }
     }
     return $visitor->visitArray($dataArray, $type, $context);
 }
开发者ID:belackriv,项目名称:step-inventory,代码行数:13,代码来源:ArrayCollectionHandler.php


注:本文中的Doctrine\Common\Collections\Collection::toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。