当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::singleton方法代码示例

本文整理汇总了PHP中Config::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::singleton方法的具体用法?PHP Config::singleton怎么用?PHP Config::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Config的用法示例。


在下文中一共展示了Config::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 public function show($name, $vars = array())
 {
     //$name es el nombre de nuestra plantilla, por ej, listado.php
     //$vars es el contenedor de nuestras variables, es un arreglo del tipo llave => valor, opcional.
     //Traemos una instancia de nuestra clase de configuracion.
     $config = Config::singleton();
     //Armamos la ruta a la plantilla
     $path = dirname(__FILE__) . '/../views/' . $name;
     //Si no existe el fichero en cuestion, mostramos un 404
     if (file_exists($path) == false) {
         trigger_error('Template `' . $path . '` does not exist.', E_USER_NOTICE);
         return false;
     }
     //Si hay variables para asignar, las pasamos una a una.
     if (is_array($vars)) {
         foreach ($vars as $key => $value) {
             $key = $value;
         }
     }
     require_once 'helpers.class.php';
     $helper = new Helpers();
     //incluimos la cabecera
     include dirname(__FILE__) . '/../views/templates/header.php';
     //Finalmente, incluimos la plantilla.
     include $path;
     //incluimos el footer
     include dirname(__FILE__) . '/../views/templates/footer.php';
 }
开发者ID:able-to-include,项目名称:email-client,代码行数:28,代码来源:view.class.php

示例2: getInstance

 public static function getInstance()
 {
     if (is_null(self::$singleton)) {
         self::$singleton = new Config();
     }
     return self::$singleton;
 }
开发者ID:MarvinMuuss,项目名称:zoopaz-radio,代码行数:7,代码来源:example.Config.php

示例3: __get

 public final function __get($index)
 {
     switch ($index) {
         case 'config':
             $this->config = Config::singleton();
             return $this->config;
         case 'cache':
             $this->cache = new Cache($this->config->read('framework/cache/driver', Cache::DISABLED), array('host' => $this->config->read('framework/cache/host', null), 'port' => $this->config->read('framework/cache/port', null)));
             return $this->cache;
         case 'sql':
             $this->config->load('db');
             $this->sql = new SQL($this->config->read('db/dsn', ''), $this->config->read('db/user', ''), $this->config->read('db/pass', ''), $this->config->read('db/pool', false));
             $this->config->unload('db');
             return $this->sql;
         case 'secure':
             $this->secure = new Secure($this->config->read('framework/secure/seed', 'sampa-framework'));
             return $this->secure;
         case 'log':
             $logfile = __SP_LOG__ . date('Ymd') . '-' . str_replace('_', '-', strtolower(get_class($this))) . '.log';
             $this->log = new Log($logfile, $this->config->read('framework/log/level', Log::DISABLED), $this->config->read('framework/log/buffered', true));
             return $this->log;
         case 'session':
             $this->session = Session::singleton($this->config);
             return $this->session;
         default:
             return null;
     }
 }
开发者ID:appdeck,项目名称:sampa,代码行数:28,代码来源:Plugin.php

示例4: __construct

 function __construct($path = null)
 {
     $this->path = $path === null ? Config::current()->plugins_dir : $path;
     $current = Config::current();
     self::$config = Config::singleton($this->path);
     Config::setCurrent($current->path);
     parent::__construct($this->path, array('Sqlite3', 'Xml'));
 }
开发者ID:rosstuck,项目名称:PEAR2_Pyrus,代码行数:8,代码来源:PluginRegistry.php

示例5: assets

 static function assets($url)
 {
     $root = Config::singleton()->get('root') . "/assets";
     if ($url[0] == "/") {
         return $root . $url;
     } else {
         return $root . "/" . $url;
     }
 }
开发者ID:fmunoz92,项目名称:mili,代码行数:9,代码来源:Router.php

示例6: __construct

 public function __construct()
 {
     $config = Config::singleton();
     try {
         parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass'));
         parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         echo 'ERROR: ' . $e->getMessage();
     }
 }
开发者ID:jaquerinte,项目名称:abogados,代码行数:10,代码来源:SPDO.php

示例7: __construct

 public function __construct()
 {
     $config = Config::singleton();
     //        parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'),$config->get('dbuser'), $config->get('dbpass'));
     try {
         //            $pdo = new PDO("mysql:host=".$config->get('dbhost').";dbname=".$config->get('dbname').";charset=utf8", $config->get('dbuser'), $config->get('dbpass'));
         parent::__construct('mysql:host=' . $config->get('dbhost') . ';dbname=' . $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass'));
         $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         echo "Se ha producido un error al intentar conectar al servidor MySQL: " . $e->getMessage();
     }
 }
开发者ID:jlegrand88,项目名称:sigpro,代码行数:12,代码来源:SPDO.class.php

示例8: singleton

 public static function singleton()
 {
     if (self::$instance == null) {
         $config = Config::singleton();
         if ($config->get('dbname') != '' or $config->get('dbuser') != '') {
             self::$instance = new self();
         } else {
             return false;
         }
     }
     return self::$instance;
 }
开发者ID:noxss,项目名称:nx-framework,代码行数:12,代码来源:SPDO.php

示例9: build

 private function build($name, $header, $footer, $css_PATH = 'css/', $js_PATH = 'js/')
 {
     $config = Config::singleton();
     $folder = $config->get('viewsFolder_Default');
     $this->data["header_path"] = $folder . $header;
     $this->data["body_path"] = $folder . $name;
     $this->data["footer_path"] = $folder . $footer;
     //extra paths
     $this->data["base"] = $config->get('baseURL');
     $this->data["css_path"] = $folder . $css_PATH;
     $this->data["js_path"] = $folder . $js_PATH;
     $this->data["img_path"] = $config->get('imgFolder');
 }
开发者ID:noxss,项目名称:nx-framework,代码行数:13,代码来源:View.php

示例10: getEM

 static function getEM()
 {
     if (is_null(self::$em)) {
         // the connection configuration
         $dbParams = array('driver' => 'pdo_mysql', 'user' => Config::singleton()->get("dbuser"), 'password' => Config::singleton()->get("dbpass"), 'dbname' => Config::singleton()->get("dbname"), 'database_host' => Config::singleton()->get("dbhost"));
         $config = Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array("app/models"), Config::singleton()->get("debug"));
         self::$em = Doctrine\ORM\EntityManager::create($dbParams, $config);
         $emConfig = self::$em->getConfiguration();
         $emConfig->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\\Query\\Mysql\\Year');
         $emConfig->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\\Query\\Mysql\\Month');
         $emConfig->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\\Query\\Mysql\\Day');
         $emConfig->addCustomDatetimeFunction('Date', 'Date');
     }
     return self::$em;
 }
开发者ID:fmunoz92,项目名称:mili,代码行数:15,代码来源:Model.php

示例11: singleton

   public static function singleton() 
   {
      if (!isset(self::$instance)) {
      
         $backend = Config::singleton()->Backend;   
         if(!$backend)
         {
            throw new BackendNotSpecifiedException("Backend type not specified, please specify one in the config.");
         }
         
         // The backend type is supplied by the code, so we don't bother to check if the file exists 
         // (it will simply throw an error if it doesn't).
         require_once($_SERVER["DOCUMENT_ROOT"] . 'includes/framework/backends/class.'.$backend.'Backend.php');
      
         $c = $backend.'Backend';
         self::$instance = new $c;
      }

      return self::$instance;
   } 
开发者ID:nevermlnd,项目名称:Color-Keying,代码行数:20,代码来源:class.Backend.php

示例12: get

 public function get($str, $lang)
 {
     if (!array_key_exists($lang, $this->lang)) {
         $config = Config::singleton();
         if (file_exists($config->get("translateDir") . $lang . '.txt')) {
             $strings = array_map(array($this, 'splitStrings'), file($config->get("translateDir") . $lang . '.txt'));
             foreach ($strings as $k => $v) {
                 $this->lang[$lang][$v[0]] = $v[1];
             }
             if (isset($this->lang[$lang])) {
                 return $this->findString($str, $lang);
             } else {
                 return $str;
             }
         } else {
             return $str;
         }
     } else {
         return $this->findString($str, $lang);
     }
 }
开发者ID:fmunoz92,项目名称:mili,代码行数:21,代码来源:Translator.php

示例13: return_html

 function return_html($template)
 {
     header('Content-Type: text/html');
     $smarty = new Smarty();
     $config = Config::singleton();
     $root = $config->get('rootAbsolute') . "/app/views/";
     /* Set config */
     $smarty->template_dir = $root;
     $smarty->compile_dir = $root . 'templates_c/';
     $smarty->config_dir = $root . 'configs/';
     $smarty->cache_dir = $root . 'cache/';
     $smarty->plugins_dir = $root . 'customplugins/';
     /* Assign smarty vars */
     foreach ($this->data as $name => $value) {
         $smarty->assign($name, $value);
     }
     $smarty->display($template);
     /* Clean data */
     $this->data = array();
     exit;
 }
开发者ID:fmunoz92,项目名称:mili,代码行数:21,代码来源:Controller.php

示例14: show

 public function show($name, $vars = array(), $include_menu = true)
 {
     //$name es el nombre de nuestra plantilla, por ej, listado.php
     //$vars es el contenedor de nuestras variables, es un arreglo del tipo llave => valor, opcional.
     //Traemos una instancia de nuestra clase de configuracion.
     $config = Config::singleton();
     //Armamos la ruta a la plantilla
     $path = $config->get('viewsFolder') . $name;
     //Si no existe el fichero en cuestion, tiramos un 404
     if (file_exists($path) == false) {
         trigger_error('Template `' . $path . '` does not exist.', E_USER_NOTICE);
         return false;
     }
     //Si hay variables para asignar, las pasamos una a una.
     if (is_array($vars)) {
         foreach ($vars as $key => $value) {
             ${$key} = $value;
         }
     }
     include $path;
 }
开发者ID:b4du3l,项目名称:startmvc,代码行数:21,代码来源:View.php

示例15: newshow

 public function newshow($name, $vars = array())
 {
     $config = Config::singleton();
     $path = VIEWS . $name . ".phtml";
     if (file_exists($path) == false) {
         trigger_error('PLantilla ' . $path . ' NO EXISTE.', E_USER_NOTICE);
         return false;
     }
     if (is_array($vars)) {
         foreach ($vars as $key => $value) {
             ${$key} = $value;
         }
     }
     $default = "views/plantillas/celestium.php";
     if (isset($this->template) && !empty($this->template)) {
         $rutap = "views/plantillas/" . $this->template . ".phtml";
         if (is_file($rutap)) {
             include $rutap;
         }
     } else {
         include $default;
     }
 }
开发者ID:luigiguerreros,项目名称:erp,代码行数:23,代码来源:View.php


注:本文中的Config::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。