Arrilot\Widgets\Factories\WidgetFactory::run PHP Method

run() public method

Run widget without magic method.
public run ( ) : mixed
return mixed
    public function run()
    {
        $args = func_get_args();
        $this->instantiateWidget($args);
        $content = $this->getContentFromCache($args);
        if ($timeout = (double) $this->getReloadTimeout()) {
            $content .= $this->javascriptFactory->getReloader($timeout);
            $content = $this->wrapContentInContainer($content);
        }
        return $this->convertToViewExpression($content);
    }

Usage Example

 public function testItCanCacheWidgets()
 {
     $output = $this->factory->run('testCachedWidget', ['foo' => 'bar']);
     $key = 'arrilot.widgets.' . serialize(['testCachedWidget', ['foo' => 'bar']]);
     $widget = new TestCachedWidget();
     $this->assertEquals('Cached output. Key: ' . $key . ', minutes: ' . $widget->cacheTime, $output);
 }