Exemple #1
0
 /**
  * addField
  *
  * @param string $method
  * @param string $field
  * @param string $data
  * @throws ModelException
  * @return Fields
  */
 private function addField($method, $field, $data)
 {
     $method = strtolower($method);
     if (!$this->fields->has($method)) {
         $this->fields->add($method, new Collection());
     }
     if (!is_array($this->dataBind)) {
         $this->dataBind = [];
     }
     $bind = ['field' => $field, 'type' => $method, 'size' => isset($data['size']) ? $data['size'] : 0, 'auto' => false];
     if ($this->getAutoincrement() !== false) {
         if ($this->getAutoincrement()->field == $field) {
             $bind['auto'] = true;
         }
     }
     if ($method == 'enum') {
         $bind['default'] = $data['default'] != null ? $data['default'] : $data['value'][0];
     }
     $this->dataBind[$field] = $bind;
     if ($this->fields->get($method)->has($field)) {
         return $this;
     }
     // default index are at false
     $data['primary'] = false;
     $data['unique'] = false;
     $data['indexe'] = false;
     $this->fields->get($method)->add($field, $data);
     $this->lastField = (object) ['method' => $method, 'field' => $field];
     return $this;
 }
Exemple #2
0
 /**
  * off supprime un event enregistre
  *
  * @param string $event
  * @param Callable $cb
  */
 public static function off($event, $cb = null)
 {
     if (static::$events->has($event)) {
         static::$events->delete($event);
         Util::launchCallback($cb);
     }
 }