示例#1
0
 /**
  * {@inheritdoc}
  */
 public function create()
 {
     $builder = \Service::getFormFactory()->createNamedBuilder($this->getName(), 'form', null, $this->getFormOptions());
     $form = $this->build($builder)->getForm();
     if ($this->editing) {
         $this->fill($form, $this->editing);
     }
     return $form;
 }
示例#2
0
 /**
  * Find what to pass as an argument on an action
  *
  * @param ReflectionParameter $modelParameter  The model's parameter we want to investigate
  * @param ParameterBag        $routeParameters The route's parameters
  */
 protected function getObjectFromParameters($modelParameter, $routeParameters)
 {
     $refClass = $modelParameter->getClass();
     $paramName = $modelParameter->getName();
     if ($refClass !== null && $refClass->isSubclassOf("Model")) {
         // Look for the object's ID/slugs in the routeParameters array
         $model = $this->findModelInParameters($modelParameter, $routeParameters);
         if ($model !== null) {
             return $model;
         }
     }
     // $me -> currently logged in user
     if ($paramName == "me") {
         return self::getMe();
     }
     if ($refClass === null) {
         // No class provived by the method's definition, we don't know
         // what we should pass
         return null;
     }
     switch ($refClass->getName()) {
         case "Symfony\\Component\\HttpFoundation\\Request":
             return $this->getRequest();
         case "Symfony\\Component\\HttpFoundation\\Session\\Session":
             return $this->getRequest()->getSession();
         case "Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBag":
             return $this->getRequest()->getSession()->getFlashBag();
         case "Monolog\\Logger":
             return $this->getLogger();
         case "Symfony\\Component\\Form\\FormFactory":
             return Service::getFormFactory();
     }
     return null;
 }
示例#3
0
 /**
  * {@inheritDoc}
  */
 public function create()
 {
     $builder = \Service::getFormFactory()->createNamedBuilder('confirm_form');
     return $builder->add($this->action, 'submit')->add($this->action == 'Yes' ? 'No' : 'Cancel', 'submit')->add('original_url', 'hidden', array('data' => $this->originalUrl))->getForm();
 }