當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。