Exemplo n.º 1
0
 public function convert($src, $dst, $filters = null, $cast = true, $strict = false, $unset = true)
 {
     if ($cast) {
         $dst = Gongo_Bean::cast($dst, $src, $strict, $unset);
     }
     $filters = is_null($filters) ? $this->options->rule : $filters;
     if (empty($filters)) {
         return $dst;
     }
     list($expanded, $fields) = $this->expandFilters($filters);
     if (!is_null($this->enable)) {
         $fields = $this->enable;
     }
     if (!is_null($this->disable)) {
         $fields = array_diff($fields, $this->disable);
     }
     foreach ($expanded as $key => $filter) {
         if (in_array($key, $fields)) {
             $current = $cast ? $dst->{$key} : $src->{$key};
             $this->options->break = false;
             foreach ($filter as $f) {
                 $this->options->unset = false;
                 $method = $f['type'];
                 $params = isset($f['params']) ? $f['params'] : null;
                 if (is_null($dst)) {
                     continue;
                 }
                 if (is_string($method)) {
                     if (in_array($method, $this->options->functions)) {
                         $current = $this->exec($method, $current, $src, $dst, $key, $params);
                     } else {
                         if (method_exists($this, $method . 'Handler')) {
                             $current = $this->{$method . 'Handler'}($current, $src, $dst, $key, $params);
                         } else {
                             if (method_exists($this, $method)) {
                                 $current = $this->exec(array($this, $method), $current, $src, $dst, $key, $params);
                             }
                         }
                     }
                 } else {
                     if (is_callable($method)) {
                         $current = call_user_func($method, $current, $src, $dst, $key, $params);
                     }
                 }
                 if ($this->options->break) {
                     break;
                 }
             }
         }
         if (!$this->options->unset) {
             $dst->{$key} = $current;
         }
     }
     return $dst;
 }
Exemplo n.º 2
0
 function setPagingParams($app, $sessionName, $reset = false)
 {
     $currentSession = $app->session->{$sessionName};
     if (!$reset && $currentSession) {
         Gongo_Bean::cast($this, $currentSession);
     }
     foreach ($this->paramNames as $k => $v) {
         $this->setPagingParam($app, $v, $k);
     }
     $app->session->{$sessionName} = $this;
     return $this;
 }
Exemplo n.º 3
0
Arquivo: Form.php Projeto: no22/gongo
 function exportForm($app, $mapper, $bean = null, $converter = null)
 {
     $bean = $bean ? $bean : $mapper->emptyBean();
     if (!is_null($converter)) {
         $form = $converter->export($this, $bean);
     } else {
         if (!is_null($mapper) && $mapper->__converter) {
             $bean = $mapper->converter->export($this, $bean);
         } else {
             $bean = Gongo_Bean::cast($bean, $this, false, true);
         }
     }
     return $bean;
 }
Exemplo n.º 4
0
 function newBean($data, $bean = null)
 {
     $bean = is_null($bean) ? $this->emptyBean() : $bean;
     if ($data instanceof Gongo_Bean) {
         $data = $data->_();
     } else {
         $data = (array) $data;
     }
     $bean = Gongo_Bean::cast($bean, $data);
     return $bean;
 }
Exemplo n.º 5
0
Arquivo: core.php Projeto: no22/gongo
 function __construct($cfg = array())
 {
     $cfg = is_string($cfg) ? parse_ini_file($cfg, true) : $cfg;
     parent::__construct($cfg);
 }
Exemplo n.º 6
0
 function _config()
 {
     $base = $this->configDefault;
     $config = $this->devMode ? $this->configDevelopment : $this->configProduction;
     return Gongo_Bean::mergeRecursive($base, $config);
 }