mandator = $parameter['mandator']; } /** * Auxilary Function To Find Mandator Id * * Check if mandator id is in data array and check if valid * * @param array * @return string */ private function findMandatorId($data) { if (!is_array($data)) { return $this->mandator->getMasterId(); } if (!$this->mandator->isEnabled()) { return $this->mandator->getMasterId(); } $primary = $this->mandator->getIdentifier(); if (empty($data[$primary])) { return $this->mandator->getMasterId(); } $this->mandator->setId($data[$primary]); if (!$this->mandator->isValid()) { return $this->mandator->getMasterId(); } return $data[$primary]; } /** * Load By Data * * Find mandator id in data and load * * @param string id */ final public function loadByData($data) { return $this->loadById($this->findMandatorId($data)); } /** * Load By Id * * @param string id */ final public function loadById($id) { $this->mandator->setId($id); $this->data = $this->doLoadById($id); $key = array( $this->mandator->getIdentifier(), 'forename', 'surname', 'email', 'phone', 'address', 'customer', 'tagline', 'ceo' ); foreach ($key as $k) { if (!isset($this->data[$k])) { $this->data[$k] = ''; } } if (empty($this->data['colourem'])) { $this->data['colourem'] = '#000000'; } if (empty($this->data['colourmute'])) { $this->data['colourmite'] = '#555555'; } } /** * Actuall Load By Id * * @param string id * @return array */ protected function doLoadById($id) { return $this->mandator->get(); } /** * Get Extended Mandator Data * * @return array */ final public function get() { return $this->data; } }