Skip to content

Commit

Permalink
Migrate to ss4
Browse files Browse the repository at this point in the history
  • Loading branch information
jedateach committed Jul 27, 2021
1 parent 024fd3e commit 1b869d7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mappings:
BannerImage: Burnbright\SilverstripeBanner\BannerImage
BannersExtension: Burnbright\SilverstripeBanner\BannersExtension
1 change: 0 additions & 1 deletion _config.php

This file was deleted.

3 changes: 3 additions & 0 deletions _config/legacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SilverStripe\ORM\DatabaseAdmin:
classname_value_remapping:
BannerImage: Burnbright\SilverstripeBanner\BannerImage
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"type": "silverstripe-vendormodule",
"keywords": ["silverstripe", "banner", "carousel", "slider"],
"require": {

"silverstripe/vendor-plugin": "^1",
"silverstripe/framework": "^4"
},
"suggests": {

"autoload": {
"psr-4": {
"Burnbright\\SilverstripeBanner\\": "src/"
}
},
"license": "BSD-2",
"authors": [
Expand All @@ -16,7 +19,6 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"extra": {
"installer-name": "banner"
}
Expand Down
25 changes: 17 additions & 8 deletions code/BannerImage.php → src/BannerImage.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
<?php

namespace Burnbright\SilverstripeBanner;

use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Permission;
use Image;
use Page;

class BannerImage extends DataObject
{

private static $table_name = "BannerImage";

private static $db = array(
'Title' => 'Varchar(255)',
'SubTitle' => 'Varchar(255)',
'Link' => 'LinkField',
// 'Link' => 'LinkField', // TODO: support linking banners in ss4
'Sort' => 'Int'
);

private static $has_one = array(
'Image' => 'Image',
'Parent' => 'Page'
'Image' => Image::class,
'Parent' => Page::class
);

private static $summary_fields = array(
'Image.CMSThumbnail' => 'Image',
'CMSTitle' => 'Title',
'Link' => 'Link'
// 'Link' => 'Link'
);

private static $default_sort = "\"Sort\" ASC, \"ID\" ASC";
Expand All @@ -44,22 +53,22 @@ public function getCMSTitle()
}
}

public function canCreate($member = null)
public function canCreate($member = null, $context = [])
{
return Permission::check("CMS_ACCESS_CMSMain");
}

public function canEdit($member = null)
public function canEdit($member = null, $context = [])
{
return Permission::check("CMS_ACCESS_CMSMain");
}

public function canDelete($member = null)
public function canDelete($member = null, $context = [])
{
return Permission::check("CMS_ACCESS_CMSMain");
}

public function canView($member = null)
public function canView($member = null, $context = [])
{
return Permission::check("CMS_ACCESS_CMSMain");
}
Expand Down
11 changes: 10 additions & 1 deletion code/BannersExtension.php → src/BannersExtension.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?php

namespace Burnbright\SilverstripeBanner;

use BannerImage;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\GridField\GridField;
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;

class BannersExtension extends DataExtension
{

public static $has_many = array(
'Banners' => 'BannerImage'
'Banners' => BannerImage::class
);

public function updateCMSFields(FieldList $fields)
Expand Down

0 comments on commit 1b869d7

Please sign in to comment.