public function toArray($values = true)
 {
     $array = parent::toArray($values);
     if (!empty($array['container']) && $array['container'] instanceof KDatabaseRowInterface) {
         $array['container'] = $array['container']->slug;
     }
     return $array;
 }
Пример #2
0
 public function __get($name)
 {
     if ($name == 'container' && isset($this->_data[$name]) && is_string($this->_data[$name]->value)) {
         $this->_data[$name]->value = KService::get('com://admin/files.model.containers')->slug($this->_data[$name]->value)->getItem();
     } else {
         if ($name == 'basepath') {
             return (string) (isset($this->_data['container']) ? $this->container : '');
         }
     }
     return parent::__get($name);
 }
Пример #3
0
 public function get($name, $default = null)
 {
     $result = parent::get($name, $default);
     if ($name === 'container' && is_string($result)) {
         $result = KService::get('com://admin/files.model.containers')->slug($result)->getItem();
         if (!is_object($result) || $result->isNew()) {
             throw new KModelException('Invalid container');
         }
         $this->_data['container']->value = $result;
     }
     return $result;
 }