$instances
$instances :
<?php
/**
* // +----------------------------------------------------------------------
* // | phpMore [ WE CAN DO IT MORE ]
* // +----------------------------------------------------------------------
* // | Copyright (c) 20011~2019 广州务商网络科技有限公司 All rights reserved.
* // +----------------------------------------------------------------------
* // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
* // +----------------------------------------------------------------------
* // | Author: sujunli <4297088@qq.com>
* // +----------------------------------------------------------------------
*/
/**
* Context是核心容器,管理着大量对象
*
*
*/
namespace cn\gz53\framework\core;
class Context
{
private $instances = [];
private $_responseCallback;
public function __construct(){
$this->put(__CLASS__, $this);
}
public static function instance(){
return new self();
}
public function get($key){
return isset($this->instances[$key]) ? $this->instances[$key] : null;
}
public function put($key, $val){
$this->instances[$key] = $val;
}
public function getCoreCallback(){
return $this->_responseCallback;
}
public function setCoreCallback(callable $responseCallback){
$this->_responseCallback = $responseCallback;
}
}