當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Factory::getInstance方法代碼示例

本文整理匯總了PHP中Factory::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Factory::getInstance方法的具體用法?PHP Factory::getInstance怎麽用?PHP Factory::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Factory的用法示例。


在下文中一共展示了Factory::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: install

 public function install()
 {
     //ini_set('display_errors', 'On');
     $name = self::trimSpace($_POST['name']);
     $pwd = self::trimSpace($_POST['pwd']);
     $file = self::trimSpace($_POST['file']);
     $dbuname = self::trimSpace($_POST['dbuname']);
     $dbpwd = self::trimSpace($_POST['dbpwd']);
     $dbname = self::trimSpace($_POST['dbname']);
     $host = self::trimSpace($_POST['host']);
     $port = $_POST['port'] ? (int) $_POST['port'] : 3306;
     if (!$name || !$pwd || !$file || !$dbuname || !$dbname || !$host) {
         return Response::json(FAIL, array('數據不能為空'));
     }
     $res = mkdir($file, 0777, true);
     if (!$res && !file_exists($file)) {
         return Response::json(FAIL, array('文件存儲目錄創建失敗,請檢查對應目錄是否有寫權限後重試'));
     }
     $mysqlConf = array();
     $mysqlConf['slave'][0]['user'] = $mysqlConf['master']['user'] = $dbuname;
     $mysqlConf['slave'][0]['pwd'] = $mysqlConf['master']['pwd'] = $dbpwd;
     $mysqlConf['slave'][0]['host'] = $mysqlConf['master']['host'] = $host;
     $mysqlConf['slave'][0]['port'] = $mysqlConf['master']['port'] = $port;
     $mysqlConf['slave'][0]['dbname'] = $mysqlConf['master']['dbname'] = $dbname;
     if (!file_exists(CONFIG_PATH . 'mysql.php')) {
         $int = file_put_contents(CONFIG_PATH . 'mysql.php', '<?php return ' . var_export($mysqlConf, true) . '; ?>');
         if (!$int) {
             return Response::json(FAIL, array('conf目錄文件寫入失敗,請檢查是否有寫權限'));
         }
     }
     $cres = $this->check();
     $check = json_decode($cres, true);
     if ($check['code'] != 1) {
         return $cres;
     }
     $this->executeSql(SQL_PATH . 'opendisk.sql');
     $ures = Factory::getInstance('user')->regist($name, $pwd, 1);
     if ($ures <= 0) {
         return Response::json(FAIL, array('管理員賬號創建失敗,請重新安裝'));
     }
     $handle = fopen(CONFIG_PATH . 'install.lock', 'w');
     fclose($handle);
     $_SESSION['CLOUD_UID'] = $ures;
     setcookie('CLOUD_UID', $ures, time() + 3600 * 24);
     return Response::json(SUCC, array('安裝成功'));
 }
開發者ID:swg0110,項目名稱:iBarn,代碼行數:46,代碼來源:Install.class.php

示例2: getComponentsConfig

 /**
  * Return configuration of UI Styleguide components
  *
  * @requestParam Array  $components list of component names
  */
 public function getComponentsConfig()
 {
     wfProfileIn(__METHOD__);
     $componentNames = $this->request->getArray(self::PARAMETER_COMPONENTS, []);
     if (empty($componentNames) || $componentNames == [""]) {
         wfProfileOut(__METHOD__);
         throw new \MissingParameterApiException(self::PARAMETER_COMPONENTS);
     }
     // create the Component instances for names specified in request parameter
     $factory = Factory::getInstance();
     $dependencies = [];
     try {
         $components = $factory->init($componentNames, false, $dependencies);
         if (!is_array($components)) {
             $components = [$components];
         }
     } catch (\Exception $e) {
         wfProfileOut(__METHOD__);
         throw new \NotFoundApiException($e->getMessage());
     }
     // build the response
     $result = [];
     foreach ($components as $component) {
         $result[] = $this->getComponentConfig($component, $factory);
     }
     $this->setVal('components', $result);
     // add the dependencies to the response
     $result = [];
     foreach ($dependencies as $component) {
         // @todo - do we want to include in the dependencies the components that are already returned in the 'components' array?
         /** @var $component \Wikia\UI\Component */
         $result[$component->getName()] = $this->getComponentConfig($component, $factory);
     }
     $this->setVal('dependencies', $result);
     // set response caching
     $this->response->setCacheValidity(self::CLIENT_CACHE_VALIDITY);
     wfProfileOut(__METHOD__);
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:43,代碼來源:UIFactoryApiController.class.php

示例3: offer

 public function offer()
 {
     $curPage = max($_REQUEST['curPage'], 1);
     $perPage = $_REQUEST['perPage'] ? (int) $_REQUEST['perPage'] : 100;
     $name = $_REQUEST['search'];
     $order = $_REQUEST['order'];
     $by = $_REQUEST['by'] == 'asc' ? 'asc' : 'desc';
     $fac = Factory::getInstance();
     $userinfo = Factory::getInstance('user')->getUserInfo($_REQUEST['uid']);
     $list = $fac->getOfferList($curPage, $perPage, $name, $order, $by);
     if ($list) {
         $fileIocn = json_decode(ICON, true);
         foreach ((array) $list as $k => $v) {
             $list[$k]['pwd'] = $v['pwd'] ? 1 : 0;
             $icon = $fileIocn[pathinfo($list[$k]['name'], PATHINFO_EXTENSION)];
             if (!$list[$k]['isdir']) {
                 $list[$k]['size'] = self::formatBytes($v['size']);
                 $list[$k]['icon'] = $icon ? $icon : $fileIocn['default'];
             } else {
                 $list[$k]['size'] = 0;
                 $list[$k]['icon'] = $fileIocn['folder'];
             }
             $collecInfo = $fac->isCollect($_REQUEST['uid'], $v['id']);
             if ($collecInfo) {
                 $list[$k]['collect'] = 1;
             } else {
                 $list[$k]['collect'] = 0;
             }
         }
     }
     $num = $fac->getOfferNum($name);
     $page = ceil($num / $perPage);
     include VIEW_PATH . 'offer.php';
 }
開發者ID:im286er,項目名稱:iBarn,代碼行數:34,代碼來源:Core.class.php

示例4: pwd

 public function pwd()
 {
     $mapId = (int) $_REQUEST['mapId'];
     $pwd = $_REQUEST['pwd'];
     if (!$mapId || !$pwd) {
         echo Response::json(LACK, array(tip('參數不全')));
         exit;
     }
     if (strlen($pwd) > 8) {
         echo Response::json(FAIL, array(tip('密碼不能超過8位')));
         exit;
     }
     $res = Factory::getInstance()->pwd($mapId, $pwd);
     if ($res) {
         $_SESSION['share'][self::getClientIp() . ':' . $mapId] = 1;
         echo Response::json(SUCC, array('urlkey' => base_convert($mapId, 10, 36)));
     } else {
         echo Response::json(FAIL, array(tip('驗證失敗')));
     }
 }
開發者ID:xpchg,項目名稱:iBarn,代碼行數:20,代碼來源:Share.class.php

示例5: loadModel

			//判斷
			if(is_file("../20140913/Core/$class.class.php")){
				include_once "../20140913/Core/$class.class.php";
			}
		}

		//4.3	加載模型類
		public static function loadModel($class){
			//判斷
			if(is_file("../20140913/Model/$class.class.php")){
				include_once "../20140913/Model/$class.class.php";
			}
		}

		//將所有的自動加載方法注冊到自動加載機製中
		private static function setAutoload(){
			spl_autoload_register(array('Factory','loadCore'));
			spl_autoload_register(array('Factory','loadAction'));
			//係統會判斷當前提供的參數是一個函數(字符串)還是一個數組
			//如果是一個數組:1.找到數組的第一個參數,判斷該參數,如果參數不是一個對象,係統會認為該字符串是一個類名,所以在拚湊訪問的時候,會用範圍解析操作符去訪問第二個參數
			//Application::loadCore();
			spl_autoload_register(array('Factory','loadModel'));
		}
	}

	echo '<pre>';
	echo '<pre>';
	$first = Factory::getInstance('Captcha');
	var_dump($first);
	$second = Factory::getInstance('Captcha');
	var_dump($second);
開發者ID:uhgy,項目名稱:phppractice,代碼行數:31,代碼來源:demo02_factory_singleton.php

示例6: testGetFactory

 /**
  * @covers Xoops\Core\Handler\FactorySpec::getFactory
  */
 public function testGetFactory()
 {
     $factory = Factory::getInstance();
     $this->assertSame($factory, $this->object->getFactory());
 }
開發者ID:ming-hai,項目名稱:XoopsCore,代碼行數:8,代碼來源:FactorySpecTest.php

示例7: __construct

 /**
  * Class constructor
  *
  * Determines whether to globally enable the XSS processing
  * and whether to allow the $_GET array.
  *
  * @return	void
  */
 public function __construct()
 {
     // First load the factory so contact can be made with everything in FuzeWorks
     $this->factory = Factory::getInstance();
     $this->_allow_get_array = Config::get('routing')->allow_get_array === TRUE;
     $this->_enable_xss = Config::get('security')->global_xss_filtering === TRUE;
     $this->_enable_csrf = Config::get('security')->csrf_protection === TRUE;
     $this->_standardize_newlines = (bool) Config::get('security')->standardize_newlines;
     // Sanitize global arrays
     $this->_sanitize_globals();
     // CSRF Protection check
     if ($this->_enable_csrf === TRUE && !$this->is_cli_request()) {
         $this->factory->security->csrf_verify();
     }
 }
開發者ID:fuzeworks,項目名稱:core,代碼行數:23,代碼來源:Input.php

示例8: unCollectAll

 public function unCollectAll()
 {
     $uid = (int) $_REQUEST['uid'];
     if (!$uid) {
         echo Response::json(LACK, array(tip('參數不全')));
         exit;
     }
     $res = Factory::getInstance()->unCollectAll($uid);
     if ($res) {
         echo Response::json(SUCC, array(tip('操作成功')));
     } else {
         echo Response::json(FAIL, array(tip('操作失敗')));
     }
 }
開發者ID:jason0913,項目名稱:iBarn,代碼行數:14,代碼來源:Collection.class.php

示例9: __construct

 /**
  * Class constructor
  *
  * @param	object	&$db	Database object
  * @return	void
  */
 public function __construct(&$db)
 {
     $this->db =& $db;
     $this->factory = Factory::getInstance();
     Logger::log('Database Utility Class Initialized');
 }
開發者ID:fuzeworks,項目名稱:core,代碼行數:12,代碼來源:DB_utility.php

示例10: testGetInstance

 function testGetInstance()
 {
     $instance = Factory::getInstance();
     self::assertInstanceOf('Hirak\\Prestissimo\\Factory', $instance);
 }
開發者ID:nilopc-interesting-libs,項目名稱:prestissimo,代碼行數:5,代碼來源:FactoryTest.php

示例11: getUserInfo

 public function getUserInfo()
 {
     $uid = (int) $_REQUEST['uid'];
     return Factory::getInstance('user')->getUserInfo($uid);
 }
開發者ID:swg0110,項目名稱:iBarn,代碼行數:5,代碼來源:User.class.php

示例12: __construct

 public function __construct()
 {
     $this->request = Factory::getInstance(\App\Lib\Api\GooglePlace\Request::class);
 }
開發者ID:majchrosoft,項目名稱:bars-in-cracow,代碼行數:4,代碼來源:BuilderAbstract.php

示例13: person

 public function person()
 {
     $userinfo = Factory::getInstance('user')->getUserInfo($_REQUEST['uid']);
     include VIEW_PATH . 'person.php';
 }
開發者ID:xpchg,項目名稱:iBarn,代碼行數:5,代碼來源:User.class.php

示例14: ob_start

Tools::clean_gpc();
if (_DEBUG) {
    F::i('Benchmark')->addStep('init');
}
try {
    if (!_DEBUG) {
        ob_start();
    }
    // What the visitor want to do ?
    $action = isset($_GET['action']) && !empty($_GET['action']) ? $_GET['action'] : _DEFAULT_ACTION;
    // Initiate Cookies
    Factory::getInstance('Cookie', _COOKIE_NAME);
    // Initiate Session
    Factory::getInstance('Session');
    // Initiate Lang
    Factory::getInstance('Lang');
    // What Params ? Priority to the requested
    $params = $_GET + $_POST;
    try {
        // Control !
        $output = Controller::check($action, $params);
    } catch (FileNotFoundException $e) {
        // 404
        header('HTTP/1.1 404 File Not Found');
        exit;
    }
    F::i('Session')->close();
    $output = Tools::parseOutput($output);
    if (!_DEBUG) {
        ob_end_clean();
    }
開發者ID:Korko,項目名稱:RiskOnline,代碼行數:31,代碼來源:index.php

示例15: i

 /**
  * @see Factory::getInstance
  */
 public static function i($class, $params = array(), $superclass = NULL)
 {
     return Factory::getInstance($class, $params, $superclass);
 }
開發者ID:Korko,項目名稱:RiskOnline,代碼行數:7,代碼來源:Factory.php


注:本文中的Factory::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。