Beispiel #1
0
 function renderOptions()
 {
     $this->identifiers->setProvider('Foo', function () {
         return ['one' => 'uno', 'two' => 'dos', 'three' => 'tres'];
     });
     $parameter = new Parameter('foo', new IdentifierType('Foo', new StringType()));
     $this->assert($this->field->render($parameter, 'two'), '<select name="foo" class="form-control">' . "\n" . '<option value="one">uno</option>' . "\n" . '<option value="two" selected="selected">dos</option>' . "\n" . '<option value="three">tres</option>' . "\n" . '</select>');
 }
Beispiel #2
0
 /**
  * @param Parameter $parameter
  * @return mixed
  * @throws \Exception
  */
 protected function getOptions(Parameter $parameter)
 {
     return $this->identifiers->getIdentifiers($this->getType($parameter)->getTarget());
 }
Beispiel #3
0
 private function initIdentifierProviders(IdentifiersProvider $identifiers)
 {
     $identifiers->setProvider(Author::class, function () {
         $ids = [];
         foreach ($this->authors->readAll() as $author) {
             $ids[$author->getEmail()] = $author->getName();
         }
         return $ids;
     });
     $identifiers->setProvider(Post::class, function () {
         $ids = [];
         foreach ($this->posts->readAll() as $post) {
             $ids[$post->getId()] = $post->getTitle() . ' - ' . $post->getAuthor()->getId();
         }
         return $ids;
     });
     return $this;
 }