本文整理汇总了PHP中myDoctrineRecord类的典型用法代码示例。如果您正苦于以下问题:PHP myDoctrineRecord类的具体用法?PHP myDoctrineRecord怎么用?PHP myDoctrineRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了myDoctrineRecord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:theolymp,项目名称:diem,代码行数:34,代码来源:dmPageI18nBuilder.php
示例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;
}
开发者ID:theolymp,项目名称:diem,代码行数:38,代码来源:dmDoctrineRecordI18nFilter.class.php
示例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);
}
开发者ID:theolymp,项目名称:diem,代码行数:40,代码来源:dmDoctrineQuery.php
示例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;
}
开发者ID:hboers,项目名称:diem,代码行数:17,代码来源:DmMediaForRecordForm.php
示例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);
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:7,代码来源:BaseApiTokenOffset.class.php
示例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'));
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:7,代码来源:BasePledgeItem.class.php
示例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'));
}
开发者ID:yasirgit,项目名称:afids,代码行数:7,代码来源:BaseUser.class.php
示例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'));
}
开发者ID:theolymp,项目名称:diem,代码行数:7,代码来源:BaseDmArea.class.php
示例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'));
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:7,代码来源:BaseContactMeta.class.php
示例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);
}
开发者ID:theolymp,项目名称:diem,代码行数:7,代码来源:BaseDmSentMail.class.php
示例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);
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:7,代码来源:BaseMappingPair.class.php
示例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);
}
开发者ID:theolymp,项目名称:diem,代码行数:7,代码来源:BaseDmMediaFolder.class.php
示例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);
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:7,代码来源:BaseMapping.class.php
示例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);
}
开发者ID:theolymp,项目名称:diem,代码行数:8,代码来源:BaseDmZone.class.php
示例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);
}
开发者ID:rafaelgou,项目名称:diem,代码行数:8,代码来源:BaseDmPage.class.php
示例16: setUp
public function setUp()
{
parent::setUp();
$this->hasMany('DmUser as Users', array('refClass' => 'DmUserPermission', 'local' => 'dm_permission_id', 'foreign' => 'dm_user_id'));
$this->hasMany('DmGroup as Groups', array('refClass' => 'DmGroupPermission', 'local' => 'dm_permission_id', 'foreign' => 'dm_group_id'));
$timestampable0 = new Doctrine_Template_Timestampable(array());
$this->actAs($timestampable0);
}
开发者ID:theolymp,项目名称:diem,代码行数:8,代码来源:BaseDmPermission.class.php
示例17: setUp
public function setUp()
{
parent::setUp();
$this->hasMany('Member', array('refClass' => 'GroupMember', 'local' => 'group_id', 'foreign' => 'member_id'));
$this->hasMany('Permission', array('refClass' => 'GroupPermission', 'local' => 'group_id', 'foreign' => 'permission_id'));
$this->hasMany('GroupPermission', array('local' => 'id', 'foreign' => 'group_id'));
$this->hasMany('GroupMember', array('local' => 'id', 'foreign' => 'group_id'));
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:8,代码来源:BaseGroup.class.php
示例18: setUp
public function setUp()
{
parent::setUp();
$this->hasOne('sfGuardGroup as Group', array('local' => 'group_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$this->hasOne('sfGuardPermission as Permission', array('local' => 'permission_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$timestampable0 = new Doctrine_Template_Timestampable(array());
$this->actAs($timestampable0);
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:8,代码来源:BasesfGuardGroupPermission.class.php
示例19: setUp
public function setUp()
{
parent::setUp();
$timestampable0 = new Doctrine_Template_Timestampable(array());
$cachetaggable0 = new Doctrine_Template_Cachetaggable(array());
$this->actAs($timestampable0);
$this->actAs($cachetaggable0);
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:8,代码来源:BaseRegistry.class.php
示例20: setUp
public function setUp()
{
parent::setUp();
$timestampable0 = new Doctrine_Template_Timestampable();
$i18n0 = new Doctrine_Template_I18n(array('fields' => array(0 => 'slug', 1 => 'name', 2 => 'title', 3 => 'h1', 4 => 'description', 5 => 'keywords', 6 => 'strip_words')));
$this->actAs($timestampable0);
$this->actAs($i18n0);
}
开发者ID:jdart,项目名称:diem,代码行数:8,代码来源:BaseDmAutoSeo.class.php
注:本文中的myDoctrineRecord类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论