Sulu\Bundle\PreviewBundle\Preview\PreviewInterface::updateContext PHP Method

updateContext() public method

Updates given context and restart preview with given data.
public updateContext ( string $token, string $webspaceKey, string $locale, array $context, array $data ) : string
$token string To identify the preview-session
$webspaceKey string Webspace to render object
$locale string
$context array Contains contextual data to restart preview
$data array Data which will be updated before re-rendering content
return string Complete html response
    public function updateContext($token, $webspaceKey, $locale, array $context, array $data);

Usage Example

Example #1
0
 /**
  * Update preview-context with given parameter.
  *
  * @param MessageHandlerContext $context
  * @param array $message
  *
  * @return array
  */
 private function updateContext($context, $message)
 {
     $response = $this->preview->updateContext($context->get('previewToken'), $message['webspaceKey'], $context->get('locale'), $message['context'], $message['data']);
     return ['command' => 'update-context', 'response' => $response, 'msg' => 'OK'];
 }