eZ\Publish\Core\MVC\Symfony\View\Manager::renderContent PHP 메소드

renderContent() 공개 메소드

$content will be injected in the selected template.
public renderContent ( eZ\Publish\API\Repository\Values\Content\Content $content, string $viewType = ViewManagerInterface::VIEW_TYPE_FULL, array $parameters = [] ) : string
$content eZ\Publish\API\Repository\Values\Content\Content
$viewType string Variation of display for your content. Default is 'full'.
$parameters array Parameters to pass to the template called to render the view. By default, it's empty. 'content' entry is reserved for the Content that is rendered.
리턴 string
    public function renderContent(Content $content, $viewType = ViewManagerInterface::VIEW_TYPE_FULL, $parameters = array())
    {
        $view = new ContentView(null, $parameters, $viewType);
        $view->setContent($content);
        if (isset($parameters['location'])) {
            $view->setLocation($parameters['location']);
        }
        $this->viewConfigurator->configure($view);
        if ($view->getTemplateIdentifier() === null) {
            throw new RuntimeException('Unable to find a template for #' . $content->contentInfo->id);
        }
        return $this->renderContentView($view, $parameters);
    }

Usage Example

예제 #1
0
 public function testRenderContentWithClosure()
 {
     $content = new Content(['versionInfo' => new VersionInfo(['contentInfo' => new ContentInfo()])]);
     // Configuring view provider behaviour
     $closure = function ($params) {
         return serialize(array_keys($params));
     };
     $params = ['foo' => 'bar'];
     $this->viewConfigurator->expects($this->once())->method('configure')->will($this->returnCallback(function (View $view) use($closure) {
         $view->setTemplateIdentifier($closure);
     }));
     // Configuring template engine behaviour
     $params += array('content' => $content, 'viewbaseLayout' => $this->viewBaseLayout);
     $expectedTemplateResult = array_keys($params);
     $this->templateEngineMock->expects($this->never())->method('render');
     $templateResult = unserialize($this->viewManager->renderContent($content, 'full', $params));
     sort($expectedTemplateResult);
     sort($templateResult);
     self::assertEquals($expectedTemplateResult, $templateResult);
 }
All Usage Examples Of eZ\Publish\Core\MVC\Symfony\View\Manager::renderContent