/** * Validate element value * * @param array $data * @param mixed $context * @return boolean */ public function isValid($value, $context = array()) { if (empty($value)) { return true; } if (!isset($context)) { $this->_error(self::INVALID_SIM); return false; } $sim = new Application\Model\SimModel($context); if (!$sim->getCustomer()) { $this->_error(self::INVALID_CUSTOMER); return false; } $apns = $sim->getCustomer()->getApnList(); if (!in_array($value, array_keys($apns))) { $this->_error(self::APN_NOT_IN_CUSTOMER, $value); return false; } return true; }
/** * Validate element value * * @param array $data * @param mixed $context * @return boolean */ public function isValid($value, $context = array()) { $arrayValidator = new App_Validate_Array(array('validators' => array('SimApn' => array('breakChainOnFailure' => true)))); if (!$arrayValidator->isValid($value, $context)) { $this->_messages = $arrayValidator->getMessages(); return false; } $sim = new Application\Model\SimModel($context); $apns = $sim->getCustomer()->getApnList(); $staticApns = array_keys($apns, true); $commonApns = array_intersect($value, $staticApns); if (count($commonApns) > 1) { $this->_error(self::TOO_MANY_STATIC_ADDRESSIN_APNS); return false; } return true; }