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


PHP Requirements::set_backend方法代码示例

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


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

示例1: init

 public function init()
 {
     Requirements::set_backend(new BetterRequirements_Backend());
     parent::init();
     Requirements::set_combined_files_folder(project() . '/_combinedfiles');
     Requirements::set_force_js_to_bottom(true);
     $this->requireJS();
     $this->requireCSS();
 }
开发者ID:silverstripe-europe-meetup,项目名称:website-2015,代码行数:9,代码来源:Page.php

示例2: testRequirements

 public function testRequirements()
 {
     $requirements = $this->getMock("Requirements_Backend", array("javascript", "css"));
     $jsFile = FRAMEWORK_DIR . '/tests/forms/a.js';
     $cssFile = FRAMEWORK_DIR . '/tests/forms/a.js';
     $requirements->expects($this->once())->method('javascript')->with($jsFile);
     $requirements->expects($this->once())->method('css')->with($cssFile);
     Requirements::set_backend($requirements);
     $template = $this->render("<% require javascript({$jsFile}) %>\n\t\t<% require css({$cssFile}) %>");
     $this->assertFalse((bool) trim($template), "Should be no content in this return.");
 }
开发者ID:normann,项目名称:sapphire,代码行数:11,代码来源:SSViewerTest.php

示例3: testRequirements

    function testRequirements()
    {
        $requirements = $this->getMock("Requirements_Backend", array("javascript", "css"));
        $jsFile = 'sapphire/tests/forms/a.js';
        $cssFile = 'sapphire/tests/forms/a.js';
        $requirements->expects($this->once())->method('javascript')->with($jsFile);
        $requirements->expects($this->once())->method('css')->with($cssFile);
        Requirements::set_backend($requirements);
        $data = new ArrayData(array());
        $viewer = SSViewer::fromString(<<<SS
\t\t<% require javascript({$jsFile}) %>
\t\t<% require css({$cssFile}) %>
SS
);
        $template = $viewer->process($data);
        $this->assertFalse((bool) trim($template), "Should be no content in this return.");
    }
开发者ID:NARKOZ,项目名称:silverstripe-doc-restructuring,代码行数:17,代码来源:SSViewerTest.php

示例4: tearDown

 public function tearDown()
 {
     // Preserve memory settings
     ini_set('memory_limit', $this->originalMemoryLimit ? $this->originalMemoryLimit : -1);
     // Restore email configuration
     $this->originalMailer = null;
     $this->mailer = null;
     // Restore password validation
     if ($this->originalMemberPasswordValidator) {
         Member::set_password_validator($this->originalMemberPasswordValidator);
     }
     // Restore requirements
     if ($this->originalRequirements) {
         Requirements::set_backend($this->originalRequirements);
     }
     // Mark test as no longer being run - we use originalIsRunningTest to allow for nested SapphireTest calls
     self::$is_running_test = $this->originalIsRunningTest;
     $this->originalIsRunningTest = null;
     // Reset mocked datetime
     DBDatetime::clear_mock_now();
     // Stop the redirection that might have been requested in the test.
     // Note: Ideally a clean Controller should be created for each test.
     // Now all tests executed in a batch share the same controller.
     $controller = Controller::has_curr() ? Controller::curr() : null;
     if ($controller && $controller->response && $controller->response->getHeader('Location')) {
         $controller->response->setStatusCode(200);
         $controller->response->removeHeader('Location');
     }
     Versioned::set_reading_mode($this->originalReadingMode);
     //unnest injector / config now that tests are over
     Injector::unnest();
     Config::unnest();
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:33,代码来源:SapphireTest.php

示例5: testProcessOnlyIncludesRequirementsOnce

 public function testProcessOnlyIncludesRequirementsOnce()
 {
     $template = new SSViewer(array('SSViewerTestProcess'));
     $basePath = dirname($this->getCurrentRelativePath()) . '/forms';
     $backend = new Requirements_Backend();
     $backend->set_combined_files_enabled(false);
     $backend->combine_files('RequirementsTest_ab.css', array($basePath . '/RequirementsTest_a.css', $basePath . '/RequirementsTest_b.css'));
     Requirements::set_backend($backend);
     $this->assertEquals(1, substr_count($template->process(array()), "a.css"));
     $this->assertEquals(1, substr_count($template->process(array()), "b.css"));
     // if we disable the requirements then we should get nothing
     $template->includeRequirements(false);
     $this->assertEquals(0, substr_count($template->process(array()), "a.css"));
     $this->assertEquals(0, substr_count($template->process(array()), "b.css"));
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:15,代码来源:SSViewerTest.php

示例6: testConditionalTemplateRequire

 public function testConditionalTemplateRequire()
 {
     $basePath = $this->getCurrentRelativePath();
     // we're asserting "framework", so set the relative path accordingly in case FRAMEWORK_DIR was changed
     // to something else
     $basePath = 'framework' . substr($basePath, strlen(FRAMEWORK_DIR));
     $backend = new Requirements_Backend();
     $holder = Requirements::backend();
     Requirements::set_backend($backend);
     $data = new ArrayData(array('FailTest' => true));
     $data->renderWith('RequirementsTest_Conditionals');
     $this->assertFileIncluded($backend, 'css', $basePath . '/RequirementsTest_a.css');
     $this->assertFileIncluded($backend, 'js', array($basePath . '/RequirementsTest_b.js', $basePath . '/RequirementsTest_c.js'));
     $this->assertFileNotIncluded($backend, 'js', $basePath . '/RequirementsTest_a.js');
     $this->assertFileNotIncluded($backend, 'css', array($basePath . '/RequirementsTest_b.css', $basePath . '/RequirementsTest_c.css'));
     $backend->clear();
     $data = new ArrayData(array('FailTest' => false));
     $data->renderWith('RequirementsTest_Conditionals');
     $this->assertFileNotIncluded($backend, 'css', $basePath . '/RequirementsTest_a.css');
     $this->assertFileNotIncluded($backend, 'js', array($basePath . '/RequirementsTest_b.js', $basePath . '/RequirementsTest_c.js'));
     $this->assertFileIncluded($backend, 'js', $basePath . '/RequirementsTest_a.js');
     $this->assertFileIncluded($backend, 'css', array($basePath . '/RequirementsTest_b.css', $basePath . '/RequirementsTest_c.css'));
     Requirements::set_backend($holder);
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:24,代码来源:RequirementsTest.php

示例7: parseVariables

 /**
  * Load all the template variables into the internal variables, including
  * the template into body.	Called before send() or debugSend()
  * $isPlain=true will cause the template to be ignored, otherwise the GenericEmail template will be used
  * and it won't be plain email :)
  *
  * This function is updated to rewrite urls in a safely manner and inline css.
  * It will also changed the requirements backend to avoid requiring stuff in the html.
  */
 protected function parseVariables($isPlain = false)
 {
     $origState = Config::inst()->get('SSViewer', 'source_file_comments');
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     // Workaround to avoid clutter in our rendered html
     $backend = Requirements::backend();
     Requirements::set_backend(new MandrillRequirementsBackend());
     if (!$this->parseVariables_done) {
         $this->parseVariables_done = true;
         if (!$this->original_body) {
             $this->original_body = $this->body;
         }
         // Parse $ variables in the base parameters
         $data = $this->templateData();
         // Process a .SS template file
         $fullBody = $this->original_body;
         if ($this->parse_body) {
             try {
                 $viewer = new SSViewer_FromString($fullBody);
                 $fullBody = $viewer->process($data);
             } catch (Exception $ex) {
                 SS_Log::log($ex->getMessage(), SS_Log::DEBUG);
             }
             // Also parse the email title
             try {
                 $viewer = new SSViewer_FromString($this->subject);
                 $this->subject = $viewer->process($data);
             } catch (Exception $ex) {
                 SS_Log::log($ex->getMessage(), SS_Log::DEBUG);
             }
             if ($this->callout) {
                 try {
                     $viewer = new SSViewer_FromString($this->callout);
                     $this->callout = $viewer->process($data);
                 } catch (Exception $ex) {
                     SS_Log::log($ex->getMessage(), SS_Log::DEBUG);
                 }
             }
             if ($this->sidebar) {
                 try {
                     $viewer = new SSViewer_FromString($this->sidebar);
                     $this->sidebar = $viewer->process($data);
                 } catch (Exception $ex) {
                     SS_Log::log($ex->getMessage(), SS_Log::DEBUG);
                 }
             }
         }
         if ($this->ss_template && !$isPlain) {
             // Requery data so that updated versions of To, From, Subject, etc are included
             $data = $this->templateData();
             $template = new SSViewer($this->ss_template);
             if ($template->exists()) {
                 // Make sure we included the parsed body into layout
                 $data->setField('Body', $fullBody);
                 try {
                     $fullBody = $template->process($data);
                 } catch (Exception $ex) {
                     SS_Log::log($ex->getMessage(), SS_Log::DEBUG);
                 }
             }
         }
         // Rewrite relative URLs
         $this->body = self::rewriteURLs($fullBody);
     }
     Config::inst()->update('SSViewer', 'source_file_comments', $origState);
     Requirements::set_backend($backend);
     return $this;
 }
开发者ID:Olliepop,项目名称:silverstripe-mandrill,代码行数:77,代码来源:MandrillEmail.php

示例8:

<?php

Requirements::set_backend(Injector::inst()->get("SectionedHeadJsBackend"));
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-headjs,代码行数:3,代码来源:_config.php

示例9: test

 /**
  * Test a URL request, returning a response object.
  * 
  * This method is the counterpart of Director::direct() that is used in functional testing.  It will execute the URL given,
  * 
  * @param string $url The URL to visit
  * @param array $postVars The $_POST & $_FILES variables
  * @param Session $session The {@link Session} object representing the current session.  By passing the same object to multiple
  * calls of Director::test(), you can simulate a persisted session.
  * @param string $httpMethod The HTTP method, such as GET or POST.  It will default to POST if postVars is set, GET otherwise.
  *  Overwritten by $postVars['_method'] if present.
  * @param string $body The HTTP body
  * @param array $headers HTTP headers with key-value pairs
  * @param array $cookies to populate $_COOKIE
  * @return SS_HTTPResponse
  * 
  * @uses getControllerForURL() The rule-lookup logic is handled by this.
  * @uses Controller::run() Controller::run() handles the page logic for a Director::direct() call.
  */
 static function test($url, $postVars = null, $session = null, $httpMethod = null, $body = null, $headers = null, $cookies = null)
 {
     // These are needed so that calling Director::test() doesnt muck with whoever is calling it.
     // Really, it's some inappropriate coupling and should be resolved by making less use of statics
     $oldStage = Versioned::current_stage();
     $getVars = array();
     if (!$httpMethod) {
         $httpMethod = $postVars || is_array($postVars) ? "POST" : "GET";
     }
     if (!$session) {
         $session = new Session(null);
     }
     // Back up the current values of the superglobals
     $existingRequestVars = isset($_REQUEST) ? $_REQUEST : array();
     $existingGetVars = isset($_GET) ? $_GET : array();
     $existingPostVars = isset($_POST) ? $_POST : array();
     $existingSessionVars = isset($_SESSION) ? $_SESSION : array();
     $existingCookies = isset($_COOKIE) ? $_COOKIE : array();
     $existingServer = isset($_SERVER) ? $_SERVER : array();
     $existingCookieReportErrors = Cookie::report_errors();
     $existingRequirementsBackend = Requirements::backend();
     Cookie::set_report_errors(false);
     Requirements::set_backend(new Requirements_Backend());
     // Handle absolute URLs
     if (@parse_url($url, PHP_URL_HOST) != '') {
         $bits = parse_url($url);
         $_SERVER['HTTP_HOST'] = $bits['host'];
         $url = Director::makeRelative($url);
     }
     $urlWithQuerystring = $url;
     if (strpos($url, '?') !== false) {
         list($url, $getVarsEncoded) = explode('?', $url, 2);
         parse_str($getVarsEncoded, $getVars);
     }
     // Replace the superglobals with appropriate test values
     $_REQUEST = array_merge((array) $getVars, (array) $postVars);
     $_GET = (array) $getVars;
     $_POST = (array) $postVars;
     $_SESSION = $session ? $session->inst_getAll() : array();
     $_COOKIE = (array) $cookies;
     $_SERVER['REQUEST_URI'] = Director::baseURL() . $urlWithQuerystring;
     $req = new SS_HTTPRequest($httpMethod, $url, $getVars, $postVars, $body);
     if ($headers) {
         foreach ($headers as $k => $v) {
             $req->addHeader($k, $v);
         }
     }
     $result = Director::handleRequest($req, $session);
     // Restore the superglobals
     $_REQUEST = $existingRequestVars;
     $_GET = $existingGetVars;
     $_POST = $existingPostVars;
     $_SESSION = $existingSessionVars;
     $_COOKIE = $existingCookies;
     $_SERVER = $existingServer;
     Cookie::set_report_errors($existingCookieReportErrors);
     Requirements::set_backend($existingRequirementsBackend);
     // These are needed so that calling Director::test() doesnt muck with whoever is calling it.
     // Really, it's some inappropriate coupling and should be resolved by making less use of statics
     Versioned::reading_stage($oldStage);
     return $result;
 }
开发者ID:eLBirador,项目名称:AllAboutCity,代码行数:81,代码来源:Director.php

示例10: ModuleRequirements_Backend

<?php

Requirements::set_backend(new ModuleRequirements_Backend());
开发者ID:helpfulrobot,项目名称:axyr-silverstripe-modulefolder,代码行数:3,代码来源:_config.php

示例11: SSGuru_Requirements_Backend

<?php

Requirements::set_backend(new SSGuru_Requirements_Backend());
define('SS_GDM_EXTENSIONS_DIR', basename(dirname(__FILE__)));
Deprecation::notification_version("0.1.3", SS_GDM_EXTENSIONS_DIR);
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-extensions,代码行数:5,代码来源:_config.php

示例12: tearDown

	function tearDown() {
		// Restore email configuration
		Email::set_mailer($this->originalMailer);
		$this->originalMailer = null;
		$this->mailer = null;

		// Restore password validation
		Member::set_password_validator($this->originalMemberPasswordValidator);
		
		// Restore requirements
		Requirements::set_backend($this->originalRequirements);

		// Mark test as no longer being run - we use originalIsRunningTest to allow for nested SapphireTest calls
		self::$is_running_test = $this->originalIsRunningTest;
		$this->originalIsRunningTest = null;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:16,代码来源:SapphireTest.php

示例13: onBeforeInit

 public function onBeforeInit()
 {
     Requirements::set_backend(new BetterRequirementsVersioning_Backend());
 }
开发者ID:christopherdarling,项目名称:silverstripe-betterrequirementsversioning,代码行数:4,代码来源:BetterRequirementsVersioningContentControllerExtension.php

示例14: test

 /**
  * Test a URL request, returning a response object.
  * 
  * This method is the counterpart of Director::direct() that is used in functional testing.  It will execute the
  * URL given, and return the result as an SS_HTTPResponse object.
  * 
  * @param string $url The URL to visit
  * @param array $postVars The $_POST & $_FILES variables
  * @param Session $session The {@link Session} object representing the current session.  By passing the same
  *                         object to multiple  calls of Director::test(), you can simulate a persisted session.
  * @param string $httpMethod The HTTP method, such as GET or POST.  It will default to POST if postVars is set,
  *                           GET otherwise. Overwritten by $postVars['_method'] if present.
  * @param string $body The HTTP body
  * @param array $headers HTTP headers with key-value pairs
  * @param array $cookies to populate $_COOKIE
  * @param HTTP_Request $request The {@see HTTP_Request} object generated as a part of this request
  * @return SS_HTTPResponse
  * 
  * @uses getControllerForURL() The rule-lookup logic is handled by this.
  * @uses Controller::run() Controller::run() handles the page logic for a Director::direct() call.
  */
 public static function test($url, $postVars = null, $session = null, $httpMethod = null, $body = null, $headers = null, $cookies = null, &$request = null)
 {
     Config::nest();
     // These are needed so that calling Director::test() doesnt muck with whoever is calling it.
     // Really, it's some inappropriate coupling and should be resolved by making less use of statics
     $oldStage = Versioned::current_stage();
     $getVars = array();
     if (!$httpMethod) {
         $httpMethod = $postVars || is_array($postVars) ? "POST" : "GET";
     }
     if (!$session) {
         $session = new Session(null);
     }
     // Back up the current values of the superglobals
     $existingRequestVars = isset($_REQUEST) ? $_REQUEST : array();
     $existingGetVars = isset($_GET) ? $_GET : array();
     $existingPostVars = isset($_POST) ? $_POST : array();
     $existingSessionVars = isset($_SESSION) ? $_SESSION : array();
     $existingCookies = isset($_COOKIE) ? $_COOKIE : array();
     $existingServer = isset($_SERVER) ? $_SERVER : array();
     $existingRequirementsBackend = Requirements::backend();
     Config::inst()->update('Cookie', 'report_errors', false);
     Requirements::set_backend(new Requirements_Backend());
     // Handle absolute URLs
     if (@parse_url($url, PHP_URL_HOST) != '') {
         $bits = parse_url($url);
         $_SERVER['HTTP_HOST'] = $bits['host'];
         $url = Director::makeRelative($url);
     }
     $urlWithQuerystring = $url;
     if (strpos($url, '?') !== false) {
         list($url, $getVarsEncoded) = explode('?', $url, 2);
         parse_str($getVarsEncoded, $getVars);
     }
     // Replace the superglobals with appropriate test values
     $_REQUEST = ArrayLib::array_merge_recursive((array) $getVars, (array) $postVars);
     $_GET = (array) $getVars;
     $_POST = (array) $postVars;
     $_SESSION = $session ? $session->inst_getAll() : array();
     $_COOKIE = (array) $cookies;
     $_SERVER['REQUEST_URI'] = Director::baseURL() . $urlWithQuerystring;
     $request = new SS_HTTPRequest($httpMethod, $url, $getVars, $postVars, $body);
     if ($headers) {
         foreach ($headers as $k => $v) {
             $request->addHeader($k, $v);
         }
     }
     // Pre-request filtering
     // @see issue #2517
     $model = DataModel::inst();
     $output = Injector::inst()->get('RequestProcessor')->preRequest($request, $session, $model);
     if ($output === false) {
         // @TODO Need to NOT proceed with the request in an elegant manner
         throw new SS_HTTPResponse_Exception(_t('Director.INVALID_REQUEST', 'Invalid request'), 400);
     }
     // TODO: Pass in the DataModel
     $result = Director::handleRequest($request, $session, $model);
     // Ensure that the result is an SS_HTTPResponse object
     if (is_string($result)) {
         if (substr($result, 0, 9) == 'redirect:') {
             $response = new SS_HTTPResponse();
             $response->redirect(substr($result, 9));
             $result = $response;
         } else {
             $result = new SS_HTTPResponse($result);
         }
     }
     $output = Injector::inst()->get('RequestProcessor')->postRequest($request, $result, $model);
     if ($output === false) {
         throw new SS_HTTPResponse_Exception("Invalid response");
     }
     // Restore the superglobals
     $_REQUEST = $existingRequestVars;
     $_GET = $existingGetVars;
     $_POST = $existingPostVars;
     $_SESSION = $existingSessionVars;
     $_COOKIE = $existingCookies;
     $_SERVER = $existingServer;
     Requirements::set_backend($existingRequirementsBackend);
//.........这里部分代码省略.........
开发者ID:jareddreyer,项目名称:catalogue,代码行数:101,代码来源:Director.php

示例15: Minify_Requirements_Backend

<?php

if (Director::isLive()) {
    Controller::add_extension('SS_MinifiedResponseExtension');
    Requirements::set_backend(new Minify_Requirements_Backend());
    if (defined('MINIFY_CACHE_BACKEND') && defined('MINIFY_CACHE_LIFETIME')) {
        $backend = unserialize(MINIFY_CACHE_BACKEND);
        SS_Cache::add_backend('MINIFY_CACHE_BACKEND', $backend['Type'], $backend['Options']);
        SS_Cache::set_cache_lifetime('MINIFY_CACHE_BACKEND', MINIFY_CACHE_LIFETIME, 100);
        SS_Cache::pick_backend('MINIFY_CACHE_BACKEND', 'MINIFY_CACHE', 100);
    }
}
开发者ID:andrelohmann,项目名称:silverstripe-minify,代码行数:12,代码来源:_config.php


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