本文整理汇总了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('安装成功'));
}
示例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__);
}
示例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';
}
示例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('验证失败')));
}
}
示例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);
示例6: testGetFactory
/**
* @covers Xoops\Core\Handler\FactorySpec::getFactory
*/
public function testGetFactory()
{
$factory = Factory::getInstance();
$this->assertSame($factory, $this->object->getFactory());
}
示例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();
}
}
示例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('操作失败')));
}
}
示例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');
}
示例10: testGetInstance
function testGetInstance()
{
$instance = Factory::getInstance();
self::assertInstanceOf('Hirak\\Prestissimo\\Factory', $instance);
}
示例11: getUserInfo
public function getUserInfo()
{
$uid = (int) $_REQUEST['uid'];
return Factory::getInstance('user')->getUserInfo($uid);
}
示例12: __construct
public function __construct()
{
$this->request = Factory::getInstance(\App\Lib\Api\GooglePlace\Request::class);
}
示例13: person
public function person()
{
$userinfo = Factory::getInstance('user')->getUserInfo($_REQUEST['uid']);
include VIEW_PATH . 'person.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();
}
示例15: i
/**
* @see Factory::getInstance
*/
public static function i($class, $params = array(), $superclass = NULL)
{
return Factory::getInstance($class, $params, $superclass);
}