4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Form\Tests\Fixtures
;
14 use Symfony\Component\Form\FormTypeInterface
;
15 use Symfony\Component\Form\FormTypeExtensionInterface
;
16 use Symfony\Component\Form\FormTypeGuesserInterface
;
17 use Symfony\Component\Form\FormExtensionInterface
;
19 class TestExtension
implements FormExtensionInterface
21 private $types = array();
23 private $extensions = array();
27 public function __construct(FormTypeGuesserInterface
$guesser)
29 $this->guesser
= $guesser;
32 public function addType(FormTypeInterface
$type)
34 $this->types
[$type->getName()] = $type;
37 public function getType($name)
39 return isset($this->types
[$name]) ? $this->types
[$name] : null;
42 public function hasType($name)
44 return isset($this->types
[$name]);
47 public function addTypeExtension(FormTypeExtensionInterface
$extension)
49 $type = $extension->getExtendedType();
51 if (!isset($this->extensions
[$type])) {
52 $this->extensions
[$type] = array();
55 $this->extensions
[$type][] = $extension;
58 public function getTypeExtensions($name)
60 return isset($this->extensions
[$name]) ? $this->extensions
[$name] : array();
63 public function hasTypeExtensions($name)
65 return isset($this->extensions
[$name]);
68 public function getTypeGuesser()
70 return $this->guesser
;