本文整理汇总了PHP中herosphp\core\Loader::import方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::import方法的具体用法?PHP Loader::import怎么用?PHP Loader::import使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类herosphp\core\Loader
的用法示例。
在下文中一共展示了Loader::import方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDB
/**
* 创建数据库连接实例
* @param int $accessType 连接方式(连接单个服务器还是连接集群)
* @param array $config 数据库的配置信息
* @return Idb
*/
public static function createDB($accessType = DB_ACCESS_SINGLE, &$config = null)
{
//获取包含路径
$classPath = self::$DB_DRIVER[$accessType]['path'];
Loader::import($classPath, IMPORT_FRAME);
$className = self::$DB_DRIVER[$accessType]['class'];
$key = md5($className . $config['flag']);
if (!isset(self::$DB_POOL[$key])) {
self::$DB_POOL[$key] = new $className($config);
}
return self::$DB_POOL[$key];
}
示例2: create
/**
* 创建缓存
* @param $key
* @param bool $single 是否单例模式
* @return \herosphp\cache\interfaces\ICache
*/
public static function create($key = 'file', $single = true)
{
//如果缓存对象已经创建,则则直接返回
if (isset(self::$CACHE_SET[$key]) && $single == false) {
return self::$CACHE_SET[$key];
}
$configs = Loader::config($key, 'cache');
$className = self::$CACHE_BEAN[$key]['class'];
Loader::import(self::$CACHE_BEAN[$key]['path'], IMPORT_FRAME);
if ($single) {
self::$CACHE_SET[$key] = new $className($configs);
return self::$CACHE_SET[$key];
} else {
return $className($configs);
}
}
示例3: builtInstance
/**
* 创建Bean实例
* @param string $classPath 要创建的对象的类路径
* @param array $params 参数列表,可以是数组或者单个参数
* @return object|ReflectionClass
* @throws \Exception
*/
public static function builtInstance($classPath, $params = null)
{
if (!is_string($classPath)) {
return null;
}
try {
$importPath = str_replace('\\', '.', $classPath);
Loader::import($importPath, IMPORT_APP, EXT_PHP);
$instance = new ReflectionClass($classPath);
if (is_array($params)) {
return $instance->newInstanceArgs($params);
} elseif ($params) {
return $instance->newInstance($params);
} else {
return $instance->newInstance();
}
} catch (\Exception $e) {
E($e->getMessage());
}
}
示例4:
* Copyright (c) 2013-now http://blog518.com All rights reserved.
* ---------------------------------------------------------------------
* Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
* ---------------------------------------------------------------------
* Author: <yangjian102621@gmail.com>
* @version 1.2.1
*-----------------------------------------------------------------------*/
namespace herosphp\model;
use herosphp\core\Loader;
use herosphp\core\WebApplication;
use herosphp\db\DBFactory;
use herosphp\exception\UnSupportedOperationException;
use herosphp\filter\Filter;
use herosphp\string\StringUtils;
Loader::import('model.IModel', IMPORT_FRAME);
class MongoModel implements IModel
{
/**
* 数据库连接资源
* @var \herosphp\db\mongo\MongoDB
*/
private $db;
/**
* 数据表名称
* @var string
*/
private $table = '';
/**
* 数据过滤规则
* @var array
示例5: index
<?php
namespace mobile\action;
use herosphp\bean\Beans;
use herosphp\core\Loader;
use herosphp\http\HttpRequest;
use herosphp\utils\AjaxResult;
use herosphp\utils\ArrayUtils;
Loader::import('mobile.action.CommonAction', IMPORT_APP);
/**
* 驼牛网M站
* @package mobile\action
*/
class IndexAction extends CommonAction
{
/**
* 首页
* @param HttpRequest $request
*/
public function index(HttpRequest $request)
{
//获取导航
$service = Beans::get('admin.chanel.service');
$chanels = $service->getItems('pid = 0', 'id,name', 'sort_num ASC');
foreach ($chanels as $key => $value) {
$chanels[$key]['url'] = url("/mobile_index_channel/?id={$value['id']}");
}
$this->assign('chanels', $chanels);
//获取推荐文章
$this->getArticlePosition('index_carousel');
示例6:
<?php
namespace admin\service;
use admin\service\interfaces\IKeywordsService;
use common\service\CommonService;
use herosphp\core\Loader;
Loader::import('admin.service.interfaces.IKeywordsService', IMPORT_APP);
Loader::import('common.service.CommonService', IMPORT_APP);
/**
* 系统保留字实现
* Class DomainService
* @package admin\service
*/
class KeywordsService extends CommonService implements IKeywordsService
{
}
示例7:
<?php
\herosphp\core\Loader::import('tasks.DataTransferTask', IMPORT_CLIENT);
$task = new \tasks\DataTransferTask();
$task->run();
示例8: __construct
<?php
/**
* 媒体管理员Model
* @author yangjian <yangjian102621@163.com>
*/
namespace models;
use herosphp\core\Loader;
use herosphp\model\C_Model;
Loader::import('filter.Filter', IMPORT_FRAME);
class MediaManagerModel extends C_Model
{
public function __construct()
{
parent::__construct('media_manager');
$this->setPrimaryKey('id');
//初始化数据模型过滤器
$filterMap = array('email' => array(DFILTER_EMAIL, array(1, 30), DFILTER_SANITIZE_TRIM, '电子邮箱'));
$this->setFilterMap($filterMap);
}
}
示例9:
<?php
namespace media\dao\interfaces;
use common\dao\interfaces\ICommonDao;
use herosphp\core\Loader;
Loader::import("common.dao.interfaces.ICommonDao", IMPORT_APP);
/**
* 媒体推荐位(DAO)接口
* Interface IMediaRecDao
* @package media\dao\interfaces
* @author yangjian102621@163.com
*/
interface IMediaRecDao extends ICommonDao
{
}
示例10:
<?php
namespace tasks;
use herosphp\utils\FileUtils;
use tasks\interfaces\ITask;
use herosphp\core\Loader;
Loader::import('tasks.interfaces.ITask', IMPORT_CLIENT);
/**
* 处理图片文件夹
* 1. 将媒体logo, 文章裁剪的缩略图替换原图
* 2. 删除缩略图缓存
* @author yangjian102621@163.com
*/
class ImageTask implements ITask
{
/**
* 要操作的目录
* @var string
*/
private static $dir = null;
/**
* 日志文件
* @var string
*/
private static $logFile = './logs/image.log';
/**
* 总共删除缩略图缓存的文件个数
* @var int
*/
private static $delNum = 0;
示例11: register
<?php
namespace test\service;
use common\service\CommonService;
use herosphp\core\Loader;
use test\service\interfaces\IUserService;
Loader::import('test.service.interfaces.IUserService', IMPORT_APP);
/**
* 用户服务实现
* Class UserService
* @package test\service
*/
class UserService extends CommonService implements IUserService
{
public function register()
{
__print("调用了 UserService::register 方法");
}
public function login()
{
__print("调用了 UserService::login 方法");
}
}
示例12: index
<?php
namespace site\action;
use herosphp\bean\Beans;
use herosphp\http\HttpRequest;
use herosphp\core\Loader;
Loader::import('site.action.CommonAction', IMPORT_APP);
/**
* 媒体服务 Action
* @author yangjian<yangjian102621@163.com>
*/
class MediaAction extends CommonAction
{
public function index(HttpRequest $request)
{
$id = $request->getParameter("id", "intval");
$url = url("/site_service_index/?id={$id}&media_id=" . $this->loginMedia['id']);
page301($url);
}
}
示例13: __construct
<?php
namespace herosphp\lock;
/*---------------------------------------------------------------------
* 同步锁,通过系统信号量加锁方式实现
* ---------------------------------------------------------------------
* Copyright (c) 2013-now http://blog518.com All rights reserved.
* ---------------------------------------------------------------------
* Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
* ---------------------------------------------------------------------
* Author: <yangjian102621@gmail.com>
*-----------------------------------------------------------------------*/
use herosphp\core\Loader;
use herosphp\lock\interfaces\ISynLock;
Loader::import('lock.interfaces.ISynLock', IMPORT_FRAME);
class SemSynLock implements ISynLock
{
private $ipc_signal = null;
//系统信号量
public function __construct($key)
{
if (!is_long($key)) {
E("传入了非法的信号量key");
}
$this->ipc_signal = sem_get($key);
}
/**
* 尝试去获取锁,成功返回false并且一直阻塞
* @throws \herosphp\exception\HeroException
*/
示例14: array
* ---------------------------------------------------------------------
* Copyright (c) 2013-now http://blog518.com All rights reserved.
* ---------------------------------------------------------------------
* Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
* ---------------------------------------------------------------------
* Author: <yangjian102621@gmail.com>
*-----------------------------------------------------------------------*/
namespace herosphp\db\mysql;
use herosphp\core\Debug;
use herosphp\core\Loader;
use herosphp\db\interfaces\Idb;
use herosphp\exception\DBException;
use PDO;
use PDOException;
Loader::import('db.interfaces.Idb', IMPORT_FRAME);
class SingleDB implements Idb
{
/**
* PDO 数据库连接实例
* @var \PDO
*/
private $link;
/**
* 数据库配置参数
* @var array
*/
private $config = array();
/**
* 事务的级数,解决事务的嵌套问题
* @var int
示例15:
<?php
namespace test\dao;
use common\dao\CommonDao;
use herosphp\core\Loader;
use test\dao\interfaces\ITestDao;
Loader::import('common.dao.CommonDao', IMPORT_APP);
Loader::import('test.dao.interfaces.ITestDao', IMPORT_APP);
/**
* 测试(DAO)接口的通用实现
* Class CommonDao
* @package test\dao
* @author yangjian102621@163.com
*/
class TestDao extends CommonDao implements ITestDao
{
}