35 lines
727 B
PHP
35 lines
727 B
PHP
<?php
|
|
|
|
namespace ctiso\Model;
|
|
use ctiso\Settings,
|
|
ctiso\Database;
|
|
|
|
class Factory
|
|
{
|
|
static $shortcut = "model";
|
|
public $db;
|
|
public $_registry;
|
|
|
|
public function __construct (/*.Database.*/ $db, Settings $_registry = null)
|
|
{
|
|
$this->db = $db;
|
|
$this->_registry = $_registry;
|
|
}
|
|
|
|
/**
|
|
* Создает модель
|
|
* @param string $name
|
|
* @return model
|
|
*/
|
|
public function getModel ($name)
|
|
{
|
|
$modelName = "App\\Mapper\\" . $name;
|
|
$model = new $modelName();
|
|
$model->db = $this->db;
|
|
$model->factory = $this;
|
|
$model->_registry = $this->_registry;
|
|
$model->setUp();
|
|
//
|
|
return $model;
|
|
}
|
|
}
|