Created
April 2, 2013 14:07
-
-
Save manuakasam/5292465 to your computer and use it in GitHub Desktop.
ServiceFactory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Haushaltportal\Factory; | |
| use Haushaltportal\Form\SitesFilter; | |
| use Zend\ServiceManager\ServiceLocatorInterface; | |
| use Zend\ServiceManager\FactoryInterface; | |
| use DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity; | |
| use Haushaltportal\Form\SitesForm; | |
| use Haushaltportal\Entity\Sites; | |
| use Haushaltportal\Form\SiteFilter; | |
| use Haushaltportal\Stdlib\Hydrator\Strategy; | |
| use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator; | |
| class SitesFormFactory implements FactoryInterface | |
| { | |
| /** | |
| * Create service | |
| * | |
| * @param ServiceLocatorInterface $serviceLocator | |
| * @return \Haushaltportal\Service\SitesService | |
| */ | |
| public function createService(ServiceLocatorInterface $serviceLocator) | |
| { | |
| $em = $serviceLocator->get('Doctrine\ORM\EntityManager'); | |
| $form = new SitesForm('site', array( | |
| 'entity_manager' => $em | |
| )); | |
| $hydrator = new DoctrineEntity($em); | |
| $form->setHydrator($hydrator) | |
| ->setObject(new Sites()) | |
| ->setAttribute('method', 'post'); | |
| return $form; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment