示例#1
0
 /**
  * Initializes the Object framework.
  *
  * @return void
  * @see initialize()
  */
 public function initializeConfiguration($configuration)
 {
     $this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     $contentObject = isset($this->cObj) ? $this->cObj : \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     $this->configurationManager->setContentObject($contentObject);
     $this->configurationManager->setConfiguration($configuration);
 }
 /**
  * Public such that it is callable from within closures
  *
  * @param integer $uniqueCounter
  * @param \TYPO3\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
  * @param string $viewHelperName
  * @return \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper
  * @internal
  */
 public function getViewHelper($uniqueCounter, \TYPO3\Fluid\Core\Rendering\RenderingContextInterface $renderingContext, $viewHelperName)
 {
     if (isset($this->viewHelpersByPositionAndContext[$uniqueCounter])) {
         if ($this->viewHelpersByPositionAndContext[$uniqueCounter]->contains($renderingContext)) {
             $viewHelper = $this->viewHelpersByPositionAndContext[$uniqueCounter][$renderingContext];
             $viewHelper->resetState();
             return $viewHelper;
         } else {
             $viewHelperInstance = self::$objectContainer->getInstance($viewHelperName);
             if ($viewHelperInstance instanceof \TYPO3\Fluid\Object\SingletonInterface) {
                 $viewHelperInstance->resetState();
             }
             $this->viewHelpersByPositionAndContext[$uniqueCounter]->attach($renderingContext, $viewHelperInstance);
             return $viewHelperInstance;
         }
     } else {
         $this->viewHelpersByPositionAndContext[$uniqueCounter] = new \SplObjectStorage();
         $viewHelperInstance = $this->objectManager->create($viewHelperName);
         if ($viewHelperInstance instanceof \TYPO3\Fluid\Object\SingletonInterface) {
             $viewHelperInstance->resetState();
         }
         $this->viewHelpersByPositionAndContext[$uniqueCounter]->attach($renderingContext, $viewHelperInstance);
         return $viewHelperInstance;
     }
 }
示例#3
0
 /**
  * @param string $identifier
  * @return \TYPO3\Fluid\Core\Parser\ParsedTemplateInterface
  */
 public function get($identifier)
 {
     $identifier = $this->sanitizeIdentifier($identifier);
     if (!isset($this->syntaxTreeInstanceCache[$identifier])) {
         require_once $this->templateCacheDir . $identifier . '.php';
         $templateClassName = 'FluidCache_' . $identifier;
         $this->syntaxTreeInstanceCache[$identifier] = $this->objectManager->create($templateClassName);
     }
     return $this->syntaxTreeInstanceCache[$identifier];
 }
 /**
  */
 public function setUp()
 {
     $this->serverBackup = $_SERVER;
     $this->getBackup = $_GET;
     $this->postBackup = $_POST;
     $this->widgetRequestBuilder = $this->getAccessibleMock('TYPO3\\Fluid\\Core\\Widget\\WidgetRequestBuilder', array('setArgumentsFromRawRequestData'));
     $this->mockWidgetRequest = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest');
     $this->mockObjectManager = $this->getMock('TYPO3\\Fluid\\Object\\ObjectManagerInterface');
     $this->mockObjectManager->expects($this->once())->method('create')->with('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest')->will($this->returnValue($this->mockWidgetRequest));
     $this->widgetRequestBuilder->_set('objectManager', $this->mockObjectManager);
     $this->mockWidgetContext = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\WidgetContext');
     $this->mockAjaxWidgetContextHolder = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder');
     $this->widgetRequestBuilder->injectAjaxWidgetContextHolder($this->mockAjaxWidgetContextHolder);
     $this->mockAjaxWidgetContextHolder->expects($this->once())->method('get')->will($this->returnValue($this->mockWidgetContext));
 }
示例#5
0
文件: Service.php 项目: kftseng/fluid
 /**
  * Builds class schemata from classes annotated as entities or value objects
  *
  * @param string $className
  * @throws Exception\UnknownClassException
  * @return \TYPO3\Fluid\Reflection\ClassSchema The class schema
  */
 protected function buildClassSchema($className)
 {
     if (!class_exists($className)) {
         throw new \TYPO3\Fluid\Reflection\Exception\UnknownClassException('The classname "' . $className . '" was not found and thus can not be reflected.', 1278450972);
     }
     $classSchema = $this->objectManager->create('TYPO3\\Fluid\\Reflection\\ClassSchema', $className);
     if (is_subclass_of($className, 'TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity')) {
         $classSchema->setModelType(\TYPO3\Fluid\Reflection\ClassSchema::MODELTYPE_ENTITY);
         $possibleRepositoryClassName = str_replace('_Model_', '_Repository_', $className) . 'Repository';
         if (class_exists($possibleRepositoryClassName)) {
             $classSchema->setAggregateRoot(TRUE);
         }
     } elseif (is_subclass_of($className, 'TYPO3\\CMS\\Extbase\\DomainObject\\AbstractValueObject')) {
         $classSchema->setModelType(\TYPO3\Fluid\Reflection\ClassSchema::MODELTYPE_VALUEOBJECT);
     } else {
         return NULL;
     }
     foreach ($this->getClassPropertyNames($className) as $propertyName) {
         if (!$this->isPropertyTaggedWith($className, $propertyName, 'transient') && $this->isPropertyTaggedWith($className, $propertyName, 'var')) {
             $cascadeTagValues = $this->getPropertyTagValues($className, $propertyName, 'cascade');
             $classSchema->addProperty($propertyName, implode(' ', $this->getPropertyTagValues($className, $propertyName, 'var')), $this->isPropertyTaggedWith($className, $propertyName, 'lazy'), $cascadeTagValues[0]);
         }
         if ($this->isPropertyTaggedWith($className, $propertyName, 'uuid')) {
             $classSchema->setUuidPropertyName($propertyName);
         }
         if ($this->isPropertyTaggedWith($className, $propertyName, 'identity')) {
             $classSchema->markAsIdentityProperty($propertyName);
         }
     }
     $this->classSchemata[$className] = $classSchema;
     $this->dataCacheNeedsUpdate = TRUE;
     return $classSchema;
 }
示例#6
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->view = $this->getAccessibleMock('TYPO3\\Fluid\\View\\StandaloneView', array('dummy'), array(), '', FALSE);
     $this->mockTemplateParser = $this->getMock('TYPO3\\Fluid\\Core\\Parser\\TemplateParser');
     $this->mockParsedTemplate = $this->getMock('TYPO3\\Fluid\\Core\\Parser\\ParsedTemplateInterface');
     $this->mockTemplateParser->expects($this->any())->method('parse')->will($this->returnValue($this->mockParsedTemplate));
     $this->mockConfigurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     $this->mockObjectManager = $this->getMock('TYPO3\\Fluid\\Object\\ObjectManagerInterface');
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback')));
     $this->mockObjectManager->expects($this->any())->method('create')->will($this->returnCallback(array($this, 'objectManagerCallback')));
     $this->mockRequest = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     $this->mockUriBuilder = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $this->mockFlashMessages = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\FlashMessages');
     $this->mockContentObject = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     $this->mockControllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext');
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest));
     $this->mockViewHelperVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $this->mockRenderingContext = $this->getMock('TYPO3\\Fluid\\Core\\Rendering\\RenderingContext');
     $this->mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->mockViewHelperVariableContainer));
     $this->view->injectTemplateParser($this->mockTemplateParser);
     $this->view->injectObjectManager($this->mockObjectManager);
     $this->view->setRenderingContext($this->mockRenderingContext);
     $this->mockTemplateCompiler = $this->getMock('TYPO3\\Fluid\\Core\\Compiler\\TemplateCompiler');
     $this->view->_set('templateCompiler', $this->mockTemplateCompiler);
     $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\Fluid\\Object\\ObjectManagerInterface', $this->mockObjectManager);
     \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', $this->mockContentObject);
 }
示例#7
0
文件: Escape.php 项目: kftseng/fluid
 /**
  * Adds a ViewHelper node using the Format\HtmlspecialcharsViewHelper to the given node.
  * If "escapingInterceptorEnabled" in the ViewHelper is FALSE, will disable itself inside the ViewHelpers body.
  *
  * @param \TYPO3\Fluid\Core\Parser\SyntaxTree\NodeInterface $node
  * @param integer $interceptorPosition One of the INTERCEPT_* constants for the current interception point
  * @param \TYPO3\Fluid\Core\Parser\ParsingState $parsingState the current parsing state. Not needed in this interceptor.
  * @return \TYPO3\Fluid\Core\Parser\SyntaxTree\NodeInterface
  */
 public function process(\TYPO3\Fluid\Core\Parser\SyntaxTree\NodeInterface $node, $interceptorPosition, \TYPO3\Fluid\Core\Parser\ParsingState $parsingState)
 {
     if ($interceptorPosition === \TYPO3\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER) {
         if (!$node->getUninitializedViewHelper()->isEscapingInterceptorEnabled()) {
             $this->interceptorEnabled = FALSE;
             $this->viewHelperNodesWhichDisableTheInterceptor[] = $node;
         }
     } elseif ($interceptorPosition === \TYPO3\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER) {
         if (end($this->viewHelperNodesWhichDisableTheInterceptor) === $node) {
             array_pop($this->viewHelperNodesWhichDisableTheInterceptor);
             if (count($this->viewHelperNodesWhichDisableTheInterceptor) === 0) {
                 $this->interceptorEnabled = TRUE;
             }
         }
     } elseif ($this->interceptorEnabled && $node instanceof \TYPO3\Fluid\Core\Parser\SyntaxTree\ObjectAccessorNode) {
         $escapeViewHelper = $this->objectManager->get('TYPO3\\Fluid\\ViewHelpers\\Format\\HtmlspecialcharsViewHelper');
         $node = $this->objectManager->create('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', $escapeViewHelper, array('value' => $node));
     }
     return $node;
 }
 /**
  * Initiate a sub request to $this->controller. Make sure to fill $this->controller
  * via Dependency Injection.
  *
  * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface the response of this request.
  * @api
  */
 protected function initiateSubRequest()
 {
     if (!$this->controller instanceof \TYPO3\Fluid\Core\Widget\AbstractWidgetController) {
         if (isset($this->controller)) {
             throw new \TYPO3\Fluid\Core\Widget\Exception\MissingControllerException('initiateSubRequest() can not be called if there is no valid controller extending TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetController. Got "' . get_class($this->controller) . '" in class "' . get_class($this) . '".', 1289422564);
         }
         throw new \TYPO3\Fluid\Core\Widget\Exception\MissingControllerException('initiateSubRequest() can not be called if there is no controller inside $this->controller. Make sure to add a corresponding injectController method to your WidgetViewHelper class "' . get_class($this) . '".', 1284401632);
     }
     $subRequest = $this->objectManager->create('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest');
     $subRequest->setWidgetContext($this->widgetContext);
     $this->passArgumentsToSubRequest($subRequest);
     $subResponse = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     $this->controller->processRequest($subRequest, $subResponse);
     return $subResponse;
 }
 /**
  * @test
  */
 public function initiateSubRequestBuildsRequestProperly()
 {
     $controller = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetController', array(), array(), '', FALSE);
     $this->viewHelper->_set('controller', $controller);
     // Initial Setup
     $widgetRequest = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest');
     $response = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     $this->objectManager->expects($this->at(0))->method('create')->with('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest')->will($this->returnValue($widgetRequest));
     $this->objectManager->expects($this->at(1))->method('create')->with('TYPO3\\CMS\\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);
 }
示例#10
0
 /**
  * @return void
  */
 protected function initializeConcreteConfigurationManager()
 {
     $this->concreteConfigurationManager = $this->objectManager->get('TYPO3\\Fluid\\Configuration\\FrontendConfigurationManager');
 }
示例#11
0
 /**
  * Text node handler
  *
  * @param \TYPO3\Fluid\Core\Parser\ParsingState $state
  * @param string $text
  * @return void
  */
 protected function textHandler(\TYPO3\Fluid\Core\Parser\ParsingState $state, $text)
 {
     $node = $this->objectManager->create('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\TextNode', $text);
     $this->callInterceptor($node, \TYPO3\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_TEXT, $state);
     $state->getNodeFromStack()->addChildNode($node);
 }
示例#12
0
 /**
  * Build parser configuration
  *
  * @return \TYPO3\Fluid\Core\Parser\Configuration
  */
 protected function buildParserConfiguration()
 {
     $parserConfiguration = $this->objectManager->create('TYPO3\\Fluid\\Core\\Parser\\Configuration');
     return $parserConfiguration;
 }