Skip to content

Instantly share code, notes, and snippets.

@manuakasam
Created April 2, 2013 14:07
Show Gist options
  • Select an option

  • Save manuakasam/5292465 to your computer and use it in GitHub Desktop.

Select an option

Save manuakasam/5292465 to your computer and use it in GitHub Desktop.
ServiceFactory
<?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