]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php
f9de560f031d3069ce6986eb3d736b21f65d9124
[github/wallabag/wallabag.git] / vendor / symfony / form / Symfony / Component / Form / Tests / Fixtures / TestExtension.php
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\Tests\Fixtures;
13
14 use Symfony\Component\Form\FormTypeInterface;
15 use Symfony\Component\Form\FormTypeExtensionInterface;
16 use Symfony\Component\Form\FormTypeGuesserInterface;
17 use Symfony\Component\Form\FormExtensionInterface;
18
19 class TestExtension implements FormExtensionInterface
20 {
21 private $types = array();
22
23 private $extensions = array();
24
25 private $guesser;
26
27 public function __construct(FormTypeGuesserInterface $guesser)
28 {
29 $this->guesser = $guesser;
30 }
31
32 public function addType(FormTypeInterface $type)
33 {
34 $this->types[$type->getName()] = $type;
35 }
36
37 public function getType($name)
38 {
39 return isset($this->types[$name]) ? $this->types[$name] : null;
40 }
41
42 public function hasType($name)
43 {
44 return isset($this->types[$name]);
45 }
46
47 public function addTypeExtension(FormTypeExtensionInterface $extension)
48 {
49 $type = $extension->getExtendedType();
50
51 if (!isset($this->extensions[$type])) {
52 $this->extensions[$type] = array();
53 }
54
55 $this->extensions[$type][] = $extension;
56 }
57
58 public function getTypeExtensions($name)
59 {
60 return isset($this->extensions[$name]) ? $this->extensions[$name] : array();
61 }
62
63 public function hasTypeExtensions($name)
64 {
65 return isset($this->extensions[$name]);
66 }
67
68 public function getTypeGuesser()
69 {
70 return $this->guesser;
71 }
72 }