示例#1
0
 /**
  * check if field should be validated
  *
  * @param $field
  * @param $fieldSettings
  * @return bool
  */
 protected function shouldValidateField($field, $fieldSettings)
 {
     if (!parent::shouldValidateField($field, $fieldSettings)) {
         return false;
     }
     $depends = $this->getFormDepends();
     if (isset($depends[$field])) {
         $allValid = false;
         foreach ($depends[$field] as $dependGroup) {
             $isValid = true;
             foreach ($dependGroup as $fieldDepend => $values) {
                 if (isset($values['entity'])) {
                     $allowedValues = $values['entity'];
                     $source = $this->getEntity();
                 } else {
                     $allowedValues = $values['attribute'];
                     $source = $this;
                 }
                 $value = trim($source->getData($fieldDepend));
                 if (!in_array($value, $allowedValues)) {
                     $isValid = false;
                     continue;
                 }
             }
             if ($isValid) {
                 $allValid = true;
             }
         }
         if (!$allValid) {
             return false;
         }
     }
     return true;
 }
示例#2
0
文件: Entity.php 项目: nhc/Umc_Base
 /**
  * __call magic method
  * handle the getHasAttributeType, getHasRelationType calls
  *
  * @param string $method
  * @param array $args
  * @return bool|mixed
  */
 public function __call($method, $args)
 {
     if (substr($method, 0, strlen('getHasAttributeTypeRequired')) == 'getHasAttributeTypeRequired') {
         $key = $this->_underscore(substr($method, strlen('getHasAttributeTypeRequired')));
         return $this->getHasAttributeTypeRequired($key);
     }
     if (substr($method, 0, strlen('getHasAttributeType')) == 'getHasAttributeType') {
         $key = $this->_underscore(substr($method, strlen('getHasAttributeType')));
         return $this->getHasAttributeType($key);
     }
     if (substr($method, 0, strlen('getHasRelationType')) == 'getHasRelationType') {
         $key = $this->_underscore(substr($method, strlen('getHasRelationType')));
         return $this->hasRelationType($key);
     }
     return parent::__call($method, $args);
 }
示例#3
0
 /**
  * get the form name
  *
  * @return mixed
  */
 public function getFormName()
 {
     return $this->model->getEntityCode();
 }
示例#4
0
 public function generateParentConstructExtraParams(AbstractModel $model)
 {
     $this->parentConstructExtraParams = '';
     if (isset($this->config['parent_construct_extra'])) {
         $this->parentConstructExtraParams = $model->filterContent($this->config['parent_construct_extra']);
     }
     return $this;
 }
示例#5
0
 /**
  * filter content
  *
  * @param $content
  * @return string
  */
 public function filterContent($content)
 {
     return $this->model->filterContent($content);
 }
示例#6
0
文件: Module.php 项目: nhc/Umc_Base
 /**
  * __call magic method
  * handle getEntityFlag and getHasAttributeType calls
  *
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (substr($method, 0, strlen('getEntityFlag')) == 'getEntityFlag') {
         $key = $this->_underscore(substr($method, strlen('getEntityFlag')));
         return $this->getEntityFlag($key);
     }
     if (substr($method, 0, strlen('getHasAttributeType')) == 'getHasAttributeType') {
         $key = $this->_underscore(substr($method, 0, 3));
         return $this->getEntityFlag($key);
     }
     return parent::__call($method, $args);
 }
示例#7
0
 /**
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (substr($method, 0, strlen('getE1')) == 'getE1') {
         $entities = $this->getEntities();
         $key = $this->_underscore(substr($method, strlen('getE1')));
         return $entities[0]->getDataUsingMethod($key);
     }
     if (substr($method, 0, strlen('getE2')) == 'getE2') {
         $entities = $this->getEntities();
         $key = $this->_underscore(substr($method, strlen('getE2')));
         return $entities[1]->getDataUsingMethod($key);
     }
     return parent::__call($method, $args);
 }