本文整理汇总了PHP中Context类的典型用法代码示例。如果您正苦于以下问题:PHP Context类的具体用法?PHP Context怎么用?PHP Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
date_default_timezone_set(@date_default_timezone_get());
session_start();
$session = new Session($_SESSION);
$request = new Request($_REQUEST);
$setup = new Setup($request->query_boolean('refresh', false));
$context = new Context($session, $request, $setup);
if ($context->is_api_request()) {
(new Api($context))->apply();
} else {
if ($context->is_info_request()) {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
require __DIR__ . '/pages/info.php';
} else {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
$fallback_html = (new Fallback($context))->get_html();
require __DIR__ . '/pages/index.php';
}
}
}
开发者ID:arter97,项目名称:h5ai,代码行数:26,代码来源:class-bootstrap.php
示例2: interpret
function interpret(Context $context)
{
if (!is_null($this->val)) {
$context->replace($this, $this->val);
$this->val = null;
}
}
开发者ID:jabouzi,项目名称:projet,代码行数:7,代码来源:listing11.02.php
示例3: getVerifyResult
/**
* 获取校验结果
* @return type
*/
public static function getVerifyResult()
{
$context = new Context();
$typhoon = new Typhoon();
if ($typhoon->isValid()) {
$ssid = $typhoon->_ssid;
$name = $typhoon->_name;
$value = $context->get($name, '');
if ($value != '') {
if ($typhoon->_request_type == 1) {
$ret = Valid::sendVerifyRemoteRequest($ssid, $value, $typhoon->_diff_time);
} else {
$ret = Valid::sendVerifyLocalRequest($ssid, $value);
}
self::$_result = Valid::getResult();
self::$_code = Valid::getCode();
self::$_details = Valid::getDetails();
} else {
self::$_result = 0;
self::$_code = 'E_VALUEEMPTY_001';
self::$_details = '验证码不可以为空';
}
} else {
self::$_result = 0;
self::$_code = 'E_PARAM_001';
self::$_details = '重要参数传递错误';
}
return self::$_result === 1 ? TRUE : FALSE;
}
开发者ID:saintho,项目名称:phpdisk,代码行数:33,代码来源:Verify.php
示例4: _execute
/**
* @param Context $context
* @param Request $request
*/
public function _execute($context, $request)
{
controller_ChangeController::setNoCache();
$generator = form_CaptchaGenerator::getInstance();
$renew = $request->hasParameter('renew');
// Set optionnal parameters.
if ($request->hasParameter('ml')) {
$generator->setCodeMaxLength(intval($request->getParameter('ml')));
if ($renew) {
$generator->setCodeMinLength(intval($request->getParameter('ml')));
}
}
if ($request->hasParameter('iw')) {
$generator->setWidth(intval($request->getParameter('iw')));
}
if ($request->hasParameter('ih')) {
$generator->setHeight(intval($request->getParameter('ih')));
}
if ($request->hasParameter('fs')) {
$generator->setFontSize(intval($request->getParameter('fs')));
}
if ($request->hasParameter('fd')) {
$generator->setFontDepth(intval($request->getParameter('fd')));
}
// Renders the image.
if ($renew) {
$generator->generateCode();
}
$generator->render($context->getUser()->getAttribute(CAPTCHA_SESSION_KEY));
return View::NONE;
}
开发者ID:RBSWebFactory,项目名称:modules.form,代码行数:35,代码来源:CaptchaAction.class.php
示例5: iterator
/** @test */
public function iterator()
{
$context = new Context(array('foo' => 'bar'));
$iterator = $context->getIterator();
$this->assertInstanceOf('IteratorAggregate', $iterator);
$iterator->offsetExists('foo');
}
开发者ID:superruzafa,项目名称:rules,代码行数:8,代码来源:ContextTest.php
示例6: on_rpc
/**
* Запуск периодических задач.
*
* Проверяется время последнего запуска, чаще установленного администратором
* времени запуск производиться не будет (по умолчанию 15 минут).
*/
public static function on_rpc(Context $ctx)
{
$status = "DELAYED";
$lastrun = $ctx->config->get('modules/cron/lastrun');
$delay = $ctx->config->get('modules/cron/delay', 15) * 60;
if (time() >= $lastrun + $delay) {
$ctx->config->set('modules/cron/lastrun', time());
$ctx->config->save();
@set_time_limit(0);
ob_start();
try {
$ctx->registry->broadcast('ru.molinos.cms.cron', array($ctx));
$status = "OK";
} catch (Exception $e) {
Logger::trace($e);
$status = "ERROR: " . get_class($e) . '; ' . trim($e->getMessage(), '.') . '.';
}
ob_end_clean();
}
if ($ctx->get('destination')) {
return $ctx->getRedirect();
}
if (!MCMS_CONSOLE) {
header('Content-Type: text/plain; charset=utf-8');
die($status);
}
die;
}
开发者ID:umonkey,项目名称:molinos-cms,代码行数:34,代码来源:class.cronmodule.php
示例7: __construct
function __construct(Context $context = null)
{
if (!$context) {
$context = new Context('helper', 'phaxsi');
}
$this->module = $context->getModule();
}
开发者ID:RNKushwaha022,项目名称:orange-php,代码行数:7,代码来源:html.helper.php
示例8: getSocketShouldNotAddReadListenerForNonReadableSocketType
/** @test */
public function getSocketShouldNotAddReadListenerForNonReadableSocketType()
{
$loop = $this->getMock('React\\EventLoop\\LoopInterface');
$loop->expects($this->never())->method('addReadStream');
$context = new Context($loop);
$socket = $context->getSocket(\ZMQ::SOCKET_PUSH);
}
开发者ID:mgldev,项目名称:coffeetrack,代码行数:8,代码来源:ContextTest.php
示例9: killer
public function killer()
{
$secure = new SecureData();
$context = new Context(new DeleteRecord());
$secure->removeRecord();
$context->algorithm($secure->setEntry());
}
开发者ID:CcrisS,项目名称:PHP-Patterns,代码行数:7,代码来源:Client.php
示例10: on_get_login_form
/**
* Вывод формы авторизации.
* @route GET//login
*/
public static function on_get_login_form(Context $ctx)
{
if ($ctx->user->id and !$ctx->get('stay')) {
return $ctx->getRedirect();
}
if (class_exists('APIStream')) {
APIStream::init($ctx);
}
$handler = array('theme' => $ctx->config->get('modules/auth/login_theme'));
$content = '';
foreach ((array) $ctx->registry->poll('ru.molinos.cms.page.head', array($ctx, $handler, null), true) as $block) {
if (!empty($block['result'])) {
$content .= $block['result'];
}
}
$content .= self::getXML($ctx);
$xml = html::em('page', array('status' => 401, 'base' => $ctx->url()->getBase($ctx), 'host' => MCMS_HOST_NAME, 'prefix' => os::webpath(MCMS_SITE_FOLDER, 'themes'), 'back' => urlencode(MCMS_REQUEST_URI), 'next' => $ctx->get('destination'), 'api' => APIStream::getPrefix(), 'query' => $ctx->query()), $content);
if (file_exists($xsl = os::path(MCMS_SITE_FOLDER, 'themes', $handler['theme'], 'templates', 'login.xsl'))) {
try {
return xslt::transform($xml, $xsl);
} catch (Exception $e) {
}
}
return xslt::transform($xml, 'lib/modules/auth/xsl/login.xsl');
}
开发者ID:umonkey,项目名称:molinos-cms,代码行数:29,代码来源:class.authform.php
示例11: rpc_post_install
public static function rpc_post_install(Context $ctx)
{
$data = $ctx->post;
if (empty($data['dbtype'])) {
throw new RuntimeException(t('Вы не выбрали тип БД.'));
}
$config = $ctx->config;
// Выносим секцию main в самое начало.
$config['main'] = array();
if ($config->isok()) {
throw new ForbiddenException(t('Инсталляция невозможна: конфигурационный файл уже есть.'));
}
$dsn = self::getDSN($data['dbtype'], $data['db'][$data['dbtype']]);
if (!empty($data['db']['prefix'])) {
$dsn['prefix'] = $data['db']['prefix'];
}
$config->set('modules/db', $dsn);
foreach (array('modules/mail/server', 'modules/mail/from', 'main/debug/errors') as $key) {
if (!empty($data[$key])) {
$config->set($key, $data[$key]);
}
}
$config->set('modules/files/storage', 'files');
$config->set('modules/files/ftp', 'ftp');
$config->set('main/tmpdir', 'tmp');
$config->set('main/debug/allow', array('127.0.0.1', $_SERVER['REMOTE_ADDR']));
// Создаём маршрут для главной страницы.
$config['routes']['localhost/'] = array('title' => 'Molinos CMS', 'theme' => 'example', 'call' => 'BaseRoute::serve');
// Проверим соединение с БД.
$pdo = Database::connect($config->get('modules/db'));
// Подключились, можно сохранять конфиг.
$config->save();
$ctx->redirect('admin/system/reload?destination=admin/system/settings');
}
开发者ID:umonkey,项目名称:molinos-cms,代码行数:34,代码来源:class.installmodule.php
示例12: render
/**
* @param Context $context
*
* @return mixed
*/
public function render($context)
{
/** @var $block_context BlockContext */
$block_context = null;
if (isset($context->render_context[BLOCK_CONTEXT_KEY])) {
$block_context = $context->render_context[BLOCK_CONTEXT_KEY];
}
$context->push();
if ($block_context === null) {
$context['block'] = $this;
$result = $this->nodelist->render($context);
} else {
$push = $block = $block_context->pop($this->name);
if ($block === null) {
$block = $this;
}
// Create new block so we can store context without thread-safety issues.
$block = new BlockNode($block->name, $block->nodelist);
$block->context = $context;
$context['block'] = $block;
$result = $block->nodelist->render($context);
if ($push !== null) {
$block_context->push($this->name, $push);
}
}
$context->pop();
return $result;
}
开发者ID:idlesign,项目名称:dja,代码行数:33,代码来源:loader_tags.php
示例13: controllerStart
/**
* Method called after the module has been setup, but before the action
* is executed.
* @param Context $context
*/
function controllerStart($context)
{
if (!$this->config['enabled']) {
return;
}
#Execute this only when it is a page controller and not when
#it is a block, layout or some other type of controller
if ($context->getType() != 'controller') {
return;
}
#Put the action in lowercase to avoid it not being detected due to case
$action = strtolower($context->getAction());
#Checks for user credentials and executes in case they are not valid
if (!$this->isAuthorized($action)) {
$this->callDenyFunction($action);
$view_type = $context->getViewType();
switch ($view_type) {
case 'html':
case 'process':
case 'mail':
$this->loginRedirect();
break;
case 'json':
case 'feed':
default:
exit;
}
exit;
}
$this->started = true;
}
开发者ID:RNKushwaha022,项目名称:orange-php,代码行数:36,代码来源:auth.plugin.php
示例14: setUp
protected function setUp()
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->scheduledStructureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ScheduledStructure')->disableOriginalConstructor()->getMock();
$this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock();
$this->contextMock->expects($this->any())->method('getScheduledStructure')->willReturn($this->scheduledStructureMock);
$this->move = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Layout\\Reader\\Move');
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:8,代码来源:MoveTest.php
示例15: execute
public function execute()
{
$context = new Context();
$context->execute(function () {
array_pop($this->tasks);
echo count($this->tasks);
});
}
开发者ID:srph,项目名称:playground,代码行数:8,代码来源:file.php
示例16: __construct
function __construct(Context $context)
{
$this->load = new Loader($context);
$this->db = new DatabaseProxy($this->load);
$this->context = $context;
$this->view = new ShellView($context);
$this->args = array_merge((array) $this->args, (array) $context->getArguments());
}
开发者ID:RNKushwaha022,项目名称:orange-php,代码行数:8,代码来源:shell.class.php
示例17: main
/**
* Main program
*/
public static function main()
{
$context = new Context();
$context->request();
$context->request();
$context->request();
$context = null;
}
开发者ID:luisOO,项目名称:design-patterns,代码行数:11,代码来源:client.php
示例18: holdsFor
/**
* {@inheritdoc}
*/
public function holdsFor(Context $context)
{
if (!$context->has($this->key)) {
return false;
}
$argument = $context->get($this->key);
return $this->operator->appliesTo($argument);
}
开发者ID:richardskinner,项目名称:qandidate-toggle,代码行数:11,代码来源:OperatorCondition.php
示例19: __construct
/**
* Initializes controller
* @param Context $context
* @param View $view
*/
function __construct(Context $context, View $view)
{
$this->load = new Loader($context);
$this->context = $context;
$this->view = $view;
$this->args = array_merge((array) $this->args, (array) $context->getArguments());
$base_module = $context->getBaseModuleName();
$this->config = isset(AppConfig::$modules[$base_module]) ? AppConfig::$modules[$base_module] : array();
}
开发者ID:RNKushwaha022,项目名称:orange-php,代码行数:14,代码来源:abstract_controller.class.php
示例20: __construct
/**
* Initializes the Controller instance and selects the appropiate View
* @param Context $context
*/
function __construct(Context $context)
{
$type = $context->getViewType();
$class_name = $type . 'view';
$view = new $class_name($context);
parent::__construct($context, $view);
$this->db = new DatabaseProxy($this->load);
$this->helper = new HelperLoader($this->load);
}
开发者ID:RNKushwaha022,项目名称:orange-php,代码行数:13,代码来源:controller.class.php
注:本文中的Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论