Ejemplo n.º 1
0
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function viewHelperChildNodesCanBeReadAgain()
 {
     $viewHelperChildNodes = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
     $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface');
     $this->widgetContext->setViewHelperChildNodes($viewHelperChildNodes, $renderingContext);
     $this->assertSame($viewHelperChildNodes, $this->widgetContext->getViewHelperChildNodes());
     $this->assertSame($renderingContext, $this->widgetContext->getViewHelperChildNodeRenderingContext());
 }
 /**
  * The widget identifier is unique on the current page, and is used
  * in the URI as a namespace for the widget's arguments.
  *
  * @return string the widget identifier for this widget
  * @author Sebastian Kurfürst <*****@*****.**>
  * @return void
  * @todo clean up, and make it somehow more routing compatible.
  */
 private function initializeWidgetIdentifier()
 {
     if (!$this->viewHelperVariableContainer->exists('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', 'nextWidgetNumber')) {
         $widgetCounter = 0;
     } else {
         $widgetCounter = $this->viewHelperVariableContainer->get('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', 'nextWidgetNumber');
     }
     $widgetIdentifier = '__widget_' . $widgetCounter;
     $this->viewHelperVariableContainer->addOrUpdate('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', 'nextWidgetNumber', $widgetCounter + 1);
     $this->widgetContext->setWidgetIdentifier($widgetIdentifier);
 }
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function initiateSubRequestBuildsRequestProperly()
 {
     $controller = $this->getMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array(), array(), '', FALSE);
     $this->viewHelper->_set('controller', $controller);
     // Initial Setup
     $widgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
     $response = $this->getMock('Tx_Extbase_MVC_Web_Response');
     $this->objectManager->expects($this->at(0))->method('create')->with('Tx_Fluid_Core_Widget_WidgetRequest')->will($this->returnValue($widgetRequest));
     $this->objectManager->expects($this->at(1))->method('create')->with('Tx_Extbase_MVC_Web_Response')->will($this->returnValue($response));
     // Widget Context is set
     $widgetRequest->expects($this->once())->method('setWidgetContext')->with($this->widgetContext);
     // The namespaced arguments are passed to the sub-request
     // and the action name is exctracted from the namespace.
     $this->controllerContext->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->widgetContext->expects($this->once())->method('getWidgetIdentifier')->will($this->returnValue('widget-1'));
     $this->request->expects($this->once())->method('getArguments')->will($this->returnValue(array('k1' => 'k2', 'widget-1' => array('arg1' => 'val1', 'arg2' => 'val2', 'action' => 'myAction'))));
     $widgetRequest->expects($this->once())->method('setArguments')->with(array('arg1' => 'val1', 'arg2' => 'val2'));
     $widgetRequest->expects($this->once())->method('setControllerActionName')->with('myAction');
     // Controller is called
     $controller->expects($this->once())->method('processRequest')->with($widgetRequest, $response);
     $output = $this->viewHelper->_call('initiateSubRequest');
     // SubResponse is returned
     $this->assertSame($response, $output);
 }
 /**
  * Stores the WidgetContext inside the Context, and sets the
  * AjaxWidgetIdentifier inside the Widget Context correctly.
  *
  * @param Tx_Fluid_Core_Widget_WidgetContext $widgetContext
  * @return void
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function store(Tx_Fluid_Core_Widget_WidgetContext $widgetContext)
 {
     $ajaxWidgetId = md5(uniqid(mt_rand(), TRUE));
     $widgetContext->setAjaxWidgetIdentifier($ajaxWidgetId);
     $this->widgetContexts[$ajaxWidgetId] = $widgetContext;
     $this->storeWidgetContexts();
 }
Ejemplo n.º 5
0
 /**
  * Returns the unique URI namespace for this widget in the format pluginNamespace[widgetIdentifier]
  *
  * @return string
  */
 public function getArgumentPrefix()
 {
     return $this->widgetContext->getParentPluginNamespace() . '[' . $this->widgetContext->getWidgetIdentifier() . ']';
 }