33 lines
762 B
PHP
33 lines
762 B
PHP
<?php
|
|
|
|
class Model_Factory
|
|
{
|
|
static $shortcut = "model";
|
|
public $db;
|
|
public $_registry;
|
|
public $_shortcut;
|
|
|
|
public function __construct (/*.Database.*/ $db, Settings $_registry = null)
|
|
{
|
|
$this->db = $db;
|
|
$this->_registry = $_registry;
|
|
}
|
|
|
|
/**
|
|
* Создает модель
|
|
* @param string $name
|
|
* @return model
|
|
*/
|
|
public function getModel ($name)
|
|
{
|
|
require_once (Shortcut::getUrl(self::$shortcut, strtolower($name)));
|
|
$modelName = $name . "Mapper";
|
|
$model = new $modelName();
|
|
$model->db = $this->db;
|
|
$model->factory = $this;
|
|
$model->_registry = $this->_registry;
|
|
$model->setUp();
|
|
//
|
|
return $model;
|
|
}
|
|
}
|