本文整理匯總了PHP中sfContext::getStorage方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfContext::getStorage方法的具體用法?PHP sfContext::getStorage怎麽用?PHP sfContext::getStorage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfContext
的用法示例。
在下文中一共展示了sfContext::getStorage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initialize
/**
* Initialize this User.
*
* @param sfContext $context A Context instance.
* @param array $parameters An associative array of initialization parameters.
*
* @return bool true, if initialization completes successfully, otherwise
* false.
*
* @throws <b>sfInitializationException</b> If an error occurs while initializing this User.
*/
public function initialize($context, $parameters = array())
{
$this->context = $context;
$this->parameterHolder = new sfParameterHolder();
$this->parameterHolder->add($parameters);
$this->attributeHolder = new sfParameterHolder(self::ATTRIBUTE_NAMESPACE);
// read attributes from storage
$attributes = $context->getStorage()->read(self::ATTRIBUTE_NAMESPACE);
if (is_array($attributes)) {
foreach ($attributes as $namespace => $values) {
$this->attributeHolder->add($values, $namespace);
}
}
// set the user culture to sf_culture parameter if present in the request
// otherwise
// - use the culture defined in the user session
// - use the default culture set in i18n.yml
if (!($culture = $context->getRequest()->getParameter('sf_culture'))) {
if (null === ($culture = $context->getStorage()->read(self::CULTURE_NAMESPACE))) {
$culture = sfConfig::get('sf_i18n_default_culture', 'en');
}
}
$this->setCulture($culture);
}