Пример #1
0
 /**
  * Gets the configuration options for this Widget.
  * @return array of options. Each option has the following keys:
  * * name: The code name of the option.
  * * types: Array of accepted types.
  * * description: The description in the code.
  */
 public function getOptions(WidgetInfo $info)
 {
     $options = $this->getOptionsFromClass($info->getReflection());
     foreach ($info->getMixins() as $mixin) {
         $mixinClass = new ReflectionClass($mixin);
         $options = array_merge($this->getOptionsFromClass($mixinClass), $options);
     }
     return $options;
 }
 public function filter(WidgetInfo $widget, array &$arguments)
 {
     if ($widget->isA('GroupElement') && isset($arguments['items'])) {
         $newItems = array();
         foreach ($arguments['items'] as $item) {
             if (!is_array($item)) {
                 throw new InvalidGroupElementItemException();
             } else {
                 $newItems[] = $this->widgetFactory->create($item);
             }
         }
         $arguments['items'] = $newItems;
     }
 }
Пример #3
0
 protected function getCode(WidgetInfo $class, array $args)
 {
     $replacements = array('$class' => $class->getClassName(), '$args' => call_user_func($this->config['encodeVars'], $args));
     $code = strtr($this->config['template'], $replacements);
     return $code;
 }
Пример #4
0
 /**
  * @dataProvider provideIsA
  */
 public function testIsA($class, $isA, $value)
 {
     $widgetInfo = new WidgetInfo('test', $class);
     $this->assertEquals($value, $widgetInfo->isA($isA));
 }