-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace DNADesign\Tagurit\Tasks; | ||
|
||
use DNADesign\Tagurit\Model\TaxonomyTerm; | ||
use SilverStripe\Dev\BuildTask; | ||
use SilverStripe\ORM\DataObject; | ||
use SilverStripe\ORM\Queries\SQLUpdate; | ||
|
||
/** | ||
* BuildTask to create the set of protected Types and Terms from config. | ||
* The protected taxonomy is created on build, and missing records are recreated. | ||
*/ | ||
class UnprotectTaxonomyTerms extends BuildTask | ||
{ | ||
protected $title = '[Taxonomy] Un-protect Taxonomy Terms'; | ||
|
||
protected $description = "Set every Taxonomy Term as un-protected"; | ||
|
||
private static $segment = "unprotect-taxonomy-terms"; | ||
|
||
protected $enabled = true; | ||
|
||
public function run($request) | ||
{ | ||
$table = DataObject::getSchema()->tableForField(TaxonomyTerm::class, 'Protected'); | ||
if (!$table) { | ||
exit('Could not locate DB table to update!'); | ||
} | ||
|
||
$query = SQLUpdate::create($table, ['Protected' => false]); | ||
$query->execute(); | ||
|
||
echo 'Done.'; | ||
} | ||
} |