本文整理汇总了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();
}
示例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');
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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');
}
}
示例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');
}
}
}
}
示例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();
}
示例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>";
}
}
示例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");
}
}
示例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');
}
}
示例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");
}
}
示例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");
}
}
示例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();
}
}