当前位置: 首页>>代码示例>>PHP>>正文


PHP Versioned::choose_site_stage方法代码示例

本文整理汇总了PHP中Versioned::choose_site_stage方法的典型用法代码示例。如果您正苦于以下问题:PHP Versioned::choose_site_stage方法的具体用法?PHP Versioned::choose_site_stage怎么用?PHP Versioned::choose_site_stage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Versioned的用法示例。


在下文中一共展示了Versioned::choose_site_stage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preRequest

 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     // Bootstrap session so that Session::get() accesses the right instance
     $dummyController = new Controller();
     $dummyController->setSession($session);
     $dummyController->setRequest($request);
     $dummyController->pushCurrent();
     // Block non-authenticated users from setting the stage mode
     if (!Versioned::can_choose_site_stage($request)) {
         $permissionMessage = sprintf(_t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", 'You must log in with your CMS password in order to view the draft or archived content. ' . '<a href="%s">Click here to go back to the published site.</a>'), Convert::raw2xml(Controller::join_links(Director::baseURL(), $request->getURL(), "?stage=Live")));
         // Force output since RequestFilter::preRequest doesn't support response overriding
         $response = Security::permissionFailure($dummyController, $permissionMessage);
         $session->inst_save();
         $dummyController->popCurrent();
         // Prevent output in testing
         if (class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
             throw new SS_HTTPResponse_Exception($response);
         }
         $response->output();
         die;
     }
     Versioned::choose_site_stage();
     $dummyController->popCurrent();
     return true;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:25,代码来源:VersionedRequestFilter.php

示例2: setUp

 protected function setUp()
 {
     $config = \Config::inst();
     $config->update('Director', 'environment_type', 'dev');
     $config->update('SSViewer', 'theme', 'theme');
     \Versioned::choose_site_stage();
     $this->controllerMock = $this->getMock('Controller');
     $this->keyCreator = new ControllerBased($this->controllerMock);
 }
开发者ID:Focus-Flow,项目名称:silverstripe-cacheinclude,代码行数:9,代码来源:ControllerBasedTest.php

示例3: start

 /**
     |--------------------------------------------------------------------------
     | Start up Silverstripe
     |--------------------------------------------------------------------------
     |
     | Include Silverstripe's core code and connect it to its database
     |
 */
 public static function start()
 {
     if (!static::$started) {
         static::$started = true;
         require_once 'SilverstripeHelpers.php';
         if (true !== (require_once public_path() . '/silverstripe/framework/core/Core.php')) {
             require_once public_path() . '/silverstripe/framework/model/DB.php';
             global $databaseConfig;
             if (!\DB::isActive()) {
                 \DB::connect($databaseConfig);
             }
         }
         \Versioned::choose_site_stage();
     }
 }
开发者ID:helpfulrobot,项目名称:themonkeys-laravel-silverstripe,代码行数:23,代码来源:Silverstripe.php

示例4: init

 public function init()
 {
     if ($this->getSession() && $this->data()->exists()) {
         Versioned::choose_site_stage($this->getSession());
     } else {
         Versioned::reading_stage('Live');
     }
     parent::init();
     self::include_microblog_requirements();
     $member = $this->securityContext->getMember();
     if ($member && $member->ID) {
         if ($member->Balance < self::POOR_USER_THRESHOLD) {
             throw new Exception("Broken pipe");
         }
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-microblog,代码行数:16,代码来源:TimelineController.php

示例5: testReadingPersistent

 /**
  * Tests that reading mode persists between requests
  */
 public function testReadingPersistent()
 {
     $session = Injector::inst()->create('Session', array());
     // Set to stage
     Director::test('/?stage=Stage', null, $session);
     $this->assertEquals('Stage.Stage', $session->inst_get('readingMode'), 'Check querystring changes reading mode to Stage');
     Director::test('/', null, $session);
     $this->assertEquals('Stage.Stage', $session->inst_get('readingMode'), 'Check that subsequent requests in the same session remain in Stage mode');
     // Test live persists
     Director::test('/?stage=Live', null, $session);
     $this->assertEquals('Stage.Live', $session->inst_get('readingMode'), 'Check querystring changes reading mode to Live');
     Director::test('/', null, $session);
     $this->assertEquals('Stage.Live', $session->inst_get('readingMode'), 'Check that subsequent requests in the same session remain in Live mode');
     // Test that session doesn't redundantly store the default stage if it doesn't need to
     $session2 = Injector::inst()->create('Session', array());
     Director::test('/', null, $session2);
     $this->assertEmpty($session2->inst_changedData());
     Director::test('/?stage=Live', null, $session2);
     $this->assertEmpty($session2->inst_changedData());
     // Test choose_site_stage
     Session::set('readingMode', 'Stage.Stage');
     Versioned::choose_site_stage();
     $this->assertEquals('Stage.Stage', Versioned::get_reading_mode());
     Session::set('readingMode', 'Archive.2014-01-01');
     Versioned::choose_site_stage();
     $this->assertEquals('Archive.2014-01-01', Versioned::get_reading_mode());
     Session::clear('readingMode');
     Versioned::choose_site_stage();
     $this->assertEquals('Stage.Live', Versioned::get_reading_mode());
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:33,代码来源:VersionedTest.php

示例6: testStageQuerying

 public function testStageQuerying()
 {
     Injector::inst()->registerService(new SolrSearchService());
     // we should be able to perform a query for documents with 'text content'
     // and receive back some valid data
     $search = singleton('SolrSearchService');
     if (!$search->isConnected()) {
         return;
     }
     // clear everything out, then index content
     /* @var $search SolrSearchService */
     $search->getSolr()->deleteByQuery('*:*');
     $item = $this->objFromFixture('Page', 'home');
     $item->write();
     $item->doPublish();
     $results = $search->query('title:home');
     $objects = $results->getDataObjects();
     // there should actually be two results; one for each stage.
     $this->assertEquals(2, $objects->count());
     // now set a stage
     Versioned::choose_site_stage();
     $results = $search->query('title:home');
     $objects = $results->getDataObjects();
     $this->assertEquals(1, $objects->count());
 }
开发者ID:helpfulrobot,项目名称:silverstripe-solr,代码行数:25,代码来源:SolrIndexingTest.php

示例7: init

 public function init()
 {
     Versioned::choose_site_stage();
     parent::init();
 }
开发者ID:nadeeth,项目名称:silverstripe-dms,代码行数:5,代码来源:DMSDocument.php

示例8: preRequest

 public function preRequest()
 {
     Versioned::choose_site_stage();
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:4,代码来源:VersionedRequestFilter.php

示例9: preRequest

 /**
  * If this url allows caching and there is a cached response then send it
  * @param  SS_HTTPRequest $request
  * @param  Session        $session
  * @param  DataModel      $model
  * @return bool|void
  */
 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     if ($this->allowFetch($request)) {
         \Versioned::choose_site_stage();
         if ($request->getURL() == '') {
             $request = clone $request;
             $request->setUrl('home');
         }
         $response = $this->cache->get($this->name, \Injector::inst()->create('CacheIncludeKeyCreator', $this->getController($request)));
         if ($response instanceof SS_HTTPResponse) {
             // replace in body
             if ($this->hasTokens()) {
                 $body = $response->getBody();
                 foreach ($this->tokens as $token) {
                     $name = self::REPLACED_TOKEN_PREFIX . $token->getName();
                     if (strpos($body, $name) !== false) {
                         $body = str_replace($name, $token->getValue(), $body);
                     }
                 }
                 $response->setBody($body);
             }
             $session->save();
             $response->output();
             exit;
         }
     }
     return true;
 }
开发者ID:Focus-Flow,项目名称:silverstripe-cacheinclude,代码行数:35,代码来源:RequestCache.php

示例10: preRequest

 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     Versioned::choose_site_stage($session);
     return true;
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:5,代码来源:VersionedRequestFilter.php


注:本文中的Versioned::choose_site_stage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。