本文整理汇总了PHP中Context类的典型用法代码示例。如果您正苦于以下问题:PHP Context类的具体用法?PHP Context怎么用?PHP Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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';
}
}
}
示例2: interpret
function interpret(Context $context)
{
if (!is_null($this->val)) {
$context->replace($this, $this->val);
$this->val = null;
}
}
示例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;
}
示例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;
}
示例5: iterator
/** @test */
public function iterator()
{
$context = new Context(array('foo' => 'bar'));
$iterator = $context->getIterator();
$this->assertInstanceOf('IteratorAggregate', $iterator);
$iterator->offsetExists('foo');
}
示例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;
}
示例7: __construct
function __construct(Context $context = null)
{
if (!$context) {
$context = new Context('helper', 'phaxsi');
}
$this->module = $context->getModule();
}
示例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);
}
示例9: killer
public function killer()
{
$secure = new SecureData();
$context = new Context(new DeleteRecord());
$secure->removeRecord();
$context->algorithm($secure->setEntry());
}
示例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');
}
示例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');
}
示例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;
}
示例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;
}
示例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');
}
示例15: execute
public function execute()
{
$context = new Context();
$context->execute(function () {
array_pop($this->tasks);
echo count($this->tasks);
});
}