set() public method

{@inheritDoc}
public set ( $key, $value )
Example #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;
 }
 public function addToFilters(ArrayCollection $filters)
 {
     $upperBound = $this->fields . '_' . $this->options['upper_bound_suffix'];
     $lowerBound = $this->fields . '_' . $this->options['lower_bound_suffix'];
     $filters->set($lowerBound, $this->getGreaterThanFilter());
     $filters->set($upperBound, $this->getLessThanFilter());
 }
 /**
  * @inheritdoc
  */
 public function update(User $user)
 {
     if (!$this->collection->containsKey((string) $user->getId())) {
         throw new UserNotFoundException();
     }
     $this->collection->set((string) $user->getId(), $user);
 }
Example #4
0
 /**
  * @param ProviderInterface $provider
  *
  * @return $this
  */
 public function addProvider(ProviderInterface $provider)
 {
     if (!$this->providers->contains($provider)) {
         $this->providers->set($provider->getName(), $provider);
     }
     return $this;
 }
Example #5
0
 /**
  * @param string $type
  * @param array $options
  * @return $this
  */
 protected function addAction($type, array $options = [])
 {
     $action = $this->actionFactory->get($type, $options);
     $suffix = $action->getOptions()['route_suffix'];
     $key = empty($suffix) ? $action->getName() : $suffix;
     $this->actions->set($key, $action);
     return $this;
 }
Example #6
0
 /**
  * @param string $type
  * @param array $options
  * @return ActionsProvider
  */
 protected function addAction(string $type, array $options = []) : self
 {
     $action = $this->actionFactory->get($type, $options);
     $suffix = $action->getOptions()['route_suffix'];
     $key = empty($suffix) ? str_replace('Action', '', substr($type, strrpos($type, '\\') + 1)) : $suffix;
     $this->actions->set(strtolower($key), $action);
     return $this;
 }
Example #7
0
 public function add(IEntity $entity)
 {
     $this->errorOnInvalidEntityType($entity);
     if ($this->getIdentityValue($entity) < 1) {
         $this->setIdentityValue($entity, $this->collection->count() + 1);
     }
     $this->collection->set($entity->getId(), $entity);
 }
Example #8
0
 public function build(\SimplePie_Item $feed)
 {
     $data = new ArrayCollection();
     $data->set('title', $feed->get_title());
     $data->set('url', $feed->get_permalink());
     $data->set('description', $feed->get_description());
     return $data;
 }
Example #9
0
 public function addBundle(BaseBundle $bundle)
 {
     if (!$this->bundles->containsKey($bundle->name)) {
         $bundle->map = $this;
         $this->bundles->set($bundle->name, $bundle);
     }
     return $this;
 }
Example #10
0
 public function addModel(BaseModel $model)
 {
     if (!$this->models->containsKey($model->name)) {
         $model->bundle = $this;
         $this->models->set($model->name, $model);
     }
     return $this;
 }
Example #11
0
 public function setDefaultConfig($key, $value, $type, $section = "default")
 {
     $valueArray = new \Doctrine\Common\Collections\ArrayCollection();
     $valueArray->set('value', $value);
     $valueArray->set('section', $section);
     $valueArray->set('key', $key);
     $valueArray->set('type', $type);
     $this->configList->set($section . '.' . $key, $valueArray);
 }
Example #12
0
 /**
  * @param Car $car
  * @return boolean
  */
 public function add(Car $car)
 {
     if ($this->has($car)) {
         return false;
     }
     $this->cars->set($car->getId(), 1);
     $this->session->set('cart', $this->cars);
     return true;
 }
 /**
  * Add activity
  *
  * @param Activity $activity
  * @return Student
  */
 public function addActivity(Activity $activity)
 {
     $key = $activity->getMachineName();
     if ($this->activities->containsKey($key)) {
         throw new \InvalidArgumentException('This Student already belongs to this Activity');
     }
     $this->activities->set($key, $activity);
     return $this;
 }
Example #14
0
 /**
  * Constructor
  *
  * @param string $text
  * @param WordFactory $wordFactory
  */
 public function __construct($text, WordFactory $wordFactory)
 {
     $this->text = $text;
     $this->words = new ArrayCollection(explode(' ', $text));
     $this->words->forAll(function ($index, $word) use($wordFactory) {
         $this->words->set($index, $wordFactory->make($word));
         return true;
     });
 }
Example #15
0
 /**
  * Set registered types
  *
  * @param string               $typeName
  * @param IntegrationInterface $type
  *
  * @throws \LogicException
  * @return $this
  */
 public function addChannelType($typeName, IntegrationInterface $type)
 {
     if (!$this->integrationTypes->containsKey($typeName)) {
         $this->integrationTypes->set($typeName, $type);
     } else {
         throw new LogicException(sprintf('Trying to redeclare integration type "%s".', $typeName));
     }
     return $this;
 }
 /**
  * @param Ignored $ignored
  *
  * @return IgnoredRepository
  */
 public function replace(Ignored $ignored)
 {
     foreach ($this->ignores as $key => $value) {
         if ($value->getId() === $ignored->getId()) {
             $this->ignores->set($key, $ignored);
             return $this;
         }
     }
     return $this;
 }
Example #17
0
 protected function _initSettings()
 {
     $this->_setSocialSetting($this->em->getRepository("AppBundle:SocialSetting")->findOneBySocialSettingStringId(self::STRING_ID));
     $q = $this->em->createQuery("\n            SELECT d FROM AppBundle\\Entity\\SocialSettingData d\n            WHERE d.socialSettingId = :id\n        ")->setParameter('id', $this->getSocialSetting()->getSocialSettingId());
     $result = $q->getResult();
     $this->_settings = new \Doctrine\Common\Collections\ArrayCollection();
     /* @var $setting \AppBundle\Entity\SocialSettingData */
     foreach ($result as $setting) {
         $this->_settings->set($setting->getSocialSettingDataKey(), $setting->getSocialSettingDataValue());
     }
 }
Example #18
0
 /**
  * @param string $field
  * @param mixed $type
  * @param array $options
  * @return FilterProvider
  */
 protected function addFilter(string $field, $type, array $options = []) : self
 {
     if (is_string($type) || $type instanceof FilterTypeInterface) {
         $filter = $this->factory->get($type, $options);
     } elseif (is_callable($type)) {
         $filter = $type;
     } else {
         throw new \InvalidArgumentException('Expected argument of type "callable", "string" or class Vardius\\Bundle\\ListBundle\\Filter\\Types\\FilterTypeInterface, ' . get_class($type) . ' given');
     }
     $this->filters->set($field, $filter);
     return $this;
 }
 public function set($key, $value)
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     $this->entries->set($key, $value);
 }
Example #20
0
 public function addKey($name, $value)
 {
     if (!$this->keys->containsKey($name)) {
         $this->keys->set($name, $value);
     }
     return $this;
 }
Example #21
0
 /**
  * Add a parameter to the class
  *
  * @param ParameterModel $parameterModel
  * @return $this
  */
 public function addParameter(ParameterModel $parameterModel)
 {
     $parameterName = $parameterModel->getName();
     Tebru\assertArrayKeyNotExists($parameterName, $this->parameters->toArray(), 'Parameter "%s" already exists in method', $parameterName);
     $this->parameters->set($parameterName, $parameterModel);
     return $this;
 }
Example #22
0
 static function load(Config $config)
 {
     $scenes = new ArrayCollection();
     // Start with the entry scene
     $stack = array();
     $scene = $config['entry_scene'];
     array_push($stack, $scene);
     // Loop until our stack is empty
     while (count($stack)) {
         // Load a scene from the stack
         $scenePath = array_pop($stack);
         $data = Yaml::load($config['base_directory'] . '/' . $scenePath . '.yml');
         // Create a scene from the data
         $newScene = new Scene($scenePath, $data);
         $scenes->set($scenePath, $newScene);
         // If we have exit-scenes, add them to the stack so we can load them
         foreach ($data['scene']['exit'] as $direction => $exitScene) {
             $tmp['exit'][strtolower($direction)] = $exitScene;
             // Only add to stack when we haven't already processed that scene
             if (!$scenes->containsKey($exitScene)) {
                 array_push($stack, $exitScene);
             }
         }
     }
     return $scenes;
 }
Example #23
0
 /**
  * {@inheritDoc}
  *
  * @throws \UnexpectedValueException
  */
 public function set($key, $value)
 {
     if (!$this->checkType($value)) {
         throw new \UnexpectedValueException(sprintf(self::$exceptionErrorMessage, 2, __CLASS__, 'set', $this->getType(), $this->getItemType($value)));
     }
     parent::set($key, $value);
 }
 /**
  * Collect all order subtotals
  *
  * @param Order $order
  *
  * @return ArrayCollection|Subtotal[]
  */
 public function getSubtotals(Order $order)
 {
     $subtotals = new ArrayCollection();
     $subtotal = $this->getSubtotal($order);
     $subtotals->set($subtotal->getType(), $subtotal);
     return $subtotals;
 }
Example #25
0
 /**
  * Add a property to the class
  *
  * @param PropertyModel $propertyModel
  * @return $this
  */
 public function addProperty(PropertyModel $propertyModel)
 {
     $propertyName = $propertyModel->getName();
     Tebru\assertArrayKeyNotExists($propertyName, $this->properties->toArray(), 'Property "%s" already exists on class', $propertyName);
     $this->properties->set($propertyName, $propertyModel);
     return $this;
 }
Example #26
0
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     foreach ($this->fields as $managerName => $method) {
         call_user_func(array(self::getElementMethod($this->model, $managerName, $method), 'set'), $key, call_user_func(array($value, $managerName)));
     }
     parent::set($key, $value);
 }
Example #27
0
 /**
  * @return mixed
  */
 public function addAttribute($name, $value)
 {
     if (!$this->attributes->offsetExists($name)) {
         $this->attributes->set($name, $value);
     }
     return $this;
 }
 public function addQuestion(SurveyQuestion $question)
 {
     if (!$this->questions->contains($question)) {
         $this->questions->set($question->getField()->getName(), $question);
         $question->setSurvey($this);
     }
 }
Example #29
0
 public function addMedia(Media $media)
 {
     if (!$this->medias->contains($media)) {
         $media->setProduct($this);
         $this->medias->set($media->getLocale(), $media);
     }
     return $this;
 }
Example #30
0
 /**
  * @param $name
  * @param Command $command
  * @param $arguments
  * @param $priority
  */
 public function addCommand($name, Command $command, $arguments, $priority)
 {
     if (!$this->commands->containsKey($name)) {
         $this->commands->set($name, new ArrayCollection());
     }
     $meta = new CommandMeta($command, $arguments, $priority);
     $this->commands->get($name)->add($meta);
 }