@@ -27,18 +27,18 @@ |
||
27 | 27 | // Specifying this array can also be done as constructor argument for the |
28 | 28 | // TemplatePaths class which can be passed to the View; see view_init.php. |
29 | 29 | $view->getTemplatePaths()->fillFromConfigurationArray([ |
30 | - \TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_TEMPLATEROOTPATHS => [ |
|
31 | - __DIR__ . '/Resources/Private/Templates/', |
|
32 | - __DIR__ . '/ResourceOverrides/Private/Templates/', |
|
33 | - ], |
|
34 | - \TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_LAYOUTROOTPATHS => [ |
|
35 | - __DIR__ . '/Resources/Private/Layouts/', |
|
36 | - __DIR__ . '/ResourceOverrides/Private/Layouts/', |
|
37 | - ], |
|
38 | - \TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_PARTIALROOTPATHS => [ |
|
39 | - __DIR__ . '/Resources/Private/Partials/', |
|
40 | - __DIR__ . '/ResourceOverrides/Private/Partials/', |
|
41 | - ] |
|
30 | + \TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_TEMPLATEROOTPATHS => [ |
|
31 | + __DIR__ . '/Resources/Private/Templates/', |
|
32 | + __DIR__ . '/ResourceOverrides/Private/Templates/', |
|
33 | + ], |
|
34 | + \TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_LAYOUTROOTPATHS => [ |
|
35 | + __DIR__ . '/Resources/Private/Layouts/', |
|
36 | + __DIR__ . '/ResourceOverrides/Private/Layouts/', |
|
37 | + ], |
|
38 | + \TYPO3Fluid\Fluid\View\TemplatePaths::CONFIG_PARTIALROOTPATHS => [ |
|
39 | + __DIR__ . '/Resources/Private/Partials/', |
|
40 | + __DIR__ . '/ResourceOverrides/Private/Partials/', |
|
41 | + ] |
|
42 | 42 | ]); |
43 | 43 | |
44 | 44 | $view->assign('foobar', 'This is foobar'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | if (!defined('FLUID_CACHE_DIRECTORY')) { |
13 | - define('FLUID_CACHE_DIRECTORY', __DIR__ . '/cache/'); |
|
13 | + define('FLUID_CACHE_DIRECTORY', __DIR__ . '/cache/'); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | require __DIR__ . '/include/view_init.php'; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | // We alias our only ViewHelper so we can access it using multiple names. |
20 | 20 | if (!class_exists('TYPO3Fluid\\FluidExample\\ViewHelpers\\Nested\\CustomViewHelper')) { |
21 | - class_alias('TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper', 'TYPO3Fluid\\FluidExample\\ViewHelpers\\Nested\\CustomViewHelper'); |
|
21 | + class_alias('TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper', 'TYPO3Fluid\\FluidExample\\ViewHelpers\\Nested\\CustomViewHelper'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | // Assigning the template path and filename to be rendered. Doing this overrides |
@@ -22,9 +22,9 @@ |
||
22 | 22 | $view->assign('secondSwitchValue', 'b'); |
23 | 23 | $view->assign('array', ['one', 'two', 'three']); |
24 | 24 | $view->assign('group', [ |
25 | - ['property' => 'one'], |
|
26 | - ['property' => 'one'], |
|
27 | - ['property' => 'two'] |
|
25 | + ['property' => 'one'], |
|
26 | + ['property' => 'one'], |
|
27 | + ['property' => 'two'] |
|
28 | 28 | ]); |
29 | 29 | |
30 | 30 | // Rendering the View: plain old rendering of single file, no bells and whistles. |
@@ -18,31 +18,31 @@ |
||
18 | 18 | // In this example we assign all our variables in one array. Alternative is |
19 | 19 | // to repeatedly call $view->assign('name', 'value'). |
20 | 20 | $view->assignMultiple([ |
21 | - // Casting types |
|
22 | - 'types' => [ |
|
23 | - 'csv' => 'one,two', |
|
24 | - 'aStringWithNumbers' => '132 a string', |
|
25 | - 'anArray' => ['one', 'two'], |
|
26 | - 'typeNameInteger' => 'integer' |
|
27 | - ], |
|
21 | + // Casting types |
|
22 | + 'types' => [ |
|
23 | + 'csv' => 'one,two', |
|
24 | + 'aStringWithNumbers' => '132 a string', |
|
25 | + 'anArray' => ['one', 'two'], |
|
26 | + 'typeNameInteger' => 'integer' |
|
27 | + ], |
|
28 | 28 | 'foobar' => 'string foo', |
29 | - // The variables we will use as dynamic part names: |
|
30 | - 'dynamic1' => $dynamic1, |
|
31 | - 'dynamic2' => $dynamic2, |
|
32 | - // Strings we will be accessing dynamically: |
|
33 | - 'stringwith' . $dynamic1 . 'part' => 'String using $dynamic1', |
|
34 | - 'stringwith' . $dynamic2 . 'part' => 'String using $dynamic2', |
|
35 | - // Arrays we will be accessing dynamically: |
|
36 | - 'array' => [ |
|
37 | - 'fixed' => 'Fixed key in $array[fixed]', |
|
38 | - // A numerically indexed array which we will access directly. |
|
39 | - 'numeric' => [ |
|
40 | - 'foo', |
|
41 | - 'bar' |
|
42 | - ], |
|
43 | - $dynamic1 => 'Dynamic key in $array[$dynamic1]', |
|
44 | - $dynamic2 => 'Dynamic key in $array[$dynamic2]', |
|
45 | - ], |
|
29 | + // The variables we will use as dynamic part names: |
|
30 | + 'dynamic1' => $dynamic1, |
|
31 | + 'dynamic2' => $dynamic2, |
|
32 | + // Strings we will be accessing dynamically: |
|
33 | + 'stringwith' . $dynamic1 . 'part' => 'String using $dynamic1', |
|
34 | + 'stringwith' . $dynamic2 . 'part' => 'String using $dynamic2', |
|
35 | + // Arrays we will be accessing dynamically: |
|
36 | + 'array' => [ |
|
37 | + 'fixed' => 'Fixed key in $array[fixed]', |
|
38 | + // A numerically indexed array which we will access directly. |
|
39 | + 'numeric' => [ |
|
40 | + 'foo', |
|
41 | + 'bar' |
|
42 | + ], |
|
43 | + $dynamic1 => 'Dynamic key in $array[$dynamic1]', |
|
44 | + $dynamic2 => 'Dynamic key in $array[$dynamic2]', |
|
45 | + ], |
|
46 | 46 | '123numericprefix' => 'Numeric prefixed variable' |
47 | 47 | ]); |
48 | 48 |
@@ -18,37 +18,37 @@ |
||
18 | 18 | */ |
19 | 19 | class CustomVariableProvider extends StandardVariableProvider implements VariableProviderInterface { |
20 | 20 | |
21 | - /** |
|
22 | - * @var integer |
|
23 | - */ |
|
24 | - protected $incrementer = 0; |
|
21 | + /** |
|
22 | + * @var integer |
|
23 | + */ |
|
24 | + protected $incrementer = 0; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Get a variable by dotted path expression, retrieving the |
|
28 | - * variable from nested arrays/objects one segment at a time. |
|
29 | - * If the second variable is passed, it is expected to contain |
|
30 | - * extraction method names (constants from VariableExtractor) |
|
31 | - * which indicate how each value is extracted. |
|
32 | - * |
|
33 | - * @param string $path |
|
34 | - * @return mixed |
|
35 | - */ |
|
36 | - public function getByPath($path, array $accessors = []) { |
|
37 | - if ($path === 'random') { |
|
38 | - return 'random' . sha1(rand(0, 999999999)); |
|
39 | - } elseif ($path === 'incrementer') { |
|
40 | - return ++ $this->incrementer; |
|
41 | - } else { |
|
42 | - return parent::getByPath($path); |
|
43 | - } |
|
44 | - } |
|
26 | + /** |
|
27 | + * Get a variable by dotted path expression, retrieving the |
|
28 | + * variable from nested arrays/objects one segment at a time. |
|
29 | + * If the second variable is passed, it is expected to contain |
|
30 | + * extraction method names (constants from VariableExtractor) |
|
31 | + * which indicate how each value is extracted. |
|
32 | + * |
|
33 | + * @param string $path |
|
34 | + * @return mixed |
|
35 | + */ |
|
36 | + public function getByPath($path, array $accessors = []) { |
|
37 | + if ($path === 'random') { |
|
38 | + return 'random' . sha1(rand(0, 999999999)); |
|
39 | + } elseif ($path === 'incrementer') { |
|
40 | + return ++ $this->incrementer; |
|
41 | + } else { |
|
42 | + return parent::getByPath($path); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $identifier |
|
48 | - * @return boolean |
|
49 | - */ |
|
50 | - public function exists($identifier) { |
|
51 | - return ($identifier === 'incrementer' || $identifier === 'random' || parent::exists($identifier)); |
|
52 | - } |
|
46 | + /** |
|
47 | + * @param string $identifier |
|
48 | + * @return boolean |
|
49 | + */ |
|
50 | + public function exists($identifier) { |
|
51 | + return ($identifier === 'incrementer' || $identifier === 'random' || parent::exists($identifier)); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | if ($path === 'random') { |
38 | 38 | return 'random' . sha1(rand(0, 999999999)); |
39 | 39 | } elseif ($path === 'incrementer') { |
40 | - return ++ $this->incrementer; |
|
40 | + return ++$this->incrementer; |
|
41 | 41 | } else { |
42 | 42 | return parent::getByPath($path); |
43 | 43 | } |
@@ -20,42 +20,42 @@ |
||
20 | 20 | */ |
21 | 21 | class CustomViewHelperResolver extends ViewHelperResolver { |
22 | 22 | |
23 | - /** |
|
24 | - * Returns the built-in set of ViewHelper classes with |
|
25 | - * one addition, `f:myLink` which is redirected to anoter |
|
26 | - * class. |
|
27 | - * |
|
28 | - * @param string $namespaceIdentifier |
|
29 | - * @param string $methodIdentifier |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier) { |
|
33 | - if ($namespaceIdentifier === 'f' && $methodIdentifier === 'myLink') { |
|
34 | - return 'TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper'; |
|
35 | - } |
|
36 | - return parent::resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier); |
|
37 | - } |
|
23 | + /** |
|
24 | + * Returns the built-in set of ViewHelper classes with |
|
25 | + * one addition, `f:myLink` which is redirected to anoter |
|
26 | + * class. |
|
27 | + * |
|
28 | + * @param string $namespaceIdentifier |
|
29 | + * @param string $methodIdentifier |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier) { |
|
33 | + if ($namespaceIdentifier === 'f' && $methodIdentifier === 'myLink') { |
|
34 | + return 'TYPO3Fluid\\FluidExample\\ViewHelpers\\CustomViewHelper'; |
|
35 | + } |
|
36 | + return parent::resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Asks the ViewHelper for argument definitions and adds |
|
41 | - * a case which matches our custom ViewHelper in order to |
|
42 | - * manipulate its argument definitions. |
|
43 | - * |
|
44 | - * @param ViewHelperInterface $viewHelper |
|
45 | - * @return ArgumentDefinition[] |
|
46 | - */ |
|
47 | - public function getArgumentDefinitionsForViewHelper(ViewHelperInterface $viewHelper) { |
|
48 | - $arguments = parent::getArgumentDefinitionsForViewHelper($viewHelper); |
|
49 | - if ($viewHelper instanceof CustomViewHelper) { |
|
50 | - $arguments['page'] = new ArgumentDefinition( |
|
51 | - 'page', |
|
52 | - 'array', // our argument must now be an array |
|
53 | - 'This is our new description for the argument', |
|
54 | - FALSE, // argument is no longer mandatory |
|
55 | - ['foo' => 'bar'] // our argument has a new default value if argument is not provided |
|
56 | - ); |
|
57 | - } |
|
58 | - return $arguments; |
|
59 | - } |
|
39 | + /** |
|
40 | + * Asks the ViewHelper for argument definitions and adds |
|
41 | + * a case which matches our custom ViewHelper in order to |
|
42 | + * manipulate its argument definitions. |
|
43 | + * |
|
44 | + * @param ViewHelperInterface $viewHelper |
|
45 | + * @return ArgumentDefinition[] |
|
46 | + */ |
|
47 | + public function getArgumentDefinitionsForViewHelper(ViewHelperInterface $viewHelper) { |
|
48 | + $arguments = parent::getArgumentDefinitionsForViewHelper($viewHelper); |
|
49 | + if ($viewHelper instanceof CustomViewHelper) { |
|
50 | + $arguments['page'] = new ArgumentDefinition( |
|
51 | + 'page', |
|
52 | + 'array', // our argument must now be an array |
|
53 | + 'This is our new description for the argument', |
|
54 | + FALSE, // argument is no longer mandatory |
|
55 | + ['foo' => 'bar'] // our argument has a new default value if argument is not provided |
|
56 | + ); |
|
57 | + } |
|
58 | + return $arguments; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | $FLUID_CACHE_DIRECTORY = !isset($FLUID_CACHE_DIRECTORY) ? __DIR__ . '/../cache/' : $FLUID_CACHE_DIRECTORY; |
4 | 4 | |
5 | 5 | if (!class_exists(TYPO3Fluid\Fluid\View\TemplateView::class)) { |
6 | - foreach ([__DIR__ . '/../../vendor/autoload.php', __DIR__ . '/../../../../autoload.php'] as $possibleAutoloadLocation) { |
|
7 | - if (file_exists($possibleAutoloadLocation)) { |
|
8 | - require_once $possibleAutoloadLocation; |
|
9 | - } |
|
10 | - } |
|
6 | + foreach ([__DIR__ . '/../../vendor/autoload.php', __DIR__ . '/../../../../autoload.php'] as $possibleAutoloadLocation) { |
|
7 | + if (file_exists($possibleAutoloadLocation)) { |
|
8 | + require_once $possibleAutoloadLocation; |
|
9 | + } |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | // Initializing the View: rendering in Fluid takes place through a View instance |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | // rendering the file located in `TemplatesB` becase this folder was last |
28 | 28 | // and is checked first (think of these paths as prioritised fallbacks). |
29 | 29 | $paths->setTemplateRootPaths([ |
30 | - __DIR__ . '/../Resources/Private/Templates/' |
|
30 | + __DIR__ . '/../Resources/Private/Templates/' |
|
31 | 31 | ]); |
32 | 32 | $paths->setLayoutRootPaths([ |
33 | - __DIR__ . '/../Resources/Private/Layouts/' |
|
33 | + __DIR__ . '/../Resources/Private/Layouts/' |
|
34 | 34 | ]); |
35 | 35 | $paths->setPartialRootPaths([ |
36 | - __DIR__ . '/../Resources/Private/Partials/' |
|
36 | + __DIR__ . '/../Resources/Private/Partials/' |
|
37 | 37 | ]); |
38 | 38 | |
39 | 39 | if ($FLUID_CACHE_DIRECTORY) { |
40 | - // Configure View's caching to use ./examples/cache/ as caching directory. |
|
41 | - $view->setCache(new \TYPO3Fluid\Fluid\Core\Cache\SimpleFileCache($FLUID_CACHE_DIRECTORY)); |
|
40 | + // Configure View's caching to use ./examples/cache/ as caching directory. |
|
41 | + $view->setCache(new \TYPO3Fluid\Fluid\Core\Cache\SimpleFileCache($FLUID_CACHE_DIRECTORY)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | if (!function_exists('example_output')) { |
53 | - function example_output($content) { |
|
54 | - $content = trim($content); |
|
55 | - echo PHP_EOL . $content . PHP_EOL . PHP_EOL; |
|
56 | - echo '# Sir\'s template is rendered above ('; |
|
57 | - echo number_format(strlen($content)) . ' bytes).' . PHP_EOL; |
|
58 | - } |
|
53 | + function example_output($content) { |
|
54 | + $content = trim($content); |
|
55 | + echo PHP_EOL . $content . PHP_EOL . PHP_EOL; |
|
56 | + echo '# Sir\'s template is rendered above ('; |
|
57 | + echo number_format(strlen($content)) . ' bytes).' . PHP_EOL; |
|
58 | + } |
|
59 | 59 | } |
@@ -23,32 +23,32 @@ |
||
23 | 23 | */ |
24 | 24 | class CustomViewHelper extends AbstractViewHelper { |
25 | 25 | |
26 | - /** |
|
27 | - * @var boolean |
|
28 | - */ |
|
29 | - protected $escapeChildren = FALSE; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var boolean |
|
33 | - */ |
|
34 | - protected $escapeOutput = FALSE; |
|
35 | - |
|
36 | - /** |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function initializeArguments() { |
|
40 | - $this->registerArgument('page', 'string', 'An arbitrary page identifier', TRUE); |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function render() { |
|
47 | - return 'The following is a dump of the "page"' . PHP_EOL . |
|
48 | - 'Argument passed to CustomViewHelper:' . PHP_EOL . |
|
49 | - '---------------------------' . PHP_EOL . |
|
50 | - var_export($this->arguments['page'], TRUE) . PHP_EOL . |
|
51 | - '---------------------------'; |
|
52 | - } |
|
26 | + /** |
|
27 | + * @var boolean |
|
28 | + */ |
|
29 | + protected $escapeChildren = FALSE; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var boolean |
|
33 | + */ |
|
34 | + protected $escapeOutput = FALSE; |
|
35 | + |
|
36 | + /** |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function initializeArguments() { |
|
40 | + $this->registerArgument('page', 'string', 'An arbitrary page identifier', TRUE); |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function render() { |
|
47 | + return 'The following is a dump of the "page"' . PHP_EOL . |
|
48 | + 'Argument passed to CustomViewHelper:' . PHP_EOL . |
|
49 | + '---------------------------' . PHP_EOL . |
|
50 | + var_export($this->arguments['page'], TRUE) . PHP_EOL . |
|
51 | + '---------------------------'; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | } |