newInstance() public méthode

Create new model from the same base class as $this.
public newInstance ( string $class = null, array $options = [] ) : Model
$class string
$options array
Résultat Model
Exemple #1
0
 public function testCustomRef()
 {
     $a = [];
     $p = new \atk4\data\Persistence_Array($a);
     $m = new Model($p, ['table' => 'user']);
     $m->addRef('archive', function ($m) {
         return $m->newInstance(null, ['table' => $m->table . '_archive']);
     });
     $this->assertEquals('user_archive', $m->ref('archive')->table);
 }