Exemplo n.º 1
0
 protected function registerAssets()
 {
     $widgets = [];
     $config = $this->getConfig();
     foreach ((array) $config['widgets'] as $name => $widget) {
         // Skip disabled extensions.
         if (isset($widget['enabled']) && $widget['enabled'] === false) {
             continue;
         }
         if (empty($widget['zone']) || $widget['zone'] !== 'backend') {
             $widget['zone'] = 'frontend';
         }
         $widgetObj = new Widget();
         $widgetObj->setZone($widget['zone'])->setLocation($widget['location'])->setCallback([$this, 'widget'])->setCallbackArguments(['widget' => $widget]);
         if (!empty($widget['class'])) {
             $widgetObj->setClass($widget['class']);
         }
         if (!empty($widget['defer'])) {
             $widgetObj->setDefer($widget['defer']);
         }
         if (!empty($widget['cacheduration'])) {
             $widgetObj->setCacheDuration($widget['cacheduration']);
         } else {
             $widgetObj->setCacheDuration(-1);
         }
         if (!empty($widget['withcontext']) && $widget['withcontext'] === true) {
             $widgetObj->setCacheDuration(-1);
             $widgetObj->setDefer(false);
         }
         $widgets[] = $widgetObj;
     }
     return $widgets;
 }
Exemplo n.º 2
0
 public function testWidgetCastStringFromCallback()
 {
     $widget = new Widget();
     $widget->setCallback([$this, 'widgetCallback'])->setCallbackArguments(['first' => 'Clippy', 'second' => 'Koala'])->setContent('Some test content');
     $this->assertSame('Clippy gives gum leaves to the Koala', (string) $widget);
 }