class Spadar_Core_Object
{
/ **
* Single class instance
*
* @staticvar Spadar_Core_Object
* /
private static $ oInstance;
...
')
/ **
* Get a single instance of a class (singleton design pattern)
*
* return Spadar_Core_Object singleton instance
* /
public static function getInstance ()
{
if (! isset (self :: $ oInstance))
{
self :: $ oInstance = new self ();
}
return self :: $ oInstance;
}
...
}
class Spadar_Core_Object
{
/ **
* Single instances of classes of heirs
*
* @staticvar array
* /
private static $ aInstances = array () ;
...
/ **
* Get a single instance of a descendant class (singleton design pattern)
*
* return Spadar_Core_Object singleton instance
* /
public static function getInstance ()
{
if (! isset ( self :: $ aInstances [__ CLASS__] ))
{
self :: $ aInstances [__ CLASS__] = new self ();
}
return self :: $ aInstances [__ CLASS__];
}
...
}
class Spadar_Controller_Widget extends Spadar_Core_Object
{
/ **
* Feeds on child widgets
*
* var array
* /
protected $ aChildWidgets = array ();
...
/ **
* Adding a child to the Widget
*
* param Spadar_Controller_Widget $ oWidget new child
* return Spadar_Controller_Widget the callee for subsequent operations
* /
public function addChild ( self $ oWidget )
{
$ this-> aChildWidgets [] = $ oWidget;
return $ this;
}
...
}
class Spadar_Core_Object
{
...
/ **
* Object recovery
*
* param string $ sInfo
* return Spadar_Core_Object called object for subsequent operations
* /
private function parseObject ($ sInfo)
{
$ mInfo = $ sInfo;
$ mInfo = @unserialize ($ sInfo);
if ( $ mInfo instanceof self )
{
return $ mInfo;
}
return $ this;
}
...
}
class Spadar_Controller_Url extends Spadar_Core_Object
{
const PARSE_PROTOCOL = 'scheme';
const PARSE_HOST = 'host';
...
const BROWSER_ARG_PROTOCOL = self :: PARSE_PROTOCOL;
/ **
* What parameter to get from urla
*
* param string $ sParam parameter for getting from URL
* return string parameter value
* /
public function getParam ($ sParam = self :: PARSE_HOST )
{
...
}
...
}
Source: https://habr.com/ru/post/15932/
All Articles