本文整理汇总了PHP中Loader::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::getInstance方法的具体用法?PHP Loader::getInstance怎么用?PHP Loader::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// Loader initialiseren
$this->_loader = Loader::getInstance();
// input class initialiseren
$this->_input = new Input();
}
示例2: __construct
function __construct()
{
$this->titan = Loader::getInstance();
// Get config elements
$this->config = $this->titan->config('cache');
// Set configurations
$this->path = APP_DIR . $this->config['path'];
$this->extension = $this->config['extension'];
$this->default_expire_time = $this->config['default_expire_time'];
}
示例3: __construct
function __construct()
{
$this->titan = Loader::getInstance();
if (ENVIRONMENT != 'production') {
$this->config = $this->titan->config('db', 'dev');
} else {
$this->config = $this->titan->config('db');
}
require_once SYSTEM_DIR . 'plugins/Database.php';
$this->db = Database::init($this->config);
}
示例4: __construct
function __construct()
{
// Configurations for security
ini_set('session.cookie_httponly', 1);
ini_set('session.use_only_cookies', 1);
$this->titan = Loader::getInstance();
// Getting config elements
$this->config = $this->titan->config('config');
// Initialize Session
$this->init();
}
示例5: __
function __($string, $variables = NULL)
{
$filename = 'Locale/' . $_SESSION['lang' . APPKEY] . '.po';
$loader = Loader::getInstance();
$match = $loader->load($filename);
$string = htmlspecialchars($string);
$find = preg_match('/msgid "(' . $string . ')"\\nmsgstr "(.+)"/', $match, $matches);
$find = htmlspecialchars_decode($find);
if ($find) {
return vsprintf($matches[2], $variables);
} else {
return vsprintf($string, $variables);
}
}
示例6: customMapping
/**
* 自定义路由
* @param $uri
* @return bool|int|string
*/
private function customMapping($uri)
{
$mappings = Loader::getInstance()->getConfig(self::CONFIG_N_MAPPINGS, self::CONFIG_F_ROUTER);
//将url与controller进行映射
$matches = array();
foreach ($mappings as $class_name => $mapping) {
foreach ($mapping as $pattern) {
$pattern = str_replace('/', '\\/', $pattern);
if (preg_match("/{$pattern}/i", $uri, $matches)) {
Application::getInstance()->getDispatcher()->getRequest()->setRouterMatches($matches);
return $class_name;
}
}
}
return false;
}
示例7: __construct
/**
* Constructor for the core
* it loads in all configuration and interfaces
* and then continues to load all components.
* When that's done the Loader component will be loaded in an instructed
* to load the designated controller.
*/
public function __construct()
{
// Include all configurations
require_once "application/config/config.php";
require_once "application/config/database.php";
// Include all interfaces
require_once "system/interfaces/isystemcomponent.php";
require_once "system/interfaces/isystemcomponentdatacompatible.php";
require_once "system/interfaces/icontroller.php";
require_once "system/interfaces/imodel.php";
require_once "system/interfaces/itable.php";
// Include all components
$sysFiles = glob("system/components/*.php");
foreach ($sysFiles as $file) {
require_once $file;
}
/*
* If controller is not set default to
* the default controller.
* If the controller is set we use it.
*/
if (!isset($_GET["c"])) {
$_GET["c"] = DEFAULT_CONTROLLER;
}
// Check for the controller's actual file.
if (!file_exists("application/controllers/" . $_GET["c"] . ".php")) {
if (DEBUG_MODE) {
die("Couldn't find controller: " . $_GET["c"] . " :(");
}
}
// Get it.
require_once "application/controllers/" . $_GET["c"] . ".php";
// Link it, detach the GET request and add the Controller affix.
$controllerActual = $_GET["c"] . "Controller";
$_GET["c"] = null;
// Define the loader
$this->load = Loader::getInstance();
// Register the loader to the core
self::$loader = Loader::getInstance();
// Use the loader to load the controller
$this->load->controller($controllerActual);
}
示例8: lang
function lang($file = '', $key = '', $change = '')
{
global $lang;
$titan = Loader::getInstance();
$config = $titan->config('language');
if (!is_string($file) || !is_string($key)) {
return false;
}
$appLangDir = APP_DIR . 'languages/' . strtolower($config['languages'][get_lang()]) . '/' . strtolower($file) . '.php';
$sysLangDir = SYSTEM_DIR . 'languages/' . strtolower($config['languages'][get_lang()]) . '/' . strtolower($file) . '.php';
if (file_exists($appLangDir)) {
require_once $appLangDir;
} elseif (file_exists($sysLangDir)) {
require_once $sysLangDir;
}
$zone = strtolower($file);
if (array_key_exists($key, $lang[$zone])) {
$str = $lang[$zone][$key];
// Change special words
if (!is_array($change)) {
if (!empty($change)) {
return str_replace('%s', $change, $str);
} else {
return $str;
}
} else {
if (!empty($change)) {
$keys = [];
$vals = [];
foreach ($change as $key => $value) {
$keys[] = $key;
$vals[] = $value;
}
return str_replace($keys, $vals, $str);
} else {
return $str;
}
}
} else {
return false;
}
}
示例9: bootstrap
public function bootstrap()
{
$bootstrapClass = Bootstrap_Abstract::YAF_DEFAULT_BOOTSTRAP;
if (isset($this->_options['bootstrap'])) {
$bootstrap = $this->_options['bootstrap'];
} else {
$bootstrap = $this->getAppDirectory() . DIRECTORY_SEPARATOR . $bootstrapClass . '.' . G::get('ext');
}
$loader = Loader::getInstance();
if (Loader::import($bootstrap)) {
if (!class_exists($bootstrapClass)) {
throw new Exception('Couldn\'t find class Bootstrap in ' . $bootstrap);
} else {
$bootstrap = new $bootstrapClass();
if (!$bootstrap instanceof Bootstrap_Abstract) {
throw new Exception('Expect a Yaf_Bootstrap_Abstract instance, ' . get_class($bootstrap) . ' give ');
}
if (version_compare(PHP_VERSION, '5.2.6') === -1) {
$class = new \ReflectionObject($bootstrap);
$classMethods = $class->getMethods();
$methodNames = array();
foreach ($classMethods as $method) {
$methodNames[] = $method->getName();
}
} else {
$methodNames = get_class_methods($bootstrap);
}
$initMethodLength = strlen(Bootstrap_Abstract::YAF_BOOTSTRAP_INITFUNC_PREFIX);
foreach ($methodNames as $method) {
if ($initMethodLength < strlen($method) && Bootstrap_Abstract::YAF_BOOTSTRAP_INITFUNC_PREFIX === substr($method, 0, $initMethodLength)) {
$bootstrap->{$method}($this->_dispatcher);
}
}
}
} else {
throw new Exception('Couldn\'t find bootstrap file ' . $bootstrap);
}
return $this;
}
示例10: __construct
public function __construct()
{
$this->titan = Loader::getInstance();
// Getting config file
$this->config = $this->titan->config('config');
// Setting default controller and method
$this->controller = $this->config['default_controller'];
$this->method = $this->config['default_method'];
// Setting controller directory
if ($this->config['default_directory']) {
$this->directory = 'controllers/' . $this->config['default_directory'] . '/';
} else {
$this->directory = 'controllers/';
}
// Getting current URL
$this->url = $this->parseURL();
// Getting routes
$this->routes = $this->titan->config('routes');
if ($this->run() === false) {
// Getting Controller
$this->set_controller($this->url);
// Getting Method
$this->set_action($this->url);
// Getting parameters
$this->set_params($this->url);
}
// Composer Autoload
if ($this->config['composer'] == true) {
if (file_exists('vendor/autoload.php')) {
require_once 'vendor/autoload.php';
} else {
echo '<span style="color:#bc5858;"><strong>UYARI:</strong> Composer yükleyicisi bulunamadı.</span>';
}
}
call_user_func_array([$this->controller, $this->method], $this->params);
}
示例11: __construct
public function __construct()
{
$this->loader = Loader::getInstance();
}
示例12: __construct
function __construct()
{
$this->titan = Loader::getInstance();
// Getting config elements
$this->config = $this->titan->config('config');
}
示例13: initialize
protected function initialize()
{
$arrConf = Loader::getInstance()->getConfig();
if ($arrConf) {
//初始化插件列表
if (isset($arrConf['plugins'])) {
foreach ($arrConf['plugins'] as $p) {
$plugin = new $p();
$this->_dispatcher->addPlugin($plugin);
}
}
//初始化请求类
if (isset($arrConf['request_class']) && $arrConf['request_class']) {
$request = new $arrConf['request_class']();
$this->_dispatcher->setRequest($request);
}
//初始化响应类
if (isset($arrConf['response_class']) && $arrConf['response_class']) {
$response = new $arrConf['response_class']();
$this->_dispatcher->setResponse($response);
}
//初始化试图类
if (isset($arrConf['view_class']) && $arrConf['view_class']) {
$view = new $arrConf['view_class']();
$this->_dispatcher->setView($view);
}
if (isset($arrConf['enable_debug']) && $arrConf['enable_debug']) {
$this->setDebugEnabled(true);
}
}
}
示例14: getSession
/**
* @return Session
*/
public function getSession()
{
return Loader::getInstance()->get('Session');
}
示例15: dispatch
/**
* 请求分发
*/
public function dispatch()
{
if (!$this->_request) {
$this->_request = new Request();
}
if (!$this->_response) {
$this->_response = new Response();
}
if (!$this->_router) {
$this->_router = new Router();
}
if (!$this->_view) {
$this->_view = new View();
}
//router startup
$this->executePlugins(Plugin::STEP_ROUTER_STARTUP);
$class = $this->_router->mapping();
//router shutdown
$this->executePlugins(Plugin::STEP_ROUTER_SHUTDOWN);
$controller = new $class();
//dispatchloop startup
$this->executePlugins(Plugin::STEP_DISPATCH_LOOP_STARTUP);
//load current controller's interceptors
self::$_interceptors = Loader::getInstance()->loadInterceptors($class);
$this->executeInterceptor(Interceptor::INVOKE_BEFORE);
while (true) {
//preDispatch
$this->executePlugins(Plugin::STEP_DISPATCH_STARTUP);
$result = $controller->execute();
//postDispatch
$this->executePlugins(Plugin::STEP_DISPATCH_SHUTDOWN);
if ($result instanceof Controller) {
$controller = $result;
continue;
}
break;
}
if (empty($result)) {
//尝试根据controller名字自动加载视图
$result = $this->getAutoView($class);
}
if (is_string($result)) {
$this->_view->display($result);
}
$this->executeInterceptor(Interceptor::INVOKE_AFTER);
//dispatch loop shutdown
$this->executePlugins(Plugin::STEP_DISPATCH_LOOP_SHUTDOWN);
}