Exemplo n.º 1
0
 /**
  * View Companies by user
  * 
  * @author Hrayr Shahbazyan
  * @param integer $userId
  * @return array
  */
 public function viewCompanyByUser($userId)
 {
     //polupate the data
     $data = array();
     $data['user_id'] = $userId;
     //Input filters
     $inputFilter = new \Company\InputFilter\Company();
     $customFilter = $inputFilter->viewCompaniesByUser($this->getUsersRepo());
     $inputFilter->setInputFilter($customFilter);
     $filter = $inputFilter->getInputFilter();
     $filter->setData($data);
     if ($filter->isValid()) {
         return $this->getCompaniesInArrayByUser($userId);
     } else {
         return $this->getErrorMessages($filter);
     }
 }
 /**
  * Get Invitations by code
  *
  * @author Hrayr Shahbazyan
  * @param string $code
  * @return mixed
  */
 public function viewInvitationsByCode($code)
 {
     //polupate the data
     $data = array();
     //Input filters
     $inputFilter = new \Company\InputFilter\Company();
     $customFilter = $inputFilter->viewCompany($this->getCompanyRepo());
     $inputFilter->setInputFilter($customFilter);
     $filter = $inputFilter->getInputFilter();
     $filter->setData($data);
     if ($filter->isValid()) {
         $invitations = array();
         $invitationsByCompany = $this->getInvitationRepo()->findBy(array('code' => $code));
         if (!is_null($invitationsByCompany)) {
             foreach ($invitationsByCompany as $invitation) {
                 $invitations[] = $invitation->getArrayCopy();
             }
         }
         $result = array();
         $result['status_code'] = 201;
         $result['invitations'] = $invitations;
         return $result;
     } else {
         return $this->getErrorMessages($filter);
     }
 }