当前位置: 首页>>代码示例>>PHP>>正文


PHP Annotation\AnnotationBuilder类代码示例

本文整理汇总了PHP中Zend\Form\Annotation\AnnotationBuilder的典型用法代码示例。如果您正苦于以下问题:PHP AnnotationBuilder类的具体用法?PHP AnnotationBuilder怎么用?PHP AnnotationBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AnnotationBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getForm

 protected function getForm()
 {
     $builder = new AnnotationBuilder();
     $entity = new TestEntity();
     $form = $builder->createForm($entity);
     return $form;
 }
开发者ID:MooonWeb,项目名称:TestAjax,代码行数:7,代码来源:SkeletonController.php

示例2: authenticateAction

 public function authenticateAction()
 {
     $user = new Forms\Login();
     $builder = new AnnotationBuilder();
     $form = $builder->createForm($user);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $user = $request->getPost('username');
             $pass = $request->getPost('password');
             $redir = urldecode($this->params()->fromQuery('redir'));
             $authService = $this->getAuthService();
             $authService->setIdentity($user);
             $authService->setCredential($pass);
             $result = $authService->authenticate();
             /* $d = new \Zend\Debug\Debug();
                $d->dump($result);
                die; */
             foreach ($result->getMessages() as $message) {
                 //save message temporary into flashmessenger
                 $this->flashmessenger()->addMessage($message);
             }
             $conf = $this->getServiceLocator()->get('IdAuth\\Config');
             if ($conf['settings']['usePrevPageRedir']) {
                 return $this->redirect()->toUrl($redir);
             } else {
                 return $this->redirect()->toRoute('idAuth');
             }
         }
     }
     return $this->redirect()->toRoute('idAuth/login');
 }
开发者ID:neuweb,项目名称:idauth,代码行数:33,代码来源:UserController.php

示例3: indexAction

 /**
  * The default action - show the home page
  */
 public function indexAction()
 {
     // init vars
     $data = NULL;
     $table = $this->getServiceLocator()->get('city-codes-table');
     $catList = $this->getServiceLocator()->get('form-demo-categories');
     $cityList = $table->getAllCityCodesForForm();
     $countryList = $table->getAllCountryCodesForForm();
     // submit button
     $submit = new Submit('submit');
     $submit->setAttribute('value', 'Submit');
     // build form
     $builder = new AnnotationBuilder();
     $entity = $this->getServiceLocator()->get('form-demo-listings-entity');
     $form = $builder->createForm($entity);
     $form->get('category')->setValueOptions(array_combine($catList, $catList));
     $form->getInputFilter()->get('category')->getValidatorChain()->attachByName('InArray', array('haystack' => $catList));
     $form->get('country')->setValueOptions($countryList);
     $form->getInputFilter()->get('country')->getValidatorChain()->attachByName('InArray', array('haystack' => $countryList));
     $form->add($submit);
     $form->bind($entity);
     if ($this->getRequest()->isPost()) {
         $form->setData($this->params()->fromPost());
         if ($form->isValid()) {
             $data = $form->getData();
         }
     }
     return new ViewModel(array('form' => $form, 'data' => $data, 'cityList' => $cityList));
 }
开发者ID:jordiwes,项目名称:zf2.unlikelysource.org,代码行数:32,代码来源:AnnotationController.php

示例4: __construct

 /**
  * @param EntityManager         $entityManager
  * @param Entity\EntityAbstract $object
  */
 public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object)
 {
     parent::__construct($object->get('underscore_entity_name'));
     $doctrineHydrator = new DoctrineHydrator($entityManager);
     $this->setHydrator($doctrineHydrator)->setObject($object);
     $builder = new AnnotationBuilder();
     /**
      * Go over the different form elements and add them to the form
      */
     foreach ($builder->createForm($object)->getElements() as $element) {
         /**
          * Go over each element to add the objectManager to the EntitySelect
          */
         if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) {
             $element->setOptions(array_merge_recursive($element->getOptions(), ['object_manager' => $entityManager]));
         }
         if ($element instanceof Radio) {
             $attributes = $element->getAttributes();
             $valueOptionsArray = 'get' . ucfirst($attributes['array']);
             $element->setOptions(array_merge_recursive($element->getOptions(), ['value_options' => $object->{$valueOptionsArray}()]));
         }
         //Add only when a type is provided
         if (array_key_exists('type', $element->getAttributes())) {
             $this->add($element);
         }
     }
 }
开发者ID:debranova,项目名称:program,代码行数:31,代码来源:ObjectFieldset.php

示例5: addAction

 public function addAction()
 {
     // The annotation builder help us create a form from the annotations in the user entity.
     $builder = new AnnotationBuilder();
     $entity = $this->serviceLocator->get('user-entity');
     $form = $builder->createForm($entity);
     $form->add(array('name' => 'password_verify', 'type' => 'Zend\\Form\\Element\\Password', 'attributes' => array('placeholder' => 'Verify Password Here...', 'required' => 'required'), 'options' => array('label' => 'Verify Password')), array('priority' => $form->get('password')->getOption('priority')));
     // This is the special code that protects our form being submitted from automated scripts
     $form->add(array('name' => 'csrf', 'type' => 'Zend\\Form\\Element\\Csrf'));
     // This is the submit button
     $form->add(array('name' => 'submit', 'type' => 'Zend\\Form\\Element\\Submit', 'attributes' => array('value' => 'Submit', 'required' => 'false')));
     // We bind the entity to the user. If the form tries to read/write data from/to the entity
     // it will use the hydrator specified in the entity to achieve this. In our case we use ClassMethods
     // hydrator which means that reading will happen calling the getter methods and writing will happen by
     // calling the setter methods.
     $form->bind($entity);
     if ($this->getRequest()->isPost()) {
         $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray());
         $form->setData($data);
         if ($form->isValid()) {
             // We use now the Doctrine 2 entity manager to save user data to the database
             $entityManager = $this->serviceLocator->get('entity-manager');
             $entityManager->persist($entity);
             $entityManager->flush();
             $this->flashmessenger()->addSuccessMessage('User was added successfully.');
             $event = new EventManager('user');
             $event->trigger('register', $this, array('user' => $entity));
             // redirect the user to the view user action
             return $this->redirect()->toRoute('user/default', array('controller' => 'account', 'action' => 'view', 'id' => $entity->getId()));
         }
     }
     // pass the data to the view for visualization
     return array('form1' => $form);
 }
开发者ID:gsokolowski,项目名称:learnzf2,代码行数:34,代码来源:AccountController.php

示例6: __construct

 /**
  * @param EntityManager $entityManager
  */
 public function __construct(EntityManager $entityManager)
 {
     parent::__construct('doa');
     $doa = new Entity\Doa();
     $doctrineHydrator = new DoctrineHydrator($entityManager, 'Affiliation\\Entity\\Doa');
     $this->setHydrator($doctrineHydrator)->setObject($doa);
     $builder = new AnnotationBuilder();
     /**
      * Go over the different form elements and add them to the form
      */
     foreach ($builder->createForm($doa)->getElements() as $element) {
         /**
          * Go over each element to add the objectManager to the EntitySelect
          */
         if ($element instanceof EntitySelect) {
             $element->setOptions(['object_manager' => $entityManager]);
         }
         //Add only when a type is provided
         if (array_key_exists('type', $element->getAttributes())) {
             $this->add($element);
         }
     }
     $this->add(['type' => '\\Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ["label" => "txt-signer"]]);
     $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => ["label" => "txt-source-file", "help-block" => _("txt-attachment-requirements")]]);
 }
开发者ID:Newman101,项目名称:affiliation,代码行数:28,代码来源:DoaFieldset.php

示例7: validateJSONAction

 /**
  * For JS AJAX validation - validates a property of Equipment object.
  * @return JSON status=ok|error,message={string}
  */
 public function validateJSONAction()
 {
     try {
         $propName = $this->params()->fromPost('propName');
         if (!in_array($propName, Equipment::propertyNames())) {
             throw new \Exception('Wrong property provided.');
         }
         $value = $this->params()->fromPost('value');
         if (!$propName || !$value) {
             throw new \Exception('No property and/or value given.');
         }
         $equipment = new Equipment();
         $builder = new AnnotationBuilder();
         $form = $builder->createForm($equipment);
         $form->setData(array($propName => $value))->isValid();
         $elements = $form->getElements();
         $element = $elements[$propName];
         if (count($element->getMessages())) {
             return $this->myJsonModel(array('status' => 'error', 'message' => $element->getMessages()));
         } else {
             return $this->myJsonModel(array('status' => 'ok', 'message' => ''));
         }
     } catch (\Exception $e) {
         // @TODO: set status to syserror so JS doesn't confuse with
         // validation error
         return $this->myJsonModel(array('status' => 'error', 'message' => $e->getMessage()));
     }
 }
开发者ID:rav990,项目名称:AplikacjaRestPhp,代码行数:32,代码来源:EquipmentsController.php

示例8: __construct

 /**
  * @param EntityManager         $entityManager
  * @param Entity\EntityAbstract $object
  */
 public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object)
 {
     parent::__construct($object->get('underscore_entity_name'));
     $doctrineHydrator = new DoctrineHydrator($entityManager);
     $this->setHydrator($doctrineHydrator)->setObject($object);
     $builder = new AnnotationBuilder();
     /**
      * Go over the different form elements and add them to the form
      */
     foreach ($builder->createForm($object)->getElements() as $element) {
         /**
          * Go over each element to add the objectManager to the EntitySelect
          */
         if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) {
             $element->setOptions(array_merge_recursive($element->getOptions(), ['object_manager' => $entityManager]));
         }
         if ($element instanceof Radio) {
             $attributes = $element->getAttributes();
             $valueOptionsArray = 'get' . ucfirst($attributes['array']);
             $element->setOptions(array_merge_recursive($element->getOptions(), ['value_options' => $object->{$valueOptionsArray}()]));
         }
         //Add only when a type is provided
         if (array_key_exists('type', $element->getAttributes())) {
             $this->add($element);
         }
     }
     $this->add(['type' => '\\Zend\\Form\\Element\\Select', 'name' => 'organisation', 'options' => ['disable_inarray_validator' => true, "label" => _("txt-organisation"), "help-block" => _("txt-organisation-help-block")]]);
     $this->add(['type' => '\\Zend\\Form\\Element\\Text', 'name' => 'branch', 'options' => ["label" => _("txt-branch"), "help-block" => _("txt-branch-help-block")]]);
 }
开发者ID:iteaoffice,项目名称:contact,代码行数:33,代码来源:ContactFieldset.php

示例9: __construct

 /**
  * @param EntityManager         $entityManager
  * @param Entity\EntityAbstract $object
  */
 public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object)
 {
     parent::__construct($object->get('underscore_entity_name'));
     $doctrineHydrator = new DoctrineHydrator($entityManager);
     $this->setHydrator($doctrineHydrator)->setObject($object);
     $builder = new AnnotationBuilder();
     /*
      * Go over the different form elements and add them to the form
      */
     foreach ($builder->createForm($object)->getElements() as $element) {
         /*
          * Go over each element to add the objectManager to the EntitySelect
          */
         if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) {
             $element->setOptions(['object_manager' => $entityManager]);
         }
         if ($element instanceof Radio) {
             $attributes = $element->getAttributes();
             $valueOptionsArray = 'get' . ucfirst($attributes['array']);
             $element->setOptions(['value_options' => $object->{$valueOptionsArray}()]);
         }
         //Add only when a type is provided
         if (array_key_exists('type', $element->getAttributes())) {
             $this->add($element);
         }
     }
     $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'attributes' => ["class" => "form-control"], 'options' => ["label" => _("txt-source-file"), "help-block" => _("txt-attachment-requirements")]]);
 }
开发者ID:debranova,项目名称:project,代码行数:32,代码来源:DocumentFieldset.php

示例10: getFeedbackForm

 /**
  * Returns constructed Feedback
  *
  * @param ServiceManager $sm ServiceManager
  *
  * @return Form
  */
 public static function getFeedbackForm(ServiceManager $sm)
 {
     $builder = new AnnotationBuilder();
     $form = $builder->createForm('\\Swissbib\\Feedback\\Form\\FeedbackForm');
     $form->add(new Csrf('security'));
     $form->add(['name' => 'submit', 'type' => 'Submit', 'attributes' => ['value' => 'feedback.form.submit']]);
     return $form;
 }
开发者ID:guenterh,项目名称:vufind,代码行数:15,代码来源:Factory.php

示例11: getForm

 public function getForm()
 {
     if (!$this->form) {
         $user = new User();
         $builder = new AnnotationBuilder();
         $this->form = $builder->createForm($user);
     }
     return $this->form;
 }
开发者ID:Gunners69400,项目名称:BACCAM_ESCALIER_ZEND_APPLICATION,代码行数:9,代码来源:AuthController.php

示例12: getForm

 private function getForm()
 {
     if (!$this->form) {
         $form = new LoginForm();
         $builder = new AnnotationBuilder();
         $this->form = $builder->createForm($form);
     }
     return $this->form;
 }
开发者ID:arnie87,项目名称:gofiliate_test,代码行数:9,代码来源:LoginController.php

示例13: getCopyForm

 /**
  * @param ServiceManager $sm
  *
  * @return Form
  */
 public static function getCopyForm(ServiceManager $sm)
 {
     AbstractValidator::setDefaultTranslator($sm->get('\\VuFind\\Translator'));
     $builder = new AnnotationBuilder();
     $form = $builder->createForm('\\Swissbib\\Record\\Form\\CopyForm');
     $form->add(new Csrf('security'));
     $form->add(['name' => 'submit', 'type' => 'Submit', 'attributes' => ['value' => 'request_copy_text']]);
     return $form;
 }
开发者ID:CUSAT,项目名称:vufind,代码行数:14,代码来源:Factory.php

示例14: __construct

 public function __construct()
 {
     $this->lastAttemptResult = LoginLogoutService::$failedLoginAttempt;
     $this->authservice = new AuthenticationService();
     $this->authservice->setStorage(new \Main\Service\UserSessionStorage());
     $user = new User();
     $builder = new AnnotationBuilder();
     $this->form = $builder->createForm($user);
 }
开发者ID:JVerstry,项目名称:Zend-2-Login-Access-Control-Demo,代码行数:9,代码来源:LoginLogoutService.php

示例15: factory

 public static function factory(PeepEntity $peep = null)
 {
     if (null === $peep) {
         $peep = __NAMESPACE__ . '\\PeepEntity';
     }
     $builder = new AnnotationBuilder();
     $form = $builder->createForm($peep);
     $form->add(new CsrfElement('secure'));
     $form->add(array('name' => 'peep', 'attributes' => array('type' => 'submit', 'value' => 'Peep!')));
     if ($peep instanceof PeepEntity) {
         $form->bind($peep);
     }
     return $form;
 }
开发者ID:vrkansagara,项目名称:PhlyPeep,代码行数:14,代码来源:PeepForm.php


注:本文中的Zend\Form\Annotation\AnnotationBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。