setTerms() public method

Set terms - Terms of Use
public setTerms ( boolean $terms ) : Inquiry
$terms boolean
return Inquiry
コード例 #1
0
 public function objectFormAction()
 {
     $success = false;
     // getting parameters is very easy ... just call $this->getParam("yorParamKey"); regardless if's POST or GET
     if ($this->getParam("firstname") && $this->getParam("lastname") && $this->getParam("email") && $this->getParam("terms")) {
         $success = true;
         // for this example the class "person" and "inquiry" is used
         // first we create a person, then we create an inquiry object and link them together
         // check for an existing person with this name
         $person = Object\Person::getByEmail($this->getParam("email"), 1);
         if (!$person) {
             // if there isn't an existing, ... create one
             $filename = \Pimcore\File::getValidFilename($this->getParam("email"));
             // first we need to create a new object, and fill some system-related information
             $person = new Object\Person();
             $person->setParent(Object::getByPath("/crm/inquiries"));
             // we store all objects in /crm
             $person->setKey($filename);
             // the filename of the object
             $person->setPublished(true);
             // yep, it should be published :)
             // of course this needs some validation here in production...
             $person->setGender($this->getParam("gender"));
             $person->setFirstname($this->getParam("firstname"));
             $person->setLastname($this->getParam("lastname"));
             $person->setEmail($this->getParam("email"));
             $person->setDateRegister(new \DateTime());
             $person->save();
         }
         // now we create the inquiry object and link the person in it
         $inquiryFilename = \Pimcore\File::getValidFilename(date("Y-m-d") . "~" . $person->getEmail());
         $inquiry = new Object\Inquiry();
         $inquiry->setParent(Object::getByPath("/inquiries"));
         // we store all objects in /inquiries
         $inquiry->setKey($inquiryFilename);
         // the filename of the object
         $inquiry->setPublished(true);
         // yep, it should be published :)
         // now we fill in the data
         $inquiry->setMessage($this->getParam("message"));
         $inquiry->setPerson($person);
         $inquiry->setDate(new \DateTime());
         $inquiry->setTerms((bool) $this->getParam("terms"));
         $inquiry->save();
     } elseif ($this->getRequest()->isPost()) {
         $this->view->error = true;
     }
     // do some validation & assign the parameters to the view
     foreach (["firstname", "lastname", "email", "message", "terms"] as $key) {
         if ($this->getParam($key)) {
             $this->view->{$key} = htmlentities(strip_tags($this->getParam($key)));
         }
     }
     // assign the status to the view
     $this->view->success = $success;
 }