當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。