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


PHP ArrayCollection::toArray方法代码示例

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


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

示例1: getParameters

 /**
  * Get parameters.
  *
  * @return array
  */
 public function getParameters()
 {
     if (!$this->parameters instanceof ArrayCollection) {
         return [];
     }
     return $this->parameters->toArray();
 }
开发者ID:juliangut,项目名称:tify,代码行数:12,代码来源:ParameterTrait.php

示例2: __toString

 /**
  * Set comma state on oxford candidate word and
  * implode words back together
  *
  * @return string
  */
 public function __toString()
 {
     $this->getOxfordItems()->map(function (Word $word) {
         $word->setComma($this->getOxford());
     });
     return implode(' ', $this->words->toArray());
 }
开发者ID:epfremmer,项目名称:PHP-Weekly-Issue28,代码行数:13,代码来源:Sentence.php

示例3: toArray

 public function toArray()
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->toArray();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:AggregateEntryCollection.php

示例4: toArray

 /**
  * Returns fields as an array
  *
  * @return array
  */
 public function toArray()
 {
     /**
      * @todo: DO we bother that we have objects inside
      */
     return $this->collection->toArray();
 }
开发者ID:wotek,项目名称:response-builder,代码行数:12,代码来源:Fields.php

示例5: getDescendants

 function getDescendants($result = null)
 {
     if ($result == null) {
         $result = array();
     }
     $result = array_merge($result, $this->entries->toArray());
     foreach ($this->children as $c) {
         $result = $c->getDescendants($result);
     }
     return $result;
 }
开发者ID:nils-wisiol,项目名称:creditcard,代码行数:11,代码来源:Category.php

示例6: findBy

 /**
  * @param array $criteria
  *
  * @param array $orderBy
  * @param null  $limit
  * @param null  $offset
  *
  * @return mixed
  */
 public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 {
     return array_filter($this->entities->toArray(), function ($entity) use($criteria) {
         $conditions = [];
         foreach ($criteria as $key => $value) {
             $conditions[] = $entity->{$key}() == $value;
         }
         return array_reduce($conditions, function ($carry, $condition) {
             return $carry && $condition;
         }, true);
     });
 }
开发者ID:slaparra,项目名称:Training-Elastic-Search-Symfony,代码行数:21,代码来源:InMemoryEntityRepository.php

示例7: getRoleById

 public function getRoleById($roleId)
 {
     $roles = $this->roles->toArray();
     foreach ($this->getGroups() as $group) {
         $roles = array_merge($roles, $group->getRoles());
     }
     foreach ($roles as $r) {
         if ($r->getId() == $roleId) {
             return true;
         }
     }
     return false;
 }
开发者ID:Varenthein,项目名称:find_bulb,代码行数:13,代码来源:User.php

示例8: getStandings

 /**
  * @return Team[]
  */
 public function getStandings()
 {
     /** @var Team[] $teams */
     $teams = $this->teams->toArray();
     $points = array();
     $goalsDifference = array();
     $goalsFor = array();
     foreach ($teams as $k => $team) {
         $points[$k] = $team->getPoints();
         $goalsDifference[$k] = $team->getGoalsDifference();
         $goalsFor[$k] = $team->getGoalsFor();
     }
     array_multisort($points, SORT_DESC, $goalsDifference, SORT_DESC, $goalsFor, SORT_DESC, $teams);
     return $teams;
 }
开发者ID:kosak83,项目名称:OpenSoccerStar,代码行数:18,代码来源:League.php

示例9: getQBAliasReference

 public function getQBAliasReference($class, $attribute = NULL)
 {
     if (!is_object($class)) {
         throw new \Exception("object must be of type object, type %s given.", gettype($class));
     }
     $class_name = get_class($class);
     // get alias of class
     $alias = NULL;
     foreach ($this->qb_alias_reference->toArray() as $_class => $_alias) {
         if (isset($_alias[$class_name])) {
             $alias = $_alias[$class_name];
         }
     }
     // if not found
     if ($alias === NULL) {
         // if empty, set new
         if ($this->qb_alias_reference->count() == 0) {
             $alias = 'a';
             // get last and then count up
         } else {
             $lastAlias = $this->qb_alias_reference->last();
             $alias = ++$lastAlias[key($lastAlias)];
         }
         // add new
         $this->qb_alias_reference->add(array($class_name => $alias));
     }
     return $attribute === NULL ? $alias : $alias . '.' . $attribute;
 }
开发者ID:RSSfeed,项目名称:AdminBundle,代码行数:28,代码来源:AdminSearch.php

示例10: getLastSavedDraftRevision

 /**
  * Return the last draft saved.
  *
  * @return Revision
  */
 public function getLastSavedDraftRevision()
 {
     if (!empty($this->lastSavedDraft)) {
         return $this->lastSavedDraft;
     }
     $published = $this->publishedRevision;
     $staged = $this->stagedRevision;
     $arrayCollection = $this->revisions->toArray();
     /** @var \Rcm\Entity\Revision $revision */
     $revision = end($arrayCollection);
     if (empty($revision)) {
         return null;
     }
     $found = false;
     while (!$found) {
         if (empty($revision)) {
             break;
         } elseif (!empty($published) && $published->getRevisionId() == $revision->getRevisionId()) {
             $found = false;
         } elseif (!empty($staged) && $staged->getRevisionId() == $revision->getRevisionId()) {
             $found = false;
         } elseif ($revision->wasPublished()) {
             $found = false;
         } else {
             $found = true;
         }
         if (!$found) {
             $revision = prev($arrayCollection);
         }
     }
     return $this->lastSavedDraft = $revision;
 }
开发者ID:reliv,项目名称:rcm,代码行数:37,代码来源:ContainerAbstract.php

示例11: getOrderedThreads

 /**
  * Get ordered threads
  *
  * @return ArrayCollection
  */
 public function getOrderedThreads()
 {
     $threads = $this->threads->toArray();
     usort($threads, function (ForumThread $a, ForumThread $b) {
         if ($b->getStickied() === true && $a->getStickied() === false) {
             return 1;
         }
         if ($b->getStickied() === false && $a->getStickied() === false) {
             if ($b->getPosts()->count() > 0 && $a->getPosts()->count() === 0) {
                 return 1;
             }
             if ($b->getPosts()->count() === 0 && $a->getPosts()->count() > 0) {
                 return -1;
             }
             if ($b->getPosts()->count() === 0 && $a->getPosts()->count() === 0) {
                 return 0;
             }
             if ($b->getPosts()->last()->getDateCreated() > $a->getPosts()->last()->getDateCreated()) {
                 return 1;
             }
             if ($b->getPosts()->last()->getDateCreated() < $a->getPosts()->last()->getDateCreated()) {
                 return -1;
             }
         }
         return 0;
     });
     return $threads;
 }
开发者ID:madrakio,项目名称:streamperk-forum-bundle,代码行数:33,代码来源:Forum.php

示例12: setTasks

 /**
  * @param ArrayCollection $tasks
  *
  * @return HasTasksInterface
  */
 public function setTasks(ArrayCollection $tasks)
 {
     foreach ($tasks->toArray() as $task) {
         $this->addTask($task);
     }
     return $this;
 }
开发者ID:ministryofjustice,项目名称:opg-core-public-domain-model,代码行数:12,代码来源:HasTasks.php

示例13: indexAction

 public function indexAction()
 {
     $user = new User();
     $rol = new RolSistema();
     $opciones = new ArrayCollection();
     //new OpcionSistema();
     $user = $this->get('security.context')->getToken()->getUser();
     if ($user != 'anon.' && $user->getAuditDeleted() == false) {
         $roles = $user->getRols();
         if (isset($roles)) {
             foreach ($roles as $rol) {
                 //$opciones = $rol->getOpcionesSistema();
                 $opciones = new ArrayCollection(array_merge_maintain_keys($opciones->toArray(), $rol->getOpcionesSistema()->toArray()));
             }
             $peticion = $this->getRequest();
             $sesion = $peticion->getSession();
             $sesion->set('opciones', $opciones);
             return $this->render('MinSalSCABundle:Default:index.html.twig', array('opciones' => $opciones));
         }
     } else {
         if ($user != 'anon.' && $user->getAuditDeleted() == true) {
             $this->get('session')->setFlash('notice', 'El usuario "' . $user->getUsername() . '" se encuentra inactivo');
             $this->getRequest()->getSession()->set('notice', 'El usuario "' . $user->getUsername() . '" se encuentra inactivo');
             return new RedirectResponse($this->generateUrl('fos_user_security_logout'));
             //return $this->redirect($this->generateUrl('fos_user_security_logout'));
         }
         return $this->render('MinSalSCABundle:Default:index.html.twig');
     }
 }
开发者ID:UNCHenryMelara,项目名称:sca-mh-minsal,代码行数:29,代码来源:DefaultController.php

示例14: loadExistsObjects

 /**
  * Method for trying load objects via factory
  */
 public function loadExistsObjects()
 {
     $ids = array_column($this->exists->toArray(), 'id');
     // Try loading objects by ids via factory
     $loaded = $this->factory->load($ids);
     if (count($loaded)) {
         /** @var TransformableInterface $object */
         foreach ($loaded as $object) {
             foreach ($this->exists as $item) {
                 // If object has id equivalent item id then item has new description for that object
                 if ($object->getId() == $item['id']) {
                     // Populate object from item description
                     $this->bindContent($item, $object, $this->map);
                     // Validate and retrieve errors if exists
                     if ($errors = $this->validate($object)) {
                         $this->errors->add(array('item' => $item['number'], 'errors' => $errors));
                     } else {
                         $this->result->add($object);
                     }
                     // Clean internal "exists" collection for memory free
                     $this->exists->removeElement($item);
                 }
             }
         }
     }
     // Join not found item in db into "new" collection
     foreach ($this->exists as $item) {
         $this->new->add($item);
         // Clean internal "exists" collection
         $this->exists->removeElement($item);
     }
 }
开发者ID:Exanrus,项目名称:crm-bundle,代码行数:35,代码来源:ReverseCollectionTransformer.php

示例15: addThread

 /**
  * Add thread to collection
  *
  * @param Thread $thread
  * @return Blacklist
  */
 public function addThread($thread)
 {
     if (!in_array($thread, $this->threads->toArray())) {
         $this->threads->add($thread);
     }
     return $this;
 }
开发者ID:rotanov,项目名称:fefu-social-network,代码行数:13,代码来源:Blacklist.php


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