Doctrine\Common\Collections\ArrayCollection::set PHP Method

set() public method

{@inheritDoc}
public set ( $key, $value )
    public function set($key, $value)
    {
        $this->elements[$key] = $value;
    }

Usage Example

Exemplo n.º 1
0
 /**
  *
  * Returns an ArrayCollection containing three keys :
  *    - self::BASKETS : an ArrayCollection of the actives baskets
  *     (Non Archived)
  *    - self::STORIES : an ArrayCollection of working stories
  *    - self::VALIDATIONS : the validation people are waiting from me
  *
  * @return \Doctrine\Common\Collections\ArrayCollection
  */
 public function getContent($sort)
 {
     /* @var $repo_baskets Alchemy\Phrasea\Model\Repositories\BasketRepository */
     $repo_baskets = $this->app['repo.baskets'];
     $sort = in_array($sort, ['date', 'name']) ? $sort : 'name';
     $ret = new ArrayCollection();
     $baskets = $repo_baskets->findActiveByUser($this->app['authentication']->getUser(), $sort);
     // force creation of a default basket
     if (0 === count($baskets)) {
         $basket = new BasketEntity();
         $basket->setName($this->app->trans('Default basket'));
         $basket->setUser($this->app['authentication']->getUser());
         $this->app['EM']->persist($basket);
         $this->app['EM']->flush();
         $baskets = [$basket];
     }
     $validations = $repo_baskets->findActiveValidationByUser($this->app['authentication']->getUser(), $sort);
     /* @var $repo_stories Alchemy\Phrasea\Model\Repositories\StoryWZRepository */
     $repo_stories = $this->app['repo.story-wz'];
     $stories = $repo_stories->findByUser($this->app, $this->app['authentication']->getUser(), $sort);
     $ret->set(self::BASKETS, $baskets);
     $ret->set(self::VALIDATIONS, $validations);
     $ret->set(self::STORIES, $stories);
     return $ret;
 }
All Usage Examples Of Doctrine\Common\Collections\ArrayCollection::set