Пример #1
0
 public function testBuildView()
 {
     $type = new AnchorType();
     $optionsResolver = $type->getOptionsResolver();
     $type->setDefaultOptions($optionsResolver, $this->defaultColumnOptions);
     $options = array('name' => 'foo', 'params' => array('k' => 'i', 'l' => 'j'), 'format' => '%d:%d', 'attrs' => array('a' => 1, 'b' => 2), 'anchor_args' => array('x' => 'y', 'z' => 1), 'anchor_route' => 'route');
     $resolvedOptions = $optionsResolver->resolve($options);
     $view = array();
     $column = new Column($type, $resolvedOptions);
     $type->buildView($view, $column, array('k' => 1, 'l' => 2), $resolvedOptions);
     $expectedViewKeys = array('name', 'type', 'attrs', 'value', 'route', 'params', 'title');
     foreach ($expectedViewKeys as $key) {
         $this->assertArrayHasKey($key, $view);
     }
     $this->assertArrayHasKey('class', $view['attrs']);
     $this->assertEquals('foo', $view['name']);
     $this->assertEquals($view['type'], $type->getName());
     $this->assertEquals($view['value'], '1:2');
     $this->assertEquals($view['route'], $resolvedOptions['anchor_route']);
     $this->assertEquals($view['params'], array('k' => 1, 'l' => 2, 'x' => 'y', 'z' => 1));
     $this->assertEquals($view['title'], $resolvedOptions['anchor_title']);
     $this->assertEquals(trim('column-' . $type->getName() . ' column-foo'), $view['attrs']['class']);
     $this->assertArrayHasKey('a', $view['attrs']);
     $this->assertArrayHasKey('b', $view['attrs']);
     $this->assertEquals(array('x' => 'y', 'z' => 1, 'k' => 1, 'l' => 2), $view['params']);
     $this->assertArrayHasKey('b', $view['attrs']);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  * <br/>
  * <br/>
  * Available Options :
  * <ul>
  * <li><b>anchor_route</b>  : string|null <i>Anchor route, default null.</i></li>
  * <li><b>icon</b>          : string|callable <i>Icon name without prefix icon_family : fa-table => table</i></li>
  * <li><b>icon_family</b>   : string <i>Icon family (fa|icon|glyphicon|...). Default is defined bundle config.</i></li>
  * </ul>
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver, array $defaultOptions)
 {
     parent::setDefaultOptions($resolver, $defaultOptions);
     $resolver->setDefaults(array('icon' => null, 'icon_family' => $defaultOptions['icon_family']));
     $resolver->addAllowedTypes(array('anchor_route' => array('null', 'string'), 'icon' => array('string', 'callable'), 'icon_family' => 'string'));
 }
Пример #3
0
 /**
  * {@inheritdoc}
  * <br/>
  * <br/>
  * Available Options :
  * <ul>
  * <li><b>anchor_route</b>  : string|null <i>Anchor route, default null.</i></li>
  * </ul>
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver, array $defaultOptions)
 {
     parent::setDefaultOptions($resolver, $defaultOptions);
     $resolver->setAllowedTypes(array('anchor_route' => array('null', 'string')));
 }