當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Context類代碼示例

本文整理匯總了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';
         }
     }
 }
開發者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


注:本文中的Context類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。