예제 #1
0
파일: Fields.php 프로젝트: papac/framework
 /**
  * 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;
 }
예제 #2
0
파일: Event.php 프로젝트: papac/framework
 /**
  * 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);
     }
 }
예제 #3
0
파일: helper.php 프로젝트: papac/framework
 /**
  * retourne une instance de collection
  *
  * @param array $data [optional]
  * @return \Bow\Support\Collection
  */
 function collect(array $data = [])
 {
     $col = new Collection();
     foreach ($data as $key => $param) {
         $col->add($key, $param);
     }
     return $col;
 }
예제 #4
0
파일: Table.php 프로젝트: papac/framework
 /**
  * toCollection, retourne les données de la DB sous en instance de Collection
  *
  * @return Collection
  */
 public function toCollection()
 {
     $data = $this->get();
     $coll = new Collection();
     foreach ($data as $key => $value) {
         $coll->add($key, $value);
     }
     return $coll;
 }