mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Add new regenerate_on_build
This commit is contained in:
parent
be8b3923cc
commit
c754116963
@ -1,3 +1,13 @@
|
|||||||
|
---
|
||||||
|
Name: frameworktest-extensions
|
||||||
|
---
|
||||||
|
SilverStripe\ORM\DataObject:
|
||||||
|
extensions:
|
||||||
|
- DevBuildGeneratorExtension
|
||||||
|
SilverStripe\Assets\File:
|
||||||
|
extensions:
|
||||||
|
- BasicFieldsTestFileExtension
|
||||||
|
|
||||||
---
|
---
|
||||||
Only:
|
Only:
|
||||||
classexists: 'DNADesign\Elemental\Extensions\ElementalPageExtension'
|
classexists: 'DNADesign\Elemental\Extensions\ElementalPageExtension'
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
Name: frameworktestpages
|
|
||||||
---
|
|
||||||
SilverStripe\Assets\File:
|
|
||||||
extensions:
|
|
||||||
- BasicFieldsTestFileExtension
|
|
@ -110,11 +110,10 @@ class BasicFieldsTestPage extends TestPage
|
|||||||
{
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
if ($inst = DataObject::get_one('BasicFieldsTestPage')) {
|
if ($inst = DataObject::get_one('BasicFieldsTestPage') && static::config()->get('regenerate_on_build')) {
|
||||||
$data = $this->getDefaultData();
|
$data = $this->getDefaultData();
|
||||||
$inst->update($data);
|
$inst->update($data);
|
||||||
$inst->write();
|
$inst->write();
|
||||||
|
|
||||||
TestCategory::create()->requireDefaultRecords();
|
TestCategory::create()->requireDefaultRecords();
|
||||||
$cats = TestCategory::get();
|
$cats = TestCategory::get();
|
||||||
$firstCat = $cats->offsetGet(0);
|
$firstCat = $cats->offsetGet(0);
|
||||||
|
@ -6,10 +6,10 @@ use SilverStripe\Assets\Image;
|
|||||||
use SilverStripe\Forms\DropdownField;
|
use SilverStripe\Forms\DropdownField;
|
||||||
use SilverStripe\ORM\HasManyList;
|
use SilverStripe\ORM\HasManyList;
|
||||||
use SilverStripe\ORM\ManyManyList;
|
use SilverStripe\ORM\ManyManyList;
|
||||||
use SilverStripe\ORM\ValidationResult;
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\AssetAdmin\Forms\UploadField;
|
use SilverStripe\AssetAdmin\Forms\UploadField;
|
||||||
|
use SilverStripe\Versioned\RecursivePublishable;
|
||||||
use SilverStripe\Versioned\Versioned;
|
use SilverStripe\Versioned\Versioned;
|
||||||
use RelationFieldsTestPage;
|
use RelationFieldsTestPage;
|
||||||
use GridFieldTestPage;
|
use GridFieldTestPage;
|
||||||
@ -120,11 +120,15 @@ class Company extends DataObject
|
|||||||
{
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
$companySet = static::get();
|
$companySet = static::get();
|
||||||
|
$data = $this->data();
|
||||||
|
if ($companySet->exists() && !static::config()->get('regenerate_on_build')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach ($companySet as $company) {
|
foreach ($companySet as $company) {
|
||||||
$company->delete();
|
$company->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->data() as $companyData) {
|
foreach ($data as $companyData) {
|
||||||
$company = new Company();
|
$company = new Company();
|
||||||
$company->Name = $companyData[0];
|
$company->Name = $companyData[0];
|
||||||
$company->Category = $companyData[1];
|
$company->Category = $companyData[1];
|
||||||
|
14
code/DevBuildGeneratorExtension.php
Normal file
14
code/DevBuildGeneratorExtension.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Core\Config\Configurable;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* There is no good place to put this setting, so it gets a class.
|
||||||
|
*/
|
||||||
|
class DevBuildGeneratorExtension extends DataExtension
|
||||||
|
{
|
||||||
|
use Configurable;
|
||||||
|
|
||||||
|
private static $regenerate_on_build = false;
|
||||||
|
}
|
@ -99,6 +99,10 @@ class Employee extends DataObject
|
|||||||
{
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
$employeeSet = DataObject::get(Employee::class);
|
$employeeSet = DataObject::get(Employee::class);
|
||||||
|
if ($employeeSet->exists() && !static::config()->get('regenerate_on_build')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($employeeSet as $employee) {
|
foreach ($employeeSet as $employee) {
|
||||||
$employee->delete();
|
$employee->delete();
|
||||||
}
|
}
|
||||||
|
@ -851,6 +851,10 @@ class TestRegistryDataObject extends DataObject implements RegistryDataInterface
|
|||||||
|
|
||||||
/** @var DataObject[] $all */
|
/** @var DataObject[] $all */
|
||||||
$all = static::get();
|
$all = static::get();
|
||||||
|
if ($all->exists() && !static::config()->get('regenerate_on_build')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($all as $one) {
|
foreach ($all as $one) {
|
||||||
$one->delete();
|
$one->delete();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user