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


PHP sfStorage::newInstance方法代碼示例

本文整理匯總了PHP中sfStorage::newInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfStorage::newInstance方法的具體用法?PHP sfStorage::newInstance怎麽用?PHP sfStorage::newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfStorage的用法示例。


在下文中一共展示了sfStorage::newInstance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: initialize

 protected function initialize()
 {
     $this->logger = sfLogger::getInstance();
     if (sfConfig::get('sf_logging_enabled')) {
         $this->logger->info('{sfContext} initialization');
     }
     if (sfConfig::get('sf_use_database')) {
         $this->databaseManager = new sfDatabaseManager();
         $this->databaseManager->initialize();
     }
     $this->actionStack = new sfActionStack();
     // 'config/factories.yml' config file
     // auto-generated by sfFactoryConfigHandler
     // date: 2015/09/01 13:56:04
     $this->controller = sfController::newInstance(sfConfig::get('sf_factory_controller', 'sfFrontWebController'));
     $this->request = sfRequest::newInstance(sfConfig::get('sf_factory_request', 'sfWebRequest'));
     $this->response = sfResponse::newInstance(sfConfig::get('sf_factory_response', 'sfWebResponse'));
     $this->storage = sfStorage::newInstance(sfConfig::get('sf_factory_storage', 'sfSessionStorage'));
     $this->user = sfUser::newInstance(sfConfig::get('sf_factory_user', 'myUser'));
     $this->controller->initialize($this);
     $this->request->initialize($this, sfConfig::get('sf_factory_request_parameters', NULL), sfConfig::get('sf_factory_request_attributes', array()));
     $this->response->initialize($this, sfConfig::get('sf_factory_response_parameters', NULL));
     $this->storage->initialize($this, sfConfig::get('sf_factory_storage_parameters', array('session_name' => 'symfony')));
     $this->user->initialize($this, sfConfig::get('sf_factory_user_parameters', NULL));
     if (sfConfig::get('sf_cache')) {
         $this->viewCacheManager = new sfViewCacheManager();
         $this->viewCacheManager->initialize($this, sfConfig::get('sf_factory_view_cache', 'sfFileCache'), sfConfig::get('sf_factory_view_cache_parameters', array('automaticCleaningFactor' => 0, 'cacheDir' => '/Applications/MAMP/trademark/cache/backend/prod/template')));
     }
     register_shutdown_function(array($this, 'shutdown'));
 }
開發者ID:kotow,項目名稱:work,代碼行數:30,代碼來源:config_core_compile.yml.php

示例2: array

<?php

// auto-generated by sfFactoryConfigHandler
// date: 2009/08/15 10:45:03
$this->controller = sfController::newInstance(sfConfig::get('sf_factory_controller', 'sfFrontWebController'));
$this->request = sfRequest::newInstance(sfConfig::get('sf_factory_request', 'sfWebRequest'));
$this->response = sfResponse::newInstance(sfConfig::get('sf_factory_response', 'sfWebResponse'));
$this->storage = sfStorage::newInstance(sfConfig::get('sf_factory_storage', 'sfSessionStorage'));
$this->user = sfUser::newInstance(sfConfig::get('sf_factory_user', 'myUser'));
$this->controller->initialize($this);
$this->request->initialize($this, sfConfig::get('sf_factory_request_parameters', NULL), sfConfig::get('sf_factory_request_attributes', array()));
$this->response->initialize($this, sfConfig::get('sf_factory_response_parameters', NULL));
$this->storage->initialize($this, sfConfig::get('sf_factory_storage_parameters', array('session_name' => 'symfony')));
$this->user->initialize($this, sfConfig::get('sf_factory_user_parameters', NULL));
if (sfConfig::get('sf_cache')) {
    $this->viewCacheManager = new sfViewCacheManager();
    $this->viewCacheManager->initialize($this, sfConfig::get('sf_factory_view_cache', 'sfFileCache'), sfConfig::get('sf_factory_view_cache_parameters', array('automaticCleaningFactor' => 0, 'cacheDir' => '/Users/takizo/Sites/coscupdemo/cache/frontend/dev/template')));
}
開發者ID:noreplied,項目名稱:Coscup-Demo,代碼行數:18,代碼來源:config_factories.yml.php

示例3: getStorage

    {
        return $this->user;
    }
    public function getStorage()
    {
        return $this->storage;
    }
}
$t = new lime_test(33, new lime_output_color());
$_SERVER['session_id'] = 'test';
sfConfig::set('sf_test_cache_dir', sfToolkit::getTmpDir());
$context = new sfContext();
$request = new sfWebRequest();
$request->initialize($context);
$context->request = $request;
$storage = sfStorage::newInstance('sfSessionTestStorage');
$storage->initialize($context);
$storage->clear();
$context->storage = $storage;
$user = new sfUser();
$user->initialize($context);
$context->user = $user;
// ->initialize()
$t->diag('->initialize()');
$t->is($user->getCulture(), 'en', '->initialize() sets the culture to "en" by default');
sfConfig::set('sf_i18n_default_culture', 'de');
$user->setCulture(null);
user_flush($context);
$t->is($user->getCulture(), 'de', '->initialize() sets the culture to the value of sf_i18n_default_culture if available');
sfConfig::set('sf_i18n_default_culture', 'fr');
user_flush($context);
開發者ID:valerio-bozzolan,項目名稱:openparlamento,代碼行數:31,代碼來源:sfUserTest.php

示例4: getStorage

 public function getStorage()
 {
     $storage = sfStorage::newInstance('sfSessionTestStorage');
     $storage->initialize($this);
     return $storage;
 }
開發者ID:valerio-bozzolan,項目名稱:openparlamento,代碼行數:6,代碼來源:sfContextMock.class.php

示例5: sfContext

{
}
$context = new sfContext();
$storage = new myStorage();
$storage->initialize($context);
// ::newInstance()
$t->diag('::newInstance()');
$t->isa_ok(sfStorage::newInstance('myStorage'), 'myStorage', '::newInstance() takes a storage class as its first parameter');
$t->isa_ok(sfStorage::newInstance('myStorage'), 'myStorage', '::newInstance() returns an instance of myStorage');
try {
    sfStorage::newInstance('fakeStorage');
    $t->fail('::newInstance() throws a sfFactoryException if the class does not extends sfStorage');
} catch (sfFactoryException $e) {
    $t->pass('::newInstance() throws a sfFactoryException if the class does not extends sfStorage');
}
// ->initialize()
$t->diag('->initialize()');
$storage = sfStorage::newInstance('myStorage');
$t->is($storage->getContext(), null, '->initialize() takes a sfContext object as its first argument');
$storage->initialize($context, array('foo' => 'bar'));
$t->is($storage->getParameter('foo'), 'bar', '->initialize() takes an array of parameters as its second argument');
$storage = new myStorage();
$storage->initialize($context);
// ->getContext()
$t->diag('->getContext()');
$storage->initialize($context);
$t->is($storage->getContext(), $context, '->getContext() returns the current context');
// parameter holder proxy
require_once $_test_dir . '/unit/sfParameterHolderTest.class.php';
$pht = new sfParameterHolderProxyTest($t);
$pht->launchTests($storage, 'parameter');
開發者ID:valerio-bozzolan,項目名稱:openparlamento,代碼行數:31,代碼來源:sfStorageTest.php


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