FOF30\Layout\LayoutHelper::render PHP Метод

render() публичный статический Метод

Method to render the layout.
public static render ( Container $container, string $layoutFile, object $displayData = null, string $basePath = '' ) : string
$container FOF30\Container\Container The container of your component
$layoutFile string Dot separated path to the layout file, relative to base path
$displayData object Object which properties are used inside the layout file to build displayed output
$basePath string Base path to use when loading layout files
Результат string
    public static function render(Container $container, $layoutFile, $displayData = null, $basePath = '')
    {
        $basePath = empty($basePath) ? self::$defaultBasePath : $basePath;
        // Make sure we send null to LayoutFile if no path set
        $basePath = empty($basePath) ? null : $basePath;
        $layout = new LayoutFile($layoutFile, $basePath);
        $layout->container = $container;
        $renderedLayout = $layout->render($displayData);
        return $renderedLayout;
    }

Usage Example

Пример #1
0
 /**
  * @covers       FOF30\Layout\LayoutHelper::render
  *
  * @dataProvider FOF30\Tests\Layout\LayoutHelperTestProvider::getTestRender
  *
  * @param string $layoutId       The layout to load
  * @param array  $platformSetup  Platform setup (baseDirs, template, templateSuffixes)
  * @param string $expectedOutput The expected output which should be returned
  * @param string $message        Failure message
  */
 public function testRenderDefaultBase($layoutId, $platformSetup, $expectedOutput, $message)
 {
     // Set up the platform
     $defaultPlatformSetup = array('baseDirs' => null, 'template' => null, 'templateSuffixes' => null);
     if (!is_array($platformSetup)) {
         $platformSetup = array();
     }
     $platformSetup = array_merge($defaultPlatformSetup, $platformSetup);
     $reflector = new \ReflectionClass('FOF30\\Tests\\Helpers\\TestJoomlaPlatform');
     foreach ($platformSetup as $k => $v) {
         $reflector->setStaticPropertyValue($k, $v);
     }
     unset($reflector);
     // Set up a fake base
     $fakeBase = realpath(__DIR__ . '/../_data/layout/base');
     // Create the layout file object
     LayoutHelper::$defaultBasePath = $fakeBase;
     $actual = LayoutHelper::render(self::$container, $layoutId);
     $this->assertEquals($expectedOutput, $actual, $message);
 }
LayoutHelper