当前位置: 首页>>代码示例>>PHP>>正文


PHP DataObject::requireDefaultRecords方法代码示例

本文整理汇总了PHP中DataObject::requireDefaultRecords方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::requireDefaultRecords方法的具体用法?PHP DataObject::requireDefaultRecords怎么用?PHP DataObject::requireDefaultRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataObject的用法示例。


在下文中一共展示了DataObject::requireDefaultRecords方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Make sure the syncrotron identifier is initially set.
     $configuration = SiteConfig::current_site_config();
     $configuration->getSyncroIdentifier();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-syncrotron,代码行数:7,代码来源:RemoteSyncroNode.php

示例2: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!ProductWeight::get()->exists()) {
         $weight = new ProductWeight();
         $weight->Title = "Kilograms";
         $weight->Unit = "kg";
         $weight->write();
         $weight->flushCache();
         DB::alteration_message('Kilograms weight created', 'created');
         $weight = new ProductWeight();
         $weight->Title = "Grams";
         $weight->Unit = "g";
         $weight->write();
         $weight->flushCache();
         DB::alteration_message('Grams weight created', 'created');
         $weight = new ProductWeight();
         $weight->Title = "Pound";
         $weight->Unit = "lb";
         $weight->write();
         $weight->flushCache();
         DB::alteration_message('Pounds weight created', 'created');
         $weight = new ProductWeight();
         $weight->Title = "Ounce";
         $weight->Unit = "oz";
         $weight->write();
         $weight->flushCache();
         DB::alteration_message('Ounces weight created', 'created');
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:30,代码来源:ProductWeight.php

示例3: requireDefaultRecords

 /**
  *	The process to automatically construct data object output configurations, executed on project build.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Grab the list of data objects that have been completely removed.
     foreach (DB::getConn()->tableList() as $table) {
         // Delete existing output configurations for these data objects.
         if (!class_exists($table)) {
             $existing = DataObjectOutputConfiguration::get_one('DataObjectOutputConfiguration', "IsFor = '" . Convert::raw2sql($table) . "'");
             $this->deleteConfiguration($table, $existing);
         }
     }
     // Grab the list of all data object types, along with any inclusions/exclusions defined.
     $objects = ClassInfo::subclassesFor('DataObject');
     $inclusions = self::$custom_inclusions;
     $exclusions = array_unique(array_merge(self::$exclusions, self::$custom_exclusions));
     // Check existing output configurations for these data objects.
     foreach ($objects as $object) {
         $existing = DataObjectOutputConfiguration::get_one('DataObjectOutputConfiguration', "IsFor = '" . Convert::raw2sql($object) . "'");
         // Delete existing output configurations for invalid data objects, or for those excluded.
         if ($existing && (self::$disabled || get_parent_class($object) !== 'DataObject' || ClassInfo::classImplements($object, 'TestOnly') || count($inclusions) > 0 && !in_array($object, $inclusions) || count($inclusions) === 0 && in_array($object, $exclusions))) {
             $this->deleteConfiguration($object, $existing);
         } else {
             if (!$existing && !self::$disabled && get_parent_class($object) === 'DataObject' && !ClassInfo::classImplements($object, 'TestOnly') && (count($inclusions) > 0 && in_array($object, $inclusions) || count($inclusions) === 0 && !in_array($object, $exclusions))) {
                 $this->addConfiguration($object);
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:31,代码来源:DataObjectOutputConfiguration.php

示例4: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $existing = DataObject::get('AccessRole');
     if ($existing && $existing->count()) {
         return;
     }
     $dp = self::allPermissions();
     $role = new AccessRole();
     $role->Title = 'Admin';
     $role->Composes = array_values($dp);
     $role->write();
     $ownerPerms = $dp;
     // get rid of publish from owners
     unset($ownerPerms['Publish']);
     $role = new AccessRole();
     $role->Title = 'Owner';
     $role->Composes = array_keys($ownerPerms);
     $role->write();
     unset($dp['TakeOwnership']);
     unset($dp['Configure']);
     $role = new AccessRole();
     $role->Title = 'Manager';
     $role->Composes = array_keys($dp);
     $role->write();
     $role = new AccessRole();
     $role->Title = 'Editor';
     $role->Composes = array('View', 'Write', 'CreateChildren');
     $role->write();
 }
开发者ID:nyeholt,项目名称:silverstripe-restrictedobjects,代码行数:30,代码来源:AccessRole.php

示例5: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // create a catch-all group
     if (!OptionGroup::get()->filter(array('Title' => 'Options'))->first()) {
         $do = new OptionGroup();
         $do->Title = "Options";
         $do->write();
     }
     if (!OptionGroup::get()->filter(array('Title' => 'Size'))->first()) {
         $do = new OptionGroup();
         $do->Title = "Size";
         $do->write();
     }
     if (!OptionGroup::get()->filter(array('Title' => 'Color'))->first()) {
         $do = new OptionGroup();
         $do->Title = "Color";
         $do->write();
     }
     if (!OptionGroup::get()->filter(array('Title' => 'Type'))->first()) {
         $do = new OptionGroup();
         $do->Title = "Type";
         $do->write();
     }
 }
开发者ID:helpfulrobot,项目名称:dynamic-foxystripe,代码行数:25,代码来源:OptionGroup.php

示例6: requireDefaultRecords

 public function requireDefaultRecords()
 {
     // If no tax rates, setup some defaults
     if (!TaxRate::get()->exists()) {
         $vat = TaxRate::create();
         $vat->Title = "VAT";
         $vat->Amount = 20;
         $vat->Code = "T1";
         $vat->write();
         DB::alteration_message('VAT tax rate created.', 'created');
         $reduced = TaxRate::create();
         $reduced->Title = "Reduced rate";
         $reduced->Amount = 5;
         $reduced->Code = "T2";
         $reduced->write();
         DB::alteration_message('Reduced tax rate created.', 'created');
         $zero = TaxRate::create();
         $zero->Title = "Zero rate";
         $zero->Amount = 0;
         $zero->Code = "T4";
         $zero->write();
         DB::alteration_message('Zero tax rate created.', 'created');
     }
     parent::requireDefaultRecords();
 }
开发者ID:alialamshahi,项目名称:silverstripe-catalogue-prowall,代码行数:25,代码来源:TaxRate.php

示例7: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!CommerceCurrency::get()->exists()) {
         $gbp = new CommerceCurrency();
         $gbp->Title = "UK Pounds";
         $gbp->HTMLNotation = "£";
         $gbp->GatewayCode = "GBP";
         $gbp->write();
         $gbp->flushCache();
         DB::alteration_message('UK Pounds created', 'created');
         $eur = new CommerceCurrency();
         $eur->Title = "Euro";
         $eur->HTMLNotation = "€";
         $eur->GatewayCode = "EUR";
         $eur->write();
         $eur->flushCache();
         DB::alteration_message('Euro created', 'created');
         $usd = new CommerceCurrency();
         $usd->Title = "US Dollars";
         $usd->HTMLNotation = "$";
         $usd->GatewayCode = "USD";
         $usd->write();
         $usd->flushCache();
         DB::alteration_message('US Dollars created', 'created');
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:27,代码来源:CommerceCurrency.php

示例8: requireDefaultRecords

 /**
  *	The process to automatically consolidate existing and configuration defined tag types, executed on project build.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Retrieve existing and configuration defined tag types that have not been consolidated.
     foreach ($this->service->getFusionTagTypes() as $type => $field) {
         if (($tags = $type::get()->filter('FusionTagID', 0)) && $tags->exists()) {
             foreach ($tags as $tag) {
                 // Determine whether there's an existing fusion tag.
                 if (!($existing = FusionTag::get()->filter('Title', $tag->{$field})->first())) {
                     // There is no fusion tag, therefore instantiate one using the current tag.
                     $fusion = FusionTag::create();
                     $fusion->Title = $tag->{$field};
                     $fusion->TagTypes = serialize(array($tag->ClassName => $tag->ClassName));
                     $fusion->write();
                     $fusionID = $fusion->ID;
                 } else {
                     // There is a fusion tag, therefore append the current tag type.
                     $types = unserialize($existing->TagTypes);
                     $types[$tag->ClassName] = $tag->ClassName;
                     $existing->TagTypes = serialize($types);
                     $existing->write();
                     $fusionID = $existing->ID;
                 }
                 // Update the current tag to point to this.
                 $tag->FusionTagID = $fusionID;
                 $tag->write();
                 DB::alteration_message("\"{$tag->{$field}}\" Fusion Tag", 'created');
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-fusion,代码行数:34,代码来源:FusionTag.php

示例9: requireDefaultRecords

 /**
  * When rebuilding the database we need to ensure that all the threads have been assigned
  * a last post and when people upgrade to this version running the rebuild should fix the data
  * rather than the entire migrate script
  *
  * @return void
  */
 function requireDefaultRecords()
 {
     if (DB::query("SELECT COUNT(*) FROM \"ForumThread\" WHERE \"LastPostID\" = 0")->value() > 0) {
         $migrate = new ForumMigrationTask();
         $migrate->attachLastPostIDs();
     }
     parent::requireDefaultRecords();
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:15,代码来源:ForumThread.php

示例10: requireDefaultRecords

 /**
  * Migrate data from Member_UnsubscribeRecord (the obsolete table)
  * to UnsubscribeRecord.
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (in_array('Email_BlackList', DB::getConn()->tableList())) {
         DB::query("INSERT INTO \"UnsubscribeRecord\" SELECT * FROM \"Member_UnsubscribeRecord\"");
         DB::query("RENAME TABLE \"Member_UnsubscribeRecord\" TO \"_obsolete_Member_UnsubscribeRecord\"");
         echo "<div style=\"padding:5px; color:white; background-color:blue;\">Data in Member_UnsubscribeRecord has been moved to the new UnsubscribeRecord table. To drop the obsolete table, issue this SQL command: \"DROP TABLE '_obsolete_Member_UnsubscribeRecord'\".</div>";
     }
 }
开发者ID:nyeholt,项目名称:silverstripe-newsletter,代码行数:13,代码来源:UnsubscribeRecord.php

示例11: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $moduleManager = DataObject::get_one('ModuleManager');
     if (!$moduleManager) {
         self::make_module_manager();
         DB::alteration_message("Added default module manager", "created");
     }
 }
开发者ID:jaedb,项目名称:modulemanager,代码行数:9,代码来源:ModuleManager.php

示例12: requireDefaultRecords

 /**
  * Setup a default ShopConfig record if none exists
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!self::current_shop_config()) {
         $shopConfig = new ShopConfig();
         $shopConfig->write();
         DB::alteration_message('Added default shop config', 'created');
     }
 }
开发者ID:vinstah,项目名称:body,代码行数:12,代码来源:ShopConfig.php

示例13: requireDefaultRecords

 /**
  * Setup a default SiteDesigner record if none exists
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $siteDesigner = DataObject::get_one('SiteDesigner');
     if (!$siteDesigner) {
         self::make_site_designer();
         DB::alteration_message("Added default site designer", "created");
     }
 }
开发者ID:helpfulrobot,项目名称:toastnz-silverstripe-site-designer,代码行数:12,代码来源:SiteDesigner.php

示例14: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $moduleManager = ModuleManager::get()->First();
     if (!$moduleManager) {
         self::make_module_manager();
         DB::alteration_message("Added default module manager", "created");
     }
 }
开发者ID:helpfulrobot,项目名称:jaedb-modulemanager,代码行数:9,代码来源:ModuleManager.php

示例15: requireDefaultRecords

 /**
  * {@inheritdoc}
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // run the population task if required.
     if (PopulateTimeZonesTask::config()->run_during_dev_build) {
         $task = new PopulateTimeZonesTask();
         $task->up();
     }
 }
开发者ID:spekulatius,项目名称:silverstripe-timezones,代码行数:12,代码来源:TimeZoneData.php


注:本文中的DataObject::requireDefaultRecords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。