Neos\Neos\Fusion\PluginImplementation::evaluate PHP Метод

evaluate() публичный Метод

Returns the rendered content of this plugin
public evaluate ( ) : string
Результат string The rendered content as a string
    public function evaluate()
    {
        $currentContext = $this->tsRuntime->getCurrentContext();
        $this->node = $currentContext['node'];
        $this->documentNode = $currentContext['documentNode'];
        /** @var $parentResponse Response */
        $parentResponse = $this->tsRuntime->getControllerContext()->getResponse();
        $pluginResponse = new Response($parentResponse);
        $this->dispatcher->dispatch($this->buildPluginRequest(), $pluginResponse);
        foreach ($pluginResponse->getHeaders()->getAll() as $key => $value) {
            $parentResponse->getHeaders()->set($key, $value, true);
        }
        return $pluginResponse->getContent();
    }

Usage Example

Пример #1
0
 /**
  * Test if the response headers of the plugin - set within the plugin action / dispatch - were set into the parent response.
  *
  * @dataProvider responseHeadersDataprovider
  * @test
  */
 public function evaluateSetHeaderIntoParent($message, $input, $expected)
 {
     $this->pluginImplementation->expects($this->any())->method('buildPluginRequest')->will($this->returnValue($this->mockActionRequest));
     $parentResponse = new Response();
     $this->_setHeadersIntoResponse($parentResponse, $input['parent']);
     $this->mockControllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($parentResponse));
     $this->mockDispatcher->expects($this->any())->method('dispatch')->will($this->returnCallback(function ($request, $response) use($input) {
         $this->_setHeadersIntoResponse($response, $input['plugin']);
     }));
     $this->pluginImplementation->evaluate();
     foreach ($expected as $expectedKey => $expectedValue) {
         $this->assertEquals($expectedValue, (string) $parentResponse->getHeaders()->get($expectedKey), $message);
     }
 }