Example #1
0
 /**
  * @return void
  */
 public function setUp()
 {
     $this->viewHelperVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $this->templateVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
     $this->uriBuilder = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setLinkAccessRestrictedPages')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setTargetPageUid')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setTargetPageType')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setNoCache')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setUseCacheHash')->will($this->returnValue($this->uriBuilder));
     $this->request = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     $this->controllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
     $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
     $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->tagBuilder = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TagBuilder');
     $this->arguments = array();
     $this->renderingContext = new \TYPO3\Fluid\Core\Rendering\RenderingContext();
     $this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
     $this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
     $this->renderingContext->setControllerContext($this->controllerContext);
 }
 /**
  * @return void
  */
 protected function setUp()
 {
     $this->viewHelperVariableContainer = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer::class);
     $this->templateVariableContainer = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer::class);
     $this->uriBuilder = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
     $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setLinkAccessRestrictedPages')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setTargetPageUid')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setTargetPageType')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setNoCache')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setUseCacheHash')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setAddQueryStringMethod')->will($this->returnValue($this->uriBuilder));
     $this->request = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
     $this->controllerContext = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class, array(), array(), '', false);
     $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
     $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->tagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class);
     $this->arguments = array();
     $this->renderingContext = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext::class, array('dummy'));
     $this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
     $this->renderingContext->_set('viewHelperVariableContainer', $this->viewHelperVariableContainer);
     $this->renderingContext->setControllerContext($this->controllerContext);
     $this->mvcPropertyMapperConfigurationService = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class, array('dummy'));
 }
 /**
  * Sets the current controller context
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
  * @return void
  */
 public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 {
     $request = $controllerContext->getRequest();
     $this->controllerContext = $controllerContext;
     $this->baseRenderingContext->getTemplatePaths()->fillDefaultsByPackageName($request->getControllerExtensionKey());
     $this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
     $this->baseRenderingContext->setControllerContext($controllerContext);
 }
Example #4
0
 /**
  * Sets up this test case
  * @return void
  */
 protected function setUp()
 {
     $this->view = $this->getMock(\TYPO3\CMS\Extbase\Mvc\View\JsonView::class, array('loadConfigurationFromYamlFile'));
     $this->controllerContext = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class, array(), array(), '', false);
     $this->response = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Response::class, array());
     $this->controllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->view->setControllerContext($this->controllerContext);
 }
Example #5
0
 /**
  * Sets up this test case
  * @return void
  */
 public function setUp()
 {
     $this->view = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\View\\JsonView', array('loadConfigurationFromYamlFile'));
     $this->controllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
     $this->response = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response', array());
     $this->controllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->view->setControllerContext($this->controllerContext);
 }
Example #6
0
 /**
  * Transforms the value view variable to a serializable
  * array representation using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $response = $this->controllerContext->getResponse();
     if ($response instanceof WebResponse) {
         // @todo Ticket: #63643 This should be solved differently once request/response model is available for TSFE.
         if (!empty($GLOBALS['TSFE']) && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController) {
             /** @var TypoScriptFrontendController $typoScriptFrontendController */
             $typoScriptFrontendController = $GLOBALS['TSFE'];
             if (empty($typoScriptFrontendController->config['config']['disableCharsetHeader'])) {
                 // If the charset header is *not* disabled in configuration,
                 // TypoScriptFrontendController will send the header later with the Content-Type which we set here.
                 $typoScriptFrontendController->setContentType('application/json');
             } else {
                 // Although the charset header is disabled in configuration, we *must* send a Content-Type header here.
                 // Content-Type headers optionally carry charset information at the same time.
                 // Since we have the information about the charset, there is no reason to not include the charset information although disabled in TypoScript.
                 $response->setHeader('Content-Type', 'application/json; charset=' . trim($typoScriptFrontendController->metaCharset));
             }
         } else {
             $response->setHeader('Content-Type', 'application/json');
         }
     }
     $propertiesToRender = $this->renderArray();
     return json_encode($propertiesToRender);
 }
Example #7
0
 /**
  * @return void
  */
 protected function setUp()
 {
     $this->viewHelperVariableContainer = $this->prophesize(ViewHelperVariableContainer::class);
     $this->templateVariableContainer = $this->createMock(CmsVariableProvider::class);
     $this->uriBuilder = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
     $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setLinkAccessRestrictedPages')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setTargetPageUid')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setTargetPageType')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setNoCache')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setUseCacheHash')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setAddQueryStringMethod')->will($this->returnValue($this->uriBuilder));
     $this->request = $this->prophesize(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
     $this->controllerContext = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class);
     $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
     $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request->reveal()));
     $this->arguments = [];
     $this->renderingContext = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture::class, ['getControllerContext']);
     $this->renderingContext->expects($this->any())->method('getControllerContext')->willReturn($this->controllerContext);
     $this->renderingContext->setVariableProvider($this->templateVariableContainer);
     $this->renderingContext->_set('viewHelperVariableContainer', $this->viewHelperVariableContainer->reveal());
     $this->renderingContext->setControllerContext($this->controllerContext);
     $this->mvcPropertyMapperConfigurationService = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class, ['dummy']);
 }
 /**
  * @dataProvider getIdentifierTestValues
  * @param string|NULL $identifierArgument
  * @param string $expectedIdentifier
  */
 public function testGetIdentifier($identifierArgument, $expectedIdentifier)
 {
     $instance = $this->createInstance();
     $instance->setArguments(array('identifier' => $identifierArgument));
     $renderingContext = new RenderingContext();
     $controllerContext = new ControllerContext();
     $request = new Request();
     $request->setControllerActionName('p1');
     $request->setControllerName('p2');
     $request->setPluginName('p3');
     $request->setControllerExtensionName('p4');
     $controllerContext->setRequest($request);
     $renderingContext->setControllerContext($controllerContext);
     $instance->setRenderingContext($renderingContext);
     $result = $this->callInaccessibleMethod($instance, 'getIdentifier');
     $this->assertEquals($expectedIdentifier, $result);
 }
 /**
  * Build parser configuration
  *
  * @return \TYPO3\CMS\Fluid\Core\Parser\Configuration
  */
 protected function buildParserConfiguration()
 {
     $parserConfiguration = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Parser\\Configuration');
     if ($this->controllerContext->getRequest()->getFormat() === 'html') {
         $parserConfiguration->addInterceptor($this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Parser\\Interceptor\\Escape'));
     }
     return $parserConfiguration;
 }
Example #10
0
 /**
  * Transforms the value view variable to a serializable
  * array representation using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $response = $this->controllerContext->getResponse();
     if ($response instanceof WebResponse) {
         $response->setHeader('Content-Type', 'application/json');
     }
     $propertiesToRender = $this->renderArray();
     return json_encode($propertiesToRender);
 }
Example #11
0
 /**
  * Test for render()
  *
  * @param array $settings
  * @param array $fieldProperties
  * @param array $additionalAttributes
  * @param mixed $iteration
  * @param array $expectedResult
  * @return void
  * @dataProvider renderReturnsArrayDataProvider
  * @test
  */
 public function renderReturnsArray($settings, $fieldProperties, $additionalAttributes, $iteration, $expectedResult)
 {
     $field = new Field();
     foreach ($fieldProperties as $propertyName => $propertyValue) {
         $field->_setProperty($propertyName, $propertyValue);
     }
     $this->abstractValidationViewHelperMock->_set('settings', $settings);
     $this->abstractValidationViewHelperMock->_set('extensionName', 'powermail');
     $controllerContext = new ControllerContext();
     $request = new Request();
     $request->setControllerExtensionName('powermail');
     $controllerContext->setRequest($request);
     $this->abstractValidationViewHelperMock->_set('controllerContext', $controllerContext);
     $result = $this->abstractValidationViewHelperMock->_callRef('render', $field, $additionalAttributes, $iteration);
     $this->assertSame($expectedResult, $result);
 }
Example #12
0
 /**
  * Pre-processes class member values.
  */
 protected function preProcess()
 {
     $emptyGetVariables = count($this->getVariables) === 0;
     // Set default GET parameters
     if ($emptyGetVariables) {
         $this->getVariables = array('id', 'M');
     }
     // Automatically determine module name in Extbase context
     if ($this->controllerContext !== null) {
         $currentRequest = $this->controllerContext->getRequest();
         $extensionName = $currentRequest->getControllerExtensionName();
         $this->moduleName = $currentRequest->getPluginName();
         // Extend default GET parameters
         if ($emptyGetVariables) {
             $modulePrefix = strtolower('tx_' . $extensionName . '_' . $this->moduleName);
             $this->getVariables[] = $modulePrefix;
         }
     }
 }
Example #13
0
 /**
  * Gets the message for a notification mail as fluid template
  *
  * @param Comment $comment comment which triggers the mail send method
  * @return string The rendered fluid template (HTML or plain text)
  *
  * @throws \Exception
  */
 protected function getMailMessage(Comment $comment)
 {
     $mailTemplate = GeneralUtility::getFileAbsFileName($this->getTemplatePath());
     if (!file_exists($mailTemplate)) {
         throw new \Exception('Mail template (' . $mailTemplate . ') not found. ');
     }
     $this->fluidTemplate->setTemplatePathAndFilename($mailTemplate);
     // Assign variables
     $this->fluidTemplate->assign('comment', $comment);
     $this->fluidTemplate->assign('settings', $this->settings);
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $subFolder = $this->settings['subFolder'] ? $this->settings['subFolder'] : '';
     $articleLink = 'http://' . GeneralUtility::getHostname() . $subFolder . '/' . $uriBuilder->setTargetPageUid($comment->getPid())->setAddQueryString($this->getAddQueryStringToLinks())->setArgumentsToBeExcludedFromQueryString(array('id', 'cHash', 'tx_pwcomments_pi1[action]', 'tx_pwcomments_pi1[controller]'))->setUseCacheHash(FALSE)->buildFrontendUri();
     $this->fluidTemplate->assign('articleLink', $articleLink);
     $backendDomain = $this->settings['overwriteBackendDomain'] ? $this->settings['overwriteBackendDomain'] : GeneralUtility::getHostname();
     $backendLink = 'http://' . $backendDomain . $subFolder . '/typo3/alt_doc.php?M=web_list&id=' . $comment->getPid() . '&edit[tx_pwcomments_domain_model_comment][' . $comment->getUid() . ']=edit';
     $this->fluidTemplate->assign('backendLink', $backendLink);
     return $this->fluidTemplate->render();
 }
Example #14
0
 /**
  * Renders a given section.
  *
  * @param string $sectionName Name of section to render
  * @param array $variables The variables to use
  * @param boolean $ignoreUnknown Ignore an unknown section and just return an empty string
  * @return string rendered template for the section
  * @throws \TYPO3\Fluid\View\Exception\InvalidSectionException
  */
 public function renderSection($sectionName, array $variables, $ignoreUnknown = FALSE)
 {
     $renderingContext = $this->getCurrentRenderingContext();
     if ($this->getCurrentRenderingType() === self::RENDERING_LAYOUT) {
         // in case we render a layout right now, we will render a section inside a TEMPLATE.
         $renderingTypeOnNextLevel = self::RENDERING_TEMPLATE;
     } else {
         $variableContainer = $this->objectManager->create('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', $variables);
         $renderingContext = clone $renderingContext;
         $renderingContext->injectTemplateVariableContainer($variableContainer);
         $renderingTypeOnNextLevel = $this->getCurrentRenderingType();
     }
     $parsedTemplate = $this->getCurrentParsedTemplate();
     if ($parsedTemplate->isCompiled()) {
         $methodNameOfSection = 'section_' . sha1($sectionName);
         if ($ignoreUnknown && !method_exists($parsedTemplate, $methodNameOfSection)) {
             return '';
         }
         $this->startRendering($renderingTypeOnNextLevel, $parsedTemplate, $renderingContext);
         $output = $parsedTemplate->{$methodNameOfSection}($renderingContext);
         $this->stopRendering();
     } else {
         $sections = $parsedTemplate->getVariableContainer()->get('sections');
         if (!array_key_exists($sectionName, $sections)) {
             $controllerObjectName = $this->controllerContext->getRequest()->getControllerObjectName();
             if ($ignoreUnknown) {
                 return '';
             } else {
                 throw new \TYPO3\Fluid\View\Exception\InvalidSectionException(sprintf('Could not render unknown section "%s" in %s used by %s.', $sectionName, get_class($this), $controllerObjectName), 1227108982);
             }
         }
         $section = $sections[$sectionName];
         $renderingContext->getViewHelperVariableContainer()->add('TYPO3\\Fluid\\ViewHelpers\\SectionViewHelper', 'isCurrentlyRenderingSection', 'TRUE');
         $this->startRendering($renderingTypeOnNextLevel, $parsedTemplate, $renderingContext);
         $output = $section->evaluate($renderingContext);
         $this->stopRendering();
     }
     return $output;
 }
 /**
  * @test
  */
 public function initiateSubRequestBuildsRequestProperly()
 {
     $controller = $this->getMock(\TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController::class, array(), array(), '', FALSE);
     $this->viewHelper->_set('controller', $controller);
     // Initial Setup
     $widgetRequest = $this->getMock(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class);
     $response = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Response::class);
     $this->objectManager->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class)->will($this->returnValue($widgetRequest));
     $this->objectManager->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Web\Response::class)->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);
 }
Example #16
0
 /**
  * Transforms the value view variable to a serializable
  * array represantion using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $this->controllerContext->getResponse()->setHeader('Content-Type', 'application/json');
     $propertiesToRender = $this->renderArray();
     return json_encode($propertiesToRender);
 }
Example #17
0
 /**
  * @test
  */
 public function constructorInjectsFlashMessageContainerToControllerContext()
 {
     $this->mockControllerContext->expects($this->once())->method('setFlashMessageContainer')->with($this->mockFlashMessages);
     new \TYPO3\Fluid\View\StandaloneView();
 }
Example #18
0
 protected function getViewFileName(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 {
     // try to get the view name based upon the controller/action
     $controller = $controllerContext->getRequest()->getControllerName();
     $action = $controllerContext->getRequest()->getControllerActionName();
     $file = $controller . '/' . ucfirst($action) . '.tpl';
     $paths = $this->getTemplateRootPaths();
     $paths = \TYPO3\CMS\Extbase\Utility\ArrayUtility::sortArrayWithIntegerKeys($paths);
     $paths = array_reverse($paths, true);
     foreach ($paths as $rootPath) {
         $fileName = GeneralUtility::fixWindowsFilePath($rootPath . '/' . $file);
         $fileName = GeneralUtility::getFileAbsFileName($fileName);
         if (file_exists($fileName)) {
             return $fileName;
         }
     }
     // no view found
     throw new \Exception('Template not found for ' . $controller . '->' . $action);
 }
 /**
  * @test
  */
 public function constructorInjectsUriBuilderToControllerContext()
 {
     $this->mockControllerContext->expects($this->once())->method('setUriBuilder')->with($this->mockUriBuilder);
     new \TYPO3\CMS\Fluid\View\StandaloneView();
 }
Example #20
0
 /**
  * Checks whether a template can be resolved for the current request context.
  *
  * @param ControllerContext $controllerContext Controller context which is available inside the view
  * @return bool
  * @api
  */
 public function canRender(ControllerContext $controllerContext)
 {
     try {
         $request = $controllerContext->getRequest();
         $this->setControllerContext($controllerContext);
         $this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
         $this->baseRenderingContext->getTemplatePaths()->getTemplateSource($request->getControllerName(), $request->getControllerActionName());
         return true;
     } catch (InvalidTemplateResourceException $e) {
         return false;
     }
 }
Example #21
0
 /**
  * Creates a Message object and adds it to the FlashMessageQueue.
  *
  * @param string $messageBody The message
  * @param string $messageTitle Optional message title
  * @param int $severity Optional severity, must be one of \TYPO3\CMS\Core\Messaging\FlashMessage constants
  * @param bool $storeInSession Optional, defines whether the message should be stored in the session (default) or not
  * @return void
  * @throws \InvalidArgumentException if the message body is no string
  * @see \TYPO3\CMS\Core\Messaging\FlashMessage
  * @api
  */
 public function addFlashMessage($messageBody, $messageTitle = '', $severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession = true)
 {
     if (!is_string($messageBody)) {
         throw new \InvalidArgumentException('The message body must be of type string, "' . gettype($messageBody) . '" given.', 1243258395);
     }
     /* @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
     $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $messageBody, $messageTitle, $severity, $storeInSession);
     $this->controllerContext->getFlashMessageQueue()->enqueue($flashMessage);
 }
Example #22
0
 /**
  * Init
  *
  * @return void
  */
 public function initializeAction()
 {
     $this->controllerContext = $this->buildControllerContext();
     $this->user = $this->div->getCurrentUser();
     $this->cObj = $this->configurationManager->getContentObject();
     $this->pluginVariables = $this->request->getArguments();
     $this->allConfig = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $this->config = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $this->config = $this->config['plugin.']['tx_femanager.']['settings.'];
     $controllerName = strtolower($this->controllerContext->getRequest()->getControllerName());
     $removeFromUserGroupSelection = $this->settings[$controllerName]['misc']['removeFromUserGroupSelection'];
     $this->allUserGroups = $this->userGroupRepository->findAllForFrontendSelection($removeFromUserGroupSelection);
     if (isset($this->arguments['user'])) {
         $this->arguments['user']->getPropertyMappingConfiguration()->forProperty('dateOfBirth')->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, LocalizationUtility::translate('tx_femanager_domain_model_user.dateFormat', 'femanager'));
     }
     // check if ts is included
     if ($this->settings['_TypoScriptIncluded'] != 1 && !GeneralUtility::_GP('eID') && TYPO3_MODE !== 'BE') {
         $this->flashMessageContainer->add(LocalizationUtility::translate('error_no_typoscript', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
     }
     // check if storage pid was set
     if (intval($this->allConfig['persistence']['storagePid']) === 0 && !GeneralUtility::_GP('eID') && TYPO3_MODE !== 'BE') {
         $this->flashMessageContainer->add(LocalizationUtility::translate('error_no_storagepid', 'femanager'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
     }
 }
 /**
  * Set the controller context which will be passed to the ViewHelper
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext The controller context to set
  */
 public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 {
     $request = $controllerContext->getRequest();
     $this->controllerContext = $controllerContext;
     $this->setControllerAction($request->getControllerActionName());
     // Check if Request is using a sub-package key; in which case we translate this
     // for our RenderingContext as an emulated plain old sub-namespace controller.
     $controllerName = $request->getControllerName();
     if ($request->getControllerSubpackageKey() && !strpos($controllerName, '\\')) {
         $this->setControllerName($request->getControllerSubpackageKey() . '\\' . $controllerName);
     } else {
         $this->setControllerName($controllerName);
     }
 }
 /**
  * @return array An array of flash messages: array<\TYPO3\CMS\Core\Messaging\FlashMessage>
  * @deprecated since 6.1, will be removed 2 versions later
  */
 public function getAllMessagesAndFlush()
 {
     \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
     return $this->controllerContext->getFlashMessageQueue()->getAllMessagesAndFlush();
 }