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


PHP myDoctrineRecord類代碼示例

本文整理匯總了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();
 }
開發者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


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