本文整理汇总了PHP中core\Config::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::get方法的具体用法?PHP Config::get怎么用?PHP Config::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core\Config
的用法示例。
在下文中一共展示了Config::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$this->_template = 'CatalogItemsWithoutFilter';
$page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
// Seo
$this->_seo['h1'] = 'Поиск';
$this->_seo['title'] = 'Поиск';
$this->_seo['keywords'] = 'Поиск';
$this->_seo['description'] = 'Поиск';
$this->setBreadcrumbs('Поиск');
// Check query
$query = Arr::get($_GET, 'query');
if (!$query) {
return $this->_content = $this->noResults();
}
// Get count items per page
$limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : conf::get('limit');
// Get sort type
$sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
$type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
// Get items list
$result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit, ($page - 1) * $limit)->as_object()->execute();
// Check for empty list
if (!count($result)) {
return $this->_content = $this->noResults();
}
// Count of parent groups
$count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->as_object()->execute()->current()->count;
// Generate pagination
$pager = Pager::factory($page, $count, $limit)->create();
// Render page
$this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
}
示例2: innerAction
public function innerAction()
{
$this->_template = 'CatalogItemsWithoutFilter';
$page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
// Check for existance
$brand = DB::select()->from('brands')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current();
if (!$brand) {
return Config::error();
}
// Seo
$this->_seo['h1'] = $brand->h1;
$this->_seo['title'] = $brand->title;
$this->_seo['keywords'] = $brand->keywords;
$this->_seo['description'] = $brand->description;
$this->setBreadcrumbs($brand->name);
// Get count items per page
$limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit');
// Get sort type
$sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
$type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
// Get popular items
$result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->where('catalog.brand_id', '=', $brand->id)->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit)->offset(($page - 1) * $limit)->as_object()->execute();
// Set description of the brand to show it above the sort part
Config::set('brand_description', View::tpl(array('brand' => $brand), 'Brands/Inner'));
// Count of parent groups
$count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->where('brand_id', '=', $brand->id)->where('status', '=', 1)->as_object()->execute()->current()->count;
// Generate pagination
$pager = Pager::factory($page, $count, $limit)->create();
// Render template
$this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
}
示例3: config
function config($name, $value = null)
{
if (!$value) {
return Config::get($name);
}
Config::set($name, $value);
}
示例4: __construct
public function __construct($data)
{
if (isset($data)) {
$this->_data = $data;
}
$this->_db = Database::getInstance(Config::get('mysql/host'), Config::get('mysql/db'), Config::get('mysql/user'), Config::get('mysql/pass'));
}
示例5: sendMail
public static function sendMail($data)
{
$transport = Swift_SmtpTransport::newInstance(Config::get('smtp.server'), Config::get('smtp.port'))->setUsername(Config::get('smtp.username'))->setPassword(Config::get('smtp.password'));
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($data['subject'])->setFrom([Config::get('smtp.username') => Config::get('framework.title')])->setTo([$data['to']])->setContentType('text/html')->setBody($data['text']);
return $mailer->send($message);
}
示例6: render
/**
* Make a URL that links to a controller/action/variables.
*
* By default we do not use the URL variables, but you can chose to do so.
*
* <code>
* array(
* 'controller' => 'Index',
* 'action' => 'Index',
* 'variables' => array(
* 'foo' => 'bar',
* 'bar' => 'foobar'
* )
* 'variable_retain' => false
* )
* </code>
*
* @access public
* @param array $param Parameters used to build the URL.
* @return string
*/
public function render($param = array())
{
// Set some defaults
$defaults = array('controller' => $this->controller, 'action' => '', 'variables' => isset($param['variable_retain']) && $param['variable_retain'] ? $_GET : array(), 'variable_retain' => false);
// However, we do not want the controller/action in the variable list
unset($defaults['variables']['controller'], $defaults['variables']['action']);
// Merge these in with the parameters
// Parameters will take precedence
$param = array_merge($defaults, $param);
// Start to build URL
// The controller
$url = Core\Config::get('path', 'root') . $param['controller'] . '/' . $param['action'];
// Any variables
if ($param['variables']) {
// Yes, there are variables to append, loop over them
foreach ($param['variables'] as $variable => $value) {
// If there is an odd amount of variables in the URL string
// .. then we just set the last variable to true. This needs
// .. to be the same in this case also.
$url .= '/' . urlencode($variable) . '/' . ($value === true ? '' : $value);
}
}
// URL has finished constructing, pass back
return $url;
}
示例7: run
public function run()
{
$config = Config::get('socket');
$config = array('worker_num' => 4, 'task_worker_num' => 8, 'max_request' => 10000, 'dispatch_mode' => 2, 'debug_mode' => 0, 'daemonize' => false);
if (isset($argv[1]) and $argv[1] == 'daemon') {
$config['daemonize'] = true;
} else {
$config['daemonize'] = false;
}
$serv = new \swoole_server("0.0.0.0", 8808);
$serv->set($config);
$serv->config = $config;
$handler = new Handler();
$serv->on('Start', array($handler, "start"));
$serv->on('Connect', array($handler, "connect"));
$serv->on('Receive', array($handler, "receive"));
$serv->on('Close', array($handler, "close"));
$serv->on('Shutdown', array($handler, "shutdown"));
$serv->on('Timer', array($handler, "timer"));
$serv->on('WorkerStart', array($handler, "workStart"));
$serv->on('WorkerStop', array($handler, "workStop"));
$serv->on('Task', array($handler, "task"));
$serv->on('Finish', array($handler, "finish"));
$serv->on('WorkerError', array($handler, "workError"));
$serv->start();
}
示例8: __construct
public function __construct()
{
//Setup extra autoloader.
new Autoloader(Config::get("autoloader"));
$this->setVars();
$this->run();
}
示例9: handle
public function handle()
{
$aConfig = c\Config::get('dsn');
u\DB::connect($aConfig['data']);
$aData = parent::handle();
$aData['data']['host'] = "http://{$_SERVER['HTTP_HOST']}/?static=";
return $aData;
}
示例10: before
function before()
{
parent::before();
$this->_seo['h1'] = 'Банерная система';
$this->_seo['title'] = 'Банерная система';
$this->setBreadcrumbs('Банерная система', 'backend/' . Route::controller() . '/index');
$this->limit = Config::get('limit_backend');
}
示例11: login
/**
* 登陆
*/
public function login()
{
$api = Config::get('global', 'qqconnect');
$weibo = Config::get('global', 'weibo');
$callback = url('qqlogin', '', '', 1);
$loginurl = $this->getQqLoginUrl($api['appid'], $callback);
include template();
}
示例12: init
public static function init()
{
$classes = Config::get('class_aliases');
if (is_array($classes)) {
foreach ($classes as $classAlias => $className) {
class_alias($className, $classAlias);
}
}
}
示例13: get
public function get($token)
{
$tokenName = Config::get('session/token');
if ($this->_session->exists($tokenName) && $this->_session->get($tokenName) === $token) {
$this->_session->delete($tokenName);
return true;
}
return false;
}
示例14: factory
/**
* Loads an image and prepares it for manipulation.
*
* $image = Image::factory('upload/test.jpg');
*
* @param string $file image file path
* @param string $driver driver type: GD, ImageMagick, etc
* @return Image
* @uses Image::$default_driver
*/
public static function factory($file, $driver = NULL)
{
if ($driver === NULL) {
// $driver = Image::$default_driver;
$driver = Config::get('main.image');
}
// Set the class name
$class = 'Core\\Image\\' . $driver;
return new $class($file);
}
示例15: before
function before()
{
parent::before();
$this->_seo['h1'] = 'Пользователи';
$this->_seo['title'] = 'Пользователи';
$this->setBreadcrumbs('Пользователи', 'backend/' . Route::controller() . '/index');
$this->page = (int) Route::param('page') ? (int) Route::param('page') : 1;
$this->limit = (int) Arr::get($_GET, 'limit', Config::get('limit_backend')) < 1 ?: Arr::get($_GET, 'limit', Config::get('limit_backend'));
$this->offset = ($this->page - 1) * $this->limit;
}