1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39:
<?php
/**
* Class Model acts as a stepping stone (or "intermediate agent") between the user-defined code (<b>/src/models/</b>)
* and the system-defined code (<b>ParentModel</b>) that helps to better structure the code. See @example
* @example
* <code>
* // To avoid:
* FooController->queryProducts();
* // and
* BarController->queryProducts();
* // to be defined twice (one in each controller) or once (in ParentController, bad code practices)
* Controller->queryProducts();
* // can be defined and thus accessed from both <b>Foo</b> and <b>Bar</b> Controllers.
* </code>
*/
class Model extends \Core\ParentModel
{
/**
* @var Model The class instance.
* @internal
*/
protected static $instance;
/**
* Returns a Model instance, creating it if it did not exist.
* @return Model
*/
public static function singleton()
{
if (!self::$instance) {
$v = __CLASS__;
self::$instance = new $v;
}
return self::$instance;
}
}