diff --git a/tests/fixtures.yml b/seed/fixtures.yml similarity index 100% rename from tests/fixtures.yml rename to seed/fixtures.yml diff --git a/src/CannedContent.php b/src/CannedContent.php old mode 100755 new mode 100644 index bcf64b0..9d21b99 --- a/src/CannedContent.php +++ b/src/CannedContent.php @@ -2,58 +2,58 @@ namespace Fractas\CannedContent; +use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\YamlFixture; +use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\HTMLEditor\HTMLEditorField; use SilverStripe\Forms\Tab; use SilverStripe\Forms\TabSet; -use SilverStripe\Forms\CheckboxField; -use SilverStripe\Forms\TextField; use SilverStripe\Forms\TextareaField; -use SilverStripe\Forms\HTMLEditor\HTMLEditorField; +use SilverStripe\Forms\TextField; use SilverStripe\ORM\DataObject; -use SilverStripe\Security\Permission; -use SilverStripe\Core\Injector\Injector; use SilverStripe\ORM\DB; -use SilverStripe\Dev\YamlFixture; +use SilverStripe\Security\Permission; class CannedContent extends DataObject { private static $table_name = 'CannedContent'; - private static $db = array( + private static $db = [ 'Name' => 'Varchar(255)', 'Description' => 'Varchar(255)', 'Content' => 'HTMLText', 'IsActive' => 'Boolean', - ); + ]; - private static $defaults = array( + private static $defaults = [ 'IsActive' => true, - ); + ]; - private static $casting = array( + private static $casting = [ 'Title' => 'Varchar', 'Link' => 'Varchar', - ); + ]; - private static $indexes = array(); + private static $indexes = []; private static $default_sort = 'ID DESC'; - private static $summary_fields = array( + private static $summary_fields = [ 'Name', 'IsActive.Nice', 'Created.Nice', - ); + ]; - private static $searchable_fields = array( + private static $searchable_fields = [ 'Name' => 'PartialMatchFilter', - ); + ]; - private static $field_labels = array( + private static $field_labels = [ 'Name' => 'Name for Canned Content Template', 'IsActive.Nice' => 'Is Active', 'Created.Nice' => 'Created', - ); + ]; private static $singular_name = 'Canned Content Template'; @@ -78,12 +78,12 @@ public function getCMSFields() { $fields = new FieldList(new TabSet('Root', new Tab('Main'))); - $fields->addFieldsToTab('Root.Main', array( + $fields->addFieldsToTab('Root.Main', [ new TextField('Name', 'Name'), new CheckboxField('IsActive', 'Is Active'), new TextareaField('Description', 'Description'), new HtmlEditorField('Content', 'Content'), - )); + ]); return $fields; } @@ -120,7 +120,7 @@ public function canDelete($member = null) return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } - public function canCreate($member = null, $context = array()) + public function canCreate($member = null, $context = []) { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } @@ -130,9 +130,9 @@ public function requireDefaultRecords() parent::requireDefaultRecords(); $anyrecord = self::get()->first(); - if (!$anyrecord) { + if (! $anyrecord) { $factory = Injector::inst()->create('SilverStripe\Dev\FixtureFactory'); - $fixture = YamlFixture::create('vendor/fractas/canned-content/tests/fixtures.yml'); + $fixture = YamlFixture::create('vendor/fractas/canned-content/seed/fixtures.yml'); $fixture->writeInto($factory); DB::alteration_message('Default Canned Content Templates created', 'created'); diff --git a/src/CannedContentAdmin.php b/src/CannedContentAdmin.php old mode 100755 new mode 100644 index 79c7128..162b88a --- a/src/CannedContentAdmin.php +++ b/src/CannedContentAdmin.php @@ -3,12 +3,11 @@ namespace Fractas\CannedContent; use SilverStripe\Admin\ModelAdmin; -use Fractas\CannedContent\CannedContent; class CannedContentAdmin extends ModelAdmin { private static $managed_models = [ - CannedContent::class + CannedContent::class, ]; private static $url_segment = 'cannedsoup'; diff --git a/src/CannedContentController.php b/src/CannedContentController.php index b1691bc..09f7b8e 100644 --- a/src/CannedContentController.php +++ b/src/CannedContentController.php @@ -9,24 +9,24 @@ class CannedContentController extends Controller { private static $url_segment = 'cannedcontent'; - private static $allowed_actions = array( + private static $allowed_actions = [ 'templates', 'template', - ); + ]; public function templates(HTTPRequest $request) { - $items = CannedContent::get()->where(array('IsActive' => '1')); - $output = array(); + $items = CannedContent::get()->where(['IsActive' => '1']); + $output = []; if ($items->exists()) { foreach ($items as $item) { if ($item->exists()) { - $output[] = array( + $output[] = [ 'title' => $item->Name, 'url' => $item->Link(), 'description' => isset($item->Description) ? $item->Description : $item->Name, - ); + ]; } } }