Beispiel #1
0
 /**
  * Load model.
  *
  * @param mixed $id
  *
  * @return $this
  */
 public function load($id)
 {
     if (!$this->persistence) {
         throw new Exception(['Model is not associated with any database']);
     }
     if ($this->loaded()) {
         $this->unload();
     }
     if ($this->hook('beforeLoad', [$id]) === false) {
         return $this;
     }
     $this->data = $this->persistence->load($this, $id);
     if (is_null($this->id)) {
         $this->id = $id;
     }
     $this->hook('afterLoad');
     return $this;
 }