getById() public static method

public static getById ( $id ) : null | Persona
$id
return null | Persona
Example #1
0
 /**
  * @param $id
  * @return bool
  */
 public static function isIdActive($id)
 {
     $persona = Model\Tool\Targeting\Persona::getById($id);
     if ($persona) {
         return $persona->getActive();
     }
     return false;
 }
Example #2
0
 /**
  * Loads a list of document-types for the specicifies parameters, returns an array of Document\DocType elements
  *
  * @return array
  */
 public function load()
 {
     $personasData = $this->db->fetchCol("SELECT id FROM targeting_personas" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $personas = [];
     foreach ($personasData as $personaData) {
         $personas[] = Model\Tool\Targeting\Persona::getById($personaData);
     }
     $this->model->setPersonas($personas);
     return $personas;
 }
Example #3
0
 /**
  * Checks if data is valid for current data field
  *
  * @param mixed $data
  * @param boolean $omitMandatoryCheck
  * @throws \Exception
  */
 public function checkValidity($data, $omitMandatoryCheck = false)
 {
     if (!$omitMandatoryCheck and $this->getMandatory() and empty($data)) {
         throw new \Exception("Empty mandatory field [ " . $this->getName() . " ]");
     }
     if (!empty($data)) {
         $persona = Tool\Targeting\Persona::getById($data);
         if (!$persona instanceof Tool\Targeting\Persona) {
             throw new \Exception("invalid persona reference");
         }
     }
 }
Example #4
0
 public function personaSaveAction()
 {
     $data = \Zend_Json::decode($this->getParam("data"));
     $persona = Targeting\Persona::getById($this->getParam("id"));
     $persona->setValues($data["settings"]);
     $persona->setConditions($data["conditions"]);
     $persona->save();
     $this->_helper->json(["success" => true]);
 }