This class is only used internally by the widget framework.
コード例 #1
0
 /**
  * Extracts the WidgetContext from the given $httpRequest.
  * If the request contains an argument "__widgetId" the context is fetched from the session (AjaxWidgetContextHolder).
  * Otherwise the argument "__widgetContext" is expected to contain the serialized WidgetContext (protected by a HMAC suffix)
  *
  * @param Request $httpRequest
  * @return WidgetContext
  */
 protected function extractWidgetContext(Request $httpRequest)
 {
     if ($httpRequest->hasArgument('__widgetId')) {
         return $this->ajaxWidgetContextHolder->get($httpRequest->getArgument('__widgetId'));
     } elseif ($httpRequest->hasArgument('__widgetContext')) {
         $serializedWidgetContextWithHmac = $httpRequest->getArgument('__widgetContext');
         $serializedWidgetContext = $this->hashService->validateAndStripHmac($serializedWidgetContextWithHmac);
         return unserialize(base64_decode($serializedWidgetContext));
     }
     return null;
 }
コード例 #2
0
 /**
  * Initialize the Widget Context, before the Render method is called.
  *
  * @return void
  */
 private function initializeWidgetContext()
 {
     if ($this->ajaxWidget === true) {
         if ($this->storeConfigurationInSession === true) {
             $this->ajaxWidgetContextHolder->store($this->widgetContext);
         }
         $this->widgetContext->setAjaxWidgetConfiguration($this->getAjaxWidgetConfiguration());
     }
     $this->widgetContext->setNonAjaxWidgetConfiguration($this->getNonAjaxWidgetConfiguration());
     $this->initializeWidgetIdentifier();
     $controllerObjectName = $this->controller instanceof DependencyProxy ? $this->controller->_getClassName() : get_class($this->controller);
     $this->widgetContext->setControllerObjectName($controllerObjectName);
 }
コード例 #3
0
 /**
  * @test
  */
 public function handleInjectsActionRequestToSecurityContext()
 {
     $mockWidgetId = 'SomeWidgetId';
     $mockControllerObjectName = 'SomeControllerObjectName';
     $this->mockHttpRequest->expects($this->at(0))->method('hasArgument')->with('__widgetId')->will($this->returnValue(true));
     $this->mockHttpRequest->expects($this->atLeastOnce())->method('getArgument')->with('__widgetId')->will($this->returnValue($mockWidgetId));
     $mockWidgetContext = $this->getMockBuilder(\Neos\FluidAdaptor\Core\Widget\WidgetContext::class)->getMock();
     $mockWidgetContext->expects($this->atLeastOnce())->method('getControllerObjectName')->will($this->returnValue($mockControllerObjectName));
     $this->mockAjaxWidgetContextHolder->expects($this->atLeastOnce())->method('get')->with($mockWidgetId)->will($this->returnValue($mockWidgetContext));
     $mockActionRequest = $this->getMockBuilder(\Neos\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockObjectManager->expects($this->atLeastOnce())->method('get')->with(\Neos\Flow\Mvc\ActionRequest::class)->will($this->returnValue($mockActionRequest));
     $this->mockSecurityContext->expects($this->once())->method('setRequest')->with($mockActionRequest);
     $this->ajaxWidgetComponent->handle($this->mockComponentContext);
 }
 /**
  * @test
  */
 public function initializeArgumentsAndRenderStoresTheWidgetContextIfInAjaxMode()
 {
     $this->viewHelper->_set('ajaxWidget', true);
     $this->ajaxWidgetContextHolder->expects($this->once())->method('store')->with($this->widgetContext);
     $this->callViewHelper();
 }