Created
April 7, 2015 15:30
-
-
Save Saeven/7801acf25c95ab1bfdb5 to your computer and use it in GitHub Desktop.
Form object
This file contains 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
/** | |
* Class UserFormFactory | |
* @package CirclicalUser\Factory\Form | |
*/ | |
class UserFormFactory implements FactoryInterface, MutableCreationOptionsInterface | |
{ | |
/** | |
* @var array | |
*/ | |
protected $options; | |
/** | |
* Set creation options | |
* | |
* @param array $options | |
* @return void | |
*/ | |
public function setCreationOptions( array $options ) | |
{ | |
$this->options = $options; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function createService(ServiceLocatorInterface $serviceLocator) | |
{ | |
/** | |
* @var \Zend\Form\FormElementManager $serviceLocator | |
* @var \Zend\ServiceManager\ServiceManager $serviceManager | |
*/ | |
$serviceManager = $serviceLocator->getServiceLocator(); | |
try | |
{ | |
$form = new UserForm( 'user' ); | |
$form->setHydrator(new ClassMethods()); | |
$form->setInputFilter( | |
$serviceManager->get('InputFilterManager')->get( UserInputFilter::class, $this->options ) | |
); | |
$form->setObject(new User()); | |
} | |
catch( \Exception $x ){ | |
die( $x->getMessage() ); | |
} | |
return $form; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment