本文整理汇总了PHP中sfDoctrineRecord::setDefaultCulture方法的典型用法代码示例。如果您正苦于以下问题:PHP sfDoctrineRecord::setDefaultCulture方法的具体用法?PHP sfDoctrineRecord::setDefaultCulture怎么用?PHP sfDoctrineRecord::setDefaultCulture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfDoctrineRecord
的用法示例。
在下文中一共展示了sfDoctrineRecord::setDefaultCulture方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDocument
public function getDocument()
{
if (!$this->shouldIndex()) {
$this->getSearch()->getEventDispatcher()->notify(new sfEvent($this, 'indexer.log', array('model "%s" cancelled indexation - primary key = %s', $this->getModelName(), current($this->getModel()->identifier()))));
return false;
}
$old_culture = null;
// automatic symfony i18n detection
if ($this->getModel()->getTable()->hasRelation('Translation')) {
$old_culture = sfDoctrineRecord::getDefaultCulture();
sfDoctrineRecord::setDefaultCulture($this->getSearch()->getParameter('culture'));
}
// build document
$doc = $this->getBaseDocument();
$doc = $this->configureDocumentFields($doc);
//$doc = $this->configureDocumentCategories($doc);
$doc = $this->configureDocumentMetas($doc);
// add document
$doc->setField('sfl_guid', $this->getModelGuid());
// restore culture in symfony i18n detection
if ($old_culture) {
sfDoctrineRecord::setDefaultCulture($old_culture);
}
return $doc;
}
示例2: updateDatabase
/**
* Update changed documentation pages in database
*/
protected function updateDatabase($branch)
{
$types = dmDb::query('Doc d')->select('d.type')->distinct()->fetchFlat();
$cultures = sfConfig::get('dm_i18n_cultures');
$originalCulture = sfDoctrineRecord::getDefaultCulture();
foreach ($types as $type) {
foreach ($cultures as $culture) {
sfDoctrineRecord::setDefaultCulture($culture);
$dir = dmOs::join($this->repo->getDir(), $type, $culture);
$files = sfFinder::type('file')->name('/^\\d{2}\\s-\\s.+\\.markdown$/')->in($dir);
foreach ($files as $file) {
$docName = preg_replace('/^\\d{2}\\s-\\s(.+)\\.markdown$/', '$1', basename($file));
$docRecord = dmDb::query('DocPage dp')->withI18n()->innerJoin('dp.Doc doc')->innerJoin('doc.Branch branch')->where('branch.number = ?', $branch)->andWhere('doc.type = ?', $type)->andWhere('dpTranslation.name = ?', $docName)->fetchOne();
if ($docRecord) {
$docText = file_get_contents($file);
if ($docRecord->text != $docText) {
$docRecord->text = $docText;
$docRecord->save();
}
}
}
}
}
sfDoctrineRecord::setDefaultCulture($originalCulture);
}
示例3: dirname
<?php
include_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
include_once dirname(__FILE__) . '/../../../bootstrap/database.php';
sfContext::createInstance($configuration);
sfDoctrineRecord::setDefaultCulture('ja_JP');
$t = new lime_test(5, new lime_output_color());
//------------------------------------------------------------
$t->diag('NotificationMailTable');
$t->diag('NotificationMailTable::getDisabledNotificationNames()');
$result = Doctrine::getTable('NotificationMail')->getDisabledNotificationNames();
$t->is($result, array('name2'));
$t->diag('NotificationMailTable::fetchTemplate()');
$result = Doctrine::getTable('NotificationMail')->fetchTemplate('name1');
$t->isa_ok($result, 'NotificationMail');
$result = Doctrine::getTable('NotificationMail')->fetchTemplate('pc_changeMailAddress');
$t->isa_ok($result, 'NotificationMail');
$result = Doctrine::getTable('NotificationMail')->fetchTemplate('aaaaa');
$t->cmp_ok(false, '===', $result);
$t->diag('NotificationMailTable::getConfigs()');
$result = Doctrine::getTable('NotificationMail')->getConfigs();
$t->isa_ok($result, 'array');
示例4: setCulture
public function setCulture($culture)
{
sfDoctrineRecord::setDefaultCulture($culture);
return $this->get('/', array('sf_culture' => $culture));
}