Exemplo n.º 1
0
 /**
  * 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;
     }
 }
Exemplo n.º 2
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];
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
 /**
  * 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;
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
 /**
  * Build parser configuration
  *
  * @return \TYPO3\Fluid\Core\Parser\Configuration
  */
 protected function buildParserConfiguration()
 {
     $parserConfiguration = $this->objectManager->create('TYPO3\\Fluid\\Core\\Parser\\Configuration');
     return $parserConfiguration;
 }