Постарничность
This commit is contained in:
parent
f30f7546d6
commit
cc33b8f810
6 changed files with 98 additions and 3 deletions
33
src/Model/Factory.php
Normal file
33
src/Model/Factory.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue