mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
29 lines
806 B
PHP
29 lines
806 B
PHP
<?php
|
|
/**
|
|
* Creates default taxonomy type records if they don't exist already
|
|
*/
|
|
class DMSTaxonomyTypeExtension extends DataExtension
|
|
{
|
|
/**
|
|
* Create default taxonomy type records. Add records via YAML configuration (see taxonomy.yml):
|
|
*
|
|
* <code>
|
|
* DMSTaxonomyTypeExtension:
|
|
* default_records:
|
|
* - Document
|
|
* - PrivateDocument
|
|
* </code>
|
|
*/
|
|
public function requireDefaultRecords()
|
|
{
|
|
$records = (array) Config::inst()->get(get_class($this), 'default_records');
|
|
foreach ($records as $name) {
|
|
$type = TaxonomyType::get()->filter('Name', $name)->first();
|
|
if (!$type) {
|
|
$type = TaxonomyType::create(array('Name' => $name));
|
|
$type->write();
|
|
}
|
|
}
|
|
}
|
|
}
|