本文整理汇总了PHP中myDoctrineRecord类的典型用法代码示例。如果您正苦于以下问题:PHP myDoctrineRecord类的具体用法?PHP myDoctrineRecord怎么用?PHP myDoctrineRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了myDoctrineRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPageTranslations
protected function createPageTranslations($pageId)
{
$cultures = $this->getOption('cultures');
$translationTable = dmDb::table('DmPageTranslation');
$existingCultures = $translationTable->createQuery('t')->where('t.id = ? ', $pageId)->andWhereIn('t.lang', $cultures)->select('t.lang')->fetchFlat();
// can not generate translations from nothing
if (empty($existingCultures)) {
return;
}
// calculate missing cultures for this page
$missingCultures = array_diff($cultures, $existingCultures);
// all translations exist
if (empty($missingCultures)) {
return;
}
if (in_array(sfConfig::get('sf_default_culture'), $existingCultures)) {
$mainCulture = sfConfig::get('sf_default_culture');
} elseif (in_array(myDoctrineRecord::getDefaultCulture(), $existingCultures)) {
$mainCulture = myDoctrineRecord::getDefaultCulture();
} else {
$mainCulture = dmArray::first($existingCultures);
}
$mainTranslationArray = $translationTable->createQuery('t')->select('t.slug, t.name, t.title, t.h1, t.description, t.keywords, t.is_active')->where('t.id = ?', $pageId)->andWhere('t.lang = ?', $mainCulture)->limit(1)->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);
$missingTranslations = new myDoctrineCollection(dmDb::table('DmPageTranslation'));
if ($this->getOption('activate_new_translations')) {
$isActive = $mainTranslationArray['is_active'];
} else {
$isActive = false;
}
foreach ($missingCultures as $culture) {
$missingTranslations->add($translationTable->create(array_merge($mainTranslationArray, array('lang' => $culture, 'is_active' => $isActive))));
}
$missingTranslations->save();
}
示例2: filterSet
/**
* Implementation of filterSet() to call set on Translation relationship to allow
* access to I18n properties from the main object.
*
* @param Doctrine_Record $record
* @param string $name Name of the property
* @param string $value Value of the property
* @return void
*/
public function filterSet(Doctrine_Record $record, $fieldName, $value)
{
$translation = $record->get('Translation');
$culture = myDoctrineRecord::getDefaultCulture();
if ($translation->contains($culture)) {
$i18n = $record->get('Translation')->get($culture);
} else {
$i18n = $record->get('Translation')->get($culture);
/*
* If translation is new
* populate it with i18n fallback
*/
if ($i18n->state() == Doctrine_Record::STATE_TDIRTY) {
if ($fallback = $record->getI18nFallBack()) {
$fallBackData = $fallback->toArray();
unset($fallBackData['id'], $fallBackData['lang']);
$i18n->fromArray($fallBackData);
}
}
}
if (!ctype_lower($fieldName) && !$i18n->contains($fieldName)) {
$underscoredFieldName = dmString::underscore($fieldName);
if (strpos($underscoredFieldName, '_') !== false && $i18n->contains($underscoredFieldName)) {
$fieldName = $underscoredFieldName;
}
}
$i18n->set($fieldName, $value);
return $value;
}
示例3: withI18n
/**
* Join translation results if they exist
* if $model is specified, will verify that it has I18n
* return @myDoctrineQuery $this
*/
public function withI18n($culture = null, $model = null, $rootAlias = null, $joinSide = 'left')
{
if (null === $model) {
$_rootAlias = $this->getRootAlias();
$from = explode(' ', $this->_dqlParts['from'][0]);
$model = $from[0];
if (strlen($model) === 0) {
$this->getRootAlias();
$models = array_keys($this->_queryComponents);
$model = $models[0];
}
}
if (!dmDb::table($model)->hasI18n()) {
return $this;
}
$culture = null === $culture ? myDoctrineRecord::getDefaultCulture() : $culture;
if (null === $rootAlias) {
// refresh query for introspection
if (empty($this->_execParams)) {
//prevent bugs for subqueries
$this->fixArrayParameterValues($this->_params);
}
$this->buildSqlQuery();
$rootAlias = $this->getRootAlias();
$translationAlias = $rootAlias . 'Translation';
// i18n already joined
if ($this->hasAliasDeclaration($translationAlias)) {
return $this;
}
} else {
$translationAlias = $rootAlias . 'Translation';
}
$joinMethod = $joinSide . 'Join';
return $this->{$joinMethod}($rootAlias . '.Translation ' . $translationAlias . ' ON ' . $rootAlias . '.id = ' . $translationAlias . '.id AND ' . $translationAlias . '.lang = ?', $culture);
}
示例4: factory
public static function factory(myDoctrineRecord $record, $local, $alias, $required)
{
/*
* Check first is local column has a value
* not to modify the record
*/
if ($record->get($local)) {
$media = $record->get($alias);
} else {
$media = new DmMedia();
$media->set('dm_media_folder_id', $record->getDmMediaFolder()->get('id'));
}
$form = new self($media);
$form->configureRequired($required);
$form->setRecord($record);
return $form;
}
示例5: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('PetitionApiToken as ApiToken', array('local' => 'petition_api_token_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$timestampable0 = new Doctrine_Template_Timestampable(array());
$this->actAs($timestampable0);
}
示例6: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('Petition', array('local' => 'petition_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasMany('PledgeText as PledgeTexts', array('local' => 'id', 'foreign' => 'pledge_item_id'));
$this->hasMany('Pledge as Pledges', array('local' => 'id', 'foreign' => 'pledge_item_id'));
}
示例7: setUp
public function setUp()
{
parent::setUp();
$this->hasMany('Group as Groups', array('refClass' => 'UserGroup', 'local' => 'user_id', 'foreign' => 'group_id'));
$this->hasMany('Permission as Permissions', array('refClass' => 'UserPermission', 'local' => 'user_id', 'foreign' => 'permission_id'));
$this->hasOne('Profile', array('local' => 'id', 'foreign' => 'user_id'));
}
示例8: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('DmLayout as Layout', array('local' => 'dm_layout_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasOne('DmPageView as PageView', array('local' => 'dm_page_view_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasMany('DmZone as Zones', array('local' => 'id', 'foreign' => 'dm_area_id'));
}
示例9: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('MailingListMeta', array('local' => 'mailing_list_meta_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasOne('Contact', array('local' => 'contact_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasOne('MailingListMetaChoice', array('local' => 'mailing_list_meta_choice_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
}
示例10: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('DmMailTemplate as Template', array('local' => 'dm_mail_template_id', 'foreign' => 'id', 'onDelete' => 'SET NULL'));
$timestampable0 = new Doctrine_Template_Timestampable(array('updated' => array('disabled' => true)));
$this->actAs($timestampable0);
}
示例11: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('Mapping', array('local' => 'mapping_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$cachetaggable0 = new Doctrine_Template_Cachetaggable();
$this->actAs($cachetaggable0);
}
示例12: setUp
public function setUp()
{
parent::setUp();
$this->hasMany('DmMedia as Medias', array('local' => 'id', 'foreign' => 'dm_media_folder_id'));
$nestedset0 = new Doctrine_Template_NestedSet(array());
$this->actAs($nestedset0);
}
示例13: setUp
public function setUp()
{
parent::setUp();
$this->hasMany('MappingPair as Pairs', array('local' => 'id', 'foreign' => 'mapping_id'));
$cachetaggable0 = new Doctrine_Template_Cachetaggable();
$this->actAs($cachetaggable0);
}
示例14: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('DmArea as Area', array('local' => 'dm_area_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasMany('DmWidget as Widgets', array('local' => 'id', 'foreign' => 'dm_zone_id'));
$sortable0 = new Doctrine_Template_Sortable(array());
$this->actAs($sortable0);
}
示例15: setUp
public function setUp()
{
parent::setUp();
$nestedset0 = new Doctrine_Template_NestedSet();
$i18n0 = new Doctrine_Template_I18n(array('fields' => array(0 => 'slug', 1 => 'name', 2 => 'title', 3 => 'h1', 4 => 'description', 5 => 'keywords', 6 => 'auto_mod', 7 => 'is_active', 8 => 'is_secure', 9 => 'is_indexable')));
$this->actAs($nestedset0);
$this->actAs($i18n0);
}