コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
ファイル: User.php プロジェクト: alduleacristi/stock-manager
 /**
  * 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;
 }
コード例 #3
0
 /**
  * @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();
 }
コード例 #4
0
 /**
  * @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;
 }
コード例 #5
0
 public function __construct(PageMediaCollectionAdminType $type, Collection $mediaSet)
 {
     parent::__construct(['media_set' => $type]);
     $this->type = $type;
     $this->mediaSet = $mediaSet;
     $this->toDelete = $mediaSet->toArray();
 }
コード例 #6
0
ファイル: Archetype.php プロジェクト: vikey89/Sylius
 /**
  * {@inheritdoc}
  */
 public function getOptions()
 {
     if (!$this->hasParent()) {
         return $this->options;
     }
     return new ArrayCollection(array_merge($this->parent->getOptions()->toArray(), $this->options->toArray()));
 }
コード例 #7
0
ファイル: Cart.php プロジェクト: hd-deman/elcodi
 /**
  * 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;
 }
コード例 #8
0
 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);
 }
コード例 #9
0
ファイル: Toponym.php プロジェクト: mhlavac/GeonamesBundle
 /**
  * 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;
 }
コード例 #10
0
ファイル: User.php プロジェクト: jducro/music-school
 public function getRoles()
 {
     $rolesArray = [];
     foreach ($this->roles->toArray() as $role) {
         if ($role instanceof Role) {
             $rolesArray[] = $role->getRole();
         }
     }
     return $rolesArray;
 }
コード例 #11
0
 /**
  * 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();
 }
 /**
  * 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();
 }
コード例 #13
0
ファイル: CollectionContainer.php プロジェクト: svobodni/web
 /**
  * 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);
         }
     }
 }
コード例 #14
0
 /**
  * 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;
 }
コード例 #15
0
 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);
 }
コード例 #16
0
ファイル: BaseRepository.php プロジェクト: svobodni/web
 /**
  * @param object|array|Collection $entity
  * @param boolean $withoutFlush
  */
 public function delete($entity, $withoutFlush = self::FLUSH)
 {
     if ($entity instanceof Collection) {
         return $this->delete($entity->toArray(), $withoutFlush);
     }
     if (is_array($entity)) {
         $repository = $this;
         array_map(function ($entity) use($repository) {
             return $repository->delete($entity, BaseRepository::NO_FLUSH);
         }, $entity);
         $this->flush($withoutFlush);
         return;
     }
     if (!$entity instanceof $this->_entityName) {
         throw new Nette\InvalidArgumentException("Entity is not instanceof " . $this->_entityName . ', ' . get_class($entity) . ' given.');
     }
     $this->getEntityManager()->remove($entity);
     $this->flush($withoutFlush);
 }
コード例 #17
0
ファイル: MenuItem.php プロジェクト: superdesk/web-publisher
 /**
  * {@inheritdoc}
  */
 public function getChildren()
 {
     if (is_array($this->children)) {
         return $this->children;
     }
     return $this->children->toArray();
 }
コード例 #18
0
ファイル: User.php プロジェクト: Newman101/WellCommerce
 /**
  * {@inheritdoc}
  */
 public function getRoles()
 {
     return $this->roles->toArray();
 }
コード例 #19
0
ファイル: Cart.php プロジェクト: VictorMateo/elcodi
 /**
  * Get the sum of all CartLines weight.
  *
  * @return int Weight
  */
 public function getWeight()
 {
     return array_reduce($this->cartLines->toArray(), function ($weight, CartLineInterface $cartLine) {
         return $weight + $cartLine->getWeight();
     }, 0);
 }
コード例 #20
0
ファイル: Canditato.php プロジェクト: serbinario/UCHI
 /**
  * Get trabalhoTrabalho
  *
  * @return \Doctrine\Common\Collections\Collection 
  */
 public function getCandidatoTemTrabalho()
 {
     return $this->candidatoTemTrabalho->toArray();
 }
コード例 #21
0
ファイル: Page.php プロジェクト: hafeez3000/orocommerce
 /**
  * Get slugs related to current page
  *
  * @return Slug[]
  */
 public function getRelatedSlugs()
 {
     return array_diff($this->slugs->toArray(), [$this->currentSlug]);
 }
コード例 #22
0
ファイル: Paciente.php プロジェクト: joprietoe/becker
 /**
  * Get nCuidados
  *
  * @return \Doctrine\Common\Collections\Collection 
  */
 public function getNCuidados()
 {
     return array_map(function ($nCuidados) {
         return $nCuidados->getCuidado();
     }, $this->nCuidados->toArray());
 }
コード例 #23
0
ファイル: User.php プロジェクト: Achse/petrhejna
 /**
  * @return Role[]
  */
 public function getUserRoles()
 {
     return $this->userRoles->toArray();
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $this->initialize();
     return $this->coll->toArray();
 }
コード例 #25
0
ファイル: UpdateWorkshop.php プロジェクト: uirapuru/evento
 private function convertLessons(Collection $lessons)
 {
     return array_map(function (Lesson $lesson) {
         return LessonFactory::createUpdateCommand($lesson);
     }, $lessons->toArray());
 }
コード例 #26
0
ファイル: Usuario.php プロジェクト: Kstro/siprint
 /**
  * Get roles
  *
  * @return Doctrine\Common\Collections\Collection
  */
 public function getRoles()
 {
     return $this->user_roles->toArray();
     //IMPORTANTE: el mecanismo de seguridad de Sf2 requiere ésto como un array
 }
コード例 #27
0
 public function serializeCollection(VisitorInterface $visitor, Collection $collection, array $type, Context $context)
 {
     // We change the base type, and pass through possible parameters.
     $type['name'] = 'array';
     return $visitor->visitArray($collection->toArray(), $type, $context);
 }
コード例 #28
0
ファイル: TagManager.php プロジェクト: snorchel/platform
 /**
  * @param Collection|int[] $tagIds
  *
  * @return int[]
  */
 protected function prepareTagIds($tagIds)
 {
     if ($tagIds instanceof Collection) {
         return array_map(function (Tag $item) {
             return $item->getId();
         }, $tagIds->toArray());
     } elseif (!is_array($tagIds)) {
         return [];
     }
     return $tagIds;
 }
コード例 #29
0
 /**
  * Sort the collection of options by their defined sort order in the attribute
  *
  * @param Collection $optionsCollection
  *
  * @return Collection
  */
 protected function sortOptions(Collection $optionsCollection)
 {
     $options = $optionsCollection->toArray();
     usort($options, function ($first, $second) {
         return $first->getSortOrder() > $second->getSortOrder();
     });
     $sortedCollection = new ArrayCollection($options);
     return $sortedCollection;
 }
コード例 #30
0
 public function serializeCollection(VisitorInterface $visitor, Collection $collection, Type $type, Context $context)
 {
     return $visitor->visitArray($collection->toArray(), $type, $context);
 }