NEW Added onAfterBuild (#9545)

* Added onAfterBuild
* Remove arbitrary argument
This commit is contained in:
Jackson Darlow 2020-06-30 16:56:14 +12:00 committed by GitHub
parent 87c041b92d
commit 57d75c89d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -117,6 +117,15 @@ abstract class DataExtension extends Extension
{
}
/**
* Extend the owner's onAfterBuild() logic
*
* See {@link DataObject::onAfterBuild()} for context.
*/
public function onAfterBuild()
{
}
/**
* Influence the owner's can() permission check value to be disallowed (false),
* allowed (true) if no other processed results are to disallow, or open (null) to not

View File

@ -3542,6 +3542,17 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$this->extend('requireDefaultRecords', $dummy);
}
/**
* Invoked after every database build is complete (including after table creation and
* default record population).
*
* See {@link DatabaseAdmin::doBuild()} for context.
*/
public function onAfterBuild()
{
$this->extend('onAfterBuild');
}
/**
* Get the default searchable fields for this object, as defined in the
* $searchable_fields list. If searchable fields are not defined on the

View File

@ -401,6 +401,10 @@ class DatabaseAdmin extends Controller
echo (Director::is_cli()) ? "\n Database build completed!\n\n" :"<p>Database build completed!</p>";
}
foreach ($dataClasses as $dataClass) {
DataObject::singleton($dataClass)->onAfterBuild();
}
ClassInfo::reset_db_cache();
}