[TASK] Sync CMS Fluid with Flow Fluid 1.1 (part1)
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / Core / Parser / Configuration.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\Parser;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 /**
15 * The parser configuration. Contains all configuration needed to configure
16 * the building of a SyntaxTree.
17 */
18 class Configuration {
19
20 /**
21 * Generic interceptors registered with the configuration.
22 *
23 * @var array<\TYPO3\CMS\Extbase\Persistence\ObjectStorage>
24 */
25 protected $interceptors = array();
26
27 /**
28 * Adds an interceptor to apply to values coming from object accessors.
29 *
30 * @param \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface $interceptor
31 * @return void
32 */
33 public function addInterceptor(\TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface $interceptor) {
34 foreach ($interceptor->getInterceptionPoints() as $interceptionPoint) {
35 if (!isset($this->interceptors[$interceptionPoint])) {
36 $this->interceptors[$interceptionPoint] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
37 }
38 if (!$this->interceptors[$interceptionPoint]->contains($interceptor)) {
39 $this->interceptors[$interceptionPoint]->attach($interceptor);
40 }
41 }
42 }
43
44 /**
45 * Returns all interceptors for a given Interception Point.
46 *
47 * @param integer $interceptionPoint one of the \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_* constants,
48 * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface>
49 */
50 public function getInterceptors($interceptionPoint) {
51 if (isset($this->interceptors[$interceptionPoint]) && $this->interceptors[$interceptionPoint] instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage) {
52 return $this->interceptors[$interceptionPoint];
53 }
54 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
55 }
56 }
57
58 ?>