/**
  * @param callable|UserCredentialsStrategyInterface $strategy
  * @param string                                    $name
  */
 public function addUserCredentialsStrategy($strategy, $name, $priority = 0)
 {
     if (!is_callable($strategy) && !$strategy instanceof UserCredentialsStrategyInterface) {
         throw new InvalidArgumentException(sprintf("User credential strategy must be a callable or implement '%s'", UserCredentialsStrategyInterface::class));
     }
     $this->userCredentialsStrategies->insert($name, $strategy, $priority);
 }
Esempio n. 2
0
 public function testToArray()
 {
     $this->list->insert('foo', 'foo_value', null);
     $this->list->insert('bar', 'bar_value', 1);
     $this->list->insert('baz', 'baz_value', -1);
     $this->assertEquals(array('bar' => 'bar_value', 'foo' => 'foo_value', 'baz' => 'baz_value'), $this->list->toArray());
     $this->assertEquals(array('bar' => array('data' => 'bar_value', 'priority' => 1, 'serial' => 1), 'foo' => array('data' => 'foo_value', 'priority' => 0, 'serial' => 0), 'baz' => array('data' => 'baz_value', 'priority' => -1, 'serial' => 2)), $this->list->toArray(PriorityList::EXTR_BOTH));
 }
Esempio n. 3
0
 /**
  * Gets an iterator to iterate over the enabled formulars.
  *
  * @return \ArrayIterator
  * @see IteratorAggregate::getIterator()
  */
 public function getIterator()
 {
     $iterator = new PriorityList();
     $iterator->isLIFO(false);
     foreach ($this->activeForms as $key) {
         $spec = $this->forms[$key];
         $priority = isset($spec['priority']) ? $spec['priority'] : 0;
         $iterator->insert($key, $this->getForm($key), $priority);
     }
     return $iterator;
 }
Esempio n. 4
0
 /**
  * Set key/value pairs to update
  *
  * @param  array $values Associative array of key values
  * @param  string $flag One of the VALUES_* constants
  * @throws Exception\InvalidArgumentException
  * @return Update
  */
 public function set(array $values, $flag = self::VALUES_SET)
 {
     if ($values === null) {
         throw new Exception\InvalidArgumentException('set() expects an array of values');
     }
     if ($flag == self::VALUES_SET) {
         $this->set->clear();
     }
     $priority = is_numeric($flag) ? $flag : 0;
     foreach ($values as $k => $v) {
         if (!is_string($k)) {
             throw new Exception\InvalidArgumentException('set() expects a string for the value key');
         }
         $this->set->insert($k, $v, $priority);
     }
     return $this;
 }
Esempio n. 5
0
 /**
  * Make a deep clone of a fieldset
  *
  * @return void
  */
 public function __clone()
 {
     $items = $this->iterator->toArray(PriorityList::EXTR_BOTH);
     $this->elements = array();
     $this->fieldsets = array();
     $this->iterator = new PriorityList();
     $this->iterator->isLIFO(false);
     foreach ($items as $name => $item) {
         $elementOrFieldset = clone $item['data'];
         $this->iterator->insert($name, $elementOrFieldset, $item['priority']);
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $this->fieldsets[$name] = $elementOrFieldset;
         } elseif ($elementOrFieldset instanceof ElementInterface) {
             $this->elements[$name] = $elementOrFieldset;
         }
     }
     $this->iterator->rewind();
     // Also make a deep copy of the object in case it's used within a collection
     if (is_object($this->object)) {
         $this->object = clone $this->object;
     }
 }
 /**
  * Adds a view model.
  *
  * @param string    $name Name of the captureTo key.
  * @param ViewModel    $model
  * @param int $priority
  *
  * @return self
  */
 public function addViewModel($name, $model, $priority = 0)
 {
     $this->models->insert($name, $model, $priority);
     return $this;
 }
Esempio n. 7
0
 /**
  * @inheritDoc
  */
 public function attachGenerator($name, GeneratorInterface $generator, $priority = 1)
 {
     $this->generators->insert($name, $generator, $priority);
     return $this;
 }
Esempio n. 8
0
 /**
  * @param string $name
  * @param CollectorInterface $collector
  * @param int $priority
  * @return $this
  */
 public function attachCollector($name, CollectorInterface $collector, $priority = 1)
 {
     $this->collectors->insert($name, $collector, $priority);
     return $this;
 }