diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
commit | 46b77928f746a4231d064774b5b67fd892c7ce86 (patch) | |
tree | e3ea690b3f0def1744ddae758923cf92171ef985 /vendor/symfony/form/Symfony/Component/Form/Extension/Templating | |
parent | 68abd9c71b1d2f7bb2e9d21819584d1d15005b25 (diff) | |
download | wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.gz wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.zst wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.zip |
rm vendor
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Extension/Templating')
2 files changed, 0 insertions, 158 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php deleted file mode 100644 index 573cb518..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Templating; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractExtension; | ||
15 | use Symfony\Component\Form\FormRenderer; | ||
16 | use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface; | ||
17 | use Symfony\Component\Templating\PhpEngine; | ||
18 | use Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper; | ||
19 | |||
20 | /** | ||
21 | * Integrates the Templating component with the Form library. | ||
22 | * | ||
23 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
24 | */ | ||
25 | class TemplatingExtension extends AbstractExtension | ||
26 | { | ||
27 | public function __construct(PhpEngine $engine, CsrfProviderInterface $csrfProvider = null, array $defaultThemes = array()) | ||
28 | { | ||
29 | $engine->addHelpers(array( | ||
30 | new FormHelper(new FormRenderer(new TemplatingRendererEngine($engine, $defaultThemes), $csrfProvider)) | ||
31 | )); | ||
32 | } | ||
33 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php deleted file mode 100644 index c1dda60b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Templating; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractRendererEngine; | ||
15 | use Symfony\Component\Form\FormView; | ||
16 | use Symfony\Component\Templating\EngineInterface; | ||
17 | |||
18 | /** | ||
19 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
20 | */ | ||
21 | class TemplatingRendererEngine extends AbstractRendererEngine | ||
22 | { | ||
23 | /** | ||
24 | * @var EngineInterface | ||
25 | */ | ||
26 | private $engine; | ||
27 | |||
28 | public function __construct(EngineInterface $engine, array $defaultThemes = array()) | ||
29 | { | ||
30 | parent::__construct($defaultThemes); | ||
31 | |||
32 | $this->engine = $engine; | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * {@inheritdoc} | ||
37 | */ | ||
38 | public function renderBlock(FormView $view, $resource, $blockName, array $variables = array()) | ||
39 | { | ||
40 | return trim($this->engine->render($resource, $variables)); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * Loads the cache with the resource for a given block name. | ||
45 | * | ||
46 | * This implementation tries to load as few blocks as possible, since each block | ||
47 | * is represented by a template on the file system. | ||
48 | * | ||
49 | * @see getResourceForBlock() | ||
50 | * | ||
51 | * @param string $cacheKey The cache key of the form view. | ||
52 | * @param FormView $view The form view for finding the applying themes. | ||
53 | * @param string $blockName The name of the block to load. | ||
54 | * | ||
55 | * @return Boolean True if the resource could be loaded, false otherwise. | ||
56 | */ | ||
57 | protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName) | ||
58 | { | ||
59 | // Recursively try to find the block in the themes assigned to $view, | ||
60 | // then of its parent form, then of the parent form of the parent and so on. | ||
61 | // When the root form is reached in this recursion, also the default | ||
62 | // themes are taken into account. | ||
63 | |||
64 | // Check each theme whether it contains the searched block | ||
65 | if (isset($this->themes[$cacheKey])) { | ||
66 | for ($i = count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) { | ||
67 | if ($this->loadResourceFromTheme($cacheKey, $blockName, $this->themes[$cacheKey][$i])) { | ||
68 | return true; | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | |||
73 | // Check the default themes once we reach the root form without success | ||
74 | if (!$view->parent) { | ||
75 | for ($i = count($this->defaultThemes) - 1; $i >= 0; --$i) { | ||
76 | if ($this->loadResourceFromTheme($cacheKey, $blockName, $this->defaultThemes[$i])) { | ||
77 | return true; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | // If we did not find anything in the themes of the current view, proceed | ||
83 | // with the themes of the parent view | ||
84 | if ($view->parent) { | ||
85 | $parentCacheKey = $view->parent->vars[self::CACHE_KEY_VAR]; | ||
86 | |||
87 | if (!isset($this->resources[$parentCacheKey][$blockName])) { | ||
88 | $this->loadResourceForBlockName($parentCacheKey, $view->parent, $blockName); | ||
89 | } | ||
90 | |||
91 | // If a template exists in the parent themes, cache that template | ||
92 | // for the current theme as well to speed up further accesses | ||
93 | if ($this->resources[$parentCacheKey][$blockName]) { | ||
94 | $this->resources[$cacheKey][$blockName] = $this->resources[$parentCacheKey][$blockName]; | ||
95 | |||
96 | return true; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | // Cache that we didn't find anything to speed up further accesses | ||
101 | $this->resources[$cacheKey][$blockName] = false; | ||
102 | |||
103 | return false; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * Tries to load the resource for a block from a theme. | ||
108 | * | ||
109 | * @param string $cacheKey The cache key for storing the resource. | ||
110 | * @param string $blockName The name of the block to load a resource for. | ||
111 | * @param mixed $theme The theme to load the block from. | ||
112 | * | ||
113 | * @return Boolean True if the resource could be loaded, false otherwise. | ||
114 | */ | ||
115 | protected function loadResourceFromTheme($cacheKey, $blockName, $theme) | ||
116 | { | ||
117 | if ($this->engine->exists($templateName = $theme.':'.$blockName.'.html.php')) { | ||
118 | $this->resources[$cacheKey][$blockName] = $templateName; | ||
119 | |||
120 | return true; | ||
121 | } | ||
122 | |||
123 | return false; | ||
124 | } | ||
125 | } | ||