API: silverstripe-upgrader run for ss4 compatibility.

This commit is contained in:
Sam Minnee 2016-09-10 11:39:25 +12:00
parent 033a7bb96f
commit 377a8cdc7c
31 changed files with 230 additions and 52 deletions

View File

@ -1,4 +1,6 @@
<?php
use SilverStripe\Control\Director;
/**
* Fetches the name of the current module folder name.

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
{
/**
@ -13,7 +15,7 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
{
parent::__construct($itemsPerPage);
$this->removeComponentsByType('GridFieldAddNewButton');
$this->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldAddNewButton');
$this->addComponent(
new GridFieldAddByDBField('buttons-before-left')
@ -26,7 +28,7 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
/**
* @var GridFieldDataColumns $columns
*/
$columns = $this->getComponentByType('GridFieldDataColumns');
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns->setFieldFormatting(array(
'BlogPostsCount' => function ($value, CategorisationObject $item) {
@ -45,7 +47,7 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
/**
* @var GridFieldDataColumns $columns
*/
$columns = $this->getComponentByType('GridFieldDataColumns');
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
$columns->setDisplayFields(array(
'Title' => 'Title',

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\Forms\GridField\GridField_FormAction;
class GridFieldFormAction extends GridField_FormAction
{
/**

View File

@ -1,5 +1,11 @@
<?php
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Control\Controller;
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
use SilverStripe\Forms\GridField\GridField_ActionProvider;
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider
{
/**

View File

@ -22,7 +22,7 @@ class BlogHolder extends BlogTree implements MigratableObject
* @var array
*/
private static $has_one = array(
'Owner' => 'Member',
'Owner' => 'SilverStripe\\Security\\Member',
);
/**

View File

@ -1,5 +1,12 @@
<?php
use SilverStripe\Core\ClassInfo;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\DatabaseAdmin;
use SilverStripe\ORM\DB;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\MigrationTask;
class BlogMigrationTask extends MigrationTask
{
/**
@ -49,7 +56,7 @@ class BlogMigrationTask extends MigrationTask
return;
}
if (is_subclass_of($class, 'SiteTree')) {
if (is_subclass_of($class, 'SilverStripe\\CMS\\Model\\SiteTree')) {
$items = SiteTree::get()->filter('ClassName', $class);
} else {
$items = $class::get();

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\ORM\DataExtension;
/**
* Adds Blog specific behaviour to Comment.
*/

View File

@ -1,5 +1,15 @@
<?php
use SilverStripe\Security\Permission;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Core\Convert;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\FormTransformation;
use SilverStripe\Forms\GridField\GridField;
/**
* This class is responsible for filtering the SiteTree when necessary and also overlaps into
* filtering only published posts.
@ -27,7 +37,7 @@ class BlogFilter extends Lumberjack
$dataQuery = $staged->dataQuery()
->innerJoin('BlogPost', sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage))
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now())));
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
$staged = $staged->setDataQuery($dataQuery);
}
@ -53,7 +63,7 @@ class BlogFilter extends Lumberjack
if (!$this->shouldFilter() && $this->isBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
$dataQuery = $staged->dataQuery()
->innerJoin('BlogPost', '"BlogPost_Live"."ID" = "SiteTree_Live"."ID"')
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now())));
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
$staged = $staged->setDataQuery($dataQuery);
}

View File

@ -1,5 +1,13 @@
<?php
use SilverStripe\View\Parsers\URLSegmentFilter;
use SilverStripe\Security\Member;
use SilverStripe\Forms\FieldList;
use SilverStripe\View\Requirements;
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\ORM\DataExtension;
/**
* This class is responsible for add Blog specific behaviour to Members.
*
@ -20,7 +28,7 @@ class BlogMemberExtension extends DataExtension
* @var array
*/
private static $has_one = array(
'BlogProfileImage' => 'Image',
'BlogProfileImage' => 'SilverStripe\\Assets\\Image',
);
/**

View File

@ -1,5 +1,13 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Control\Controller;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataExtension;
/**
* This is responsible for filtering only published posts to users who do not have permission to
* view non-published posts.
@ -23,7 +31,7 @@ class BlogPostFilter extends DataExtension
}
if ($stage == 'Live' || !Permission::check('VIEW_DRAFT_CONTENT')) {
$query->addWhere(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now())));
$query->addWhere(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
}
}

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\ORM\DataExtension;
/**
* Customise blog post to support comment notifications.
*

View File

@ -1,5 +1,9 @@
<?php
use SilverStripe\View\Parsers\URLSegmentFilter;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataExtension;
/**
* Adds URLSegment functionality to Tags & Categories.
*

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\Control\Cookie;
use SilverStripe\Forms\FieldGroup;
class BlogAdminSidebar extends FieldGroup
{
/**

View File

@ -1,5 +1,17 @@
<?php
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Control\Controller;
use SilverStripe\Security\Security;
use SilverStripe\View\Requirements;
use SilverStripe\Core\Convert;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\GridField\GridField_FormAction;
use SilverStripe\View\ArrayData;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Forms\GridField\GridField_ActionProvider;
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
/**
* Adds a component which allows a user to add a new DataObject by database field.
*

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\View\Requirements;
/**
* Provides a component to the {@link GridField} which tells the user whether or not a blog post
* has been published and when.

View File

@ -1,5 +1,24 @@
<?php
use SilverStripe\View\Requirements;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Security\Member;
use SilverStripe\ORM\UnsavedRelationList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\ListboxField;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\DB;
use SilverStripe\Core\Convert;
use SilverStripe\Control\Controller;
use SilverStripe\Security\Group;
use SilverStripe\Security\PermissionProvider;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\PaginatedList;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\Control\RSS\RSSFeed;
/**
* Blog Holder
*
@ -69,9 +88,9 @@ class Blog extends Page implements PermissionProvider
* @var array
*/
private static $many_many = array(
'Editors' => 'Member',
'Writers' => 'Member',
'Contributors' => 'Member',
'Editors' => 'SilverStripe\\Security\\Member',
'Writers' => 'SilverStripe\\Security\\Member',
'Contributors' => 'SilverStripe\\Security\\Member',
);
/**
@ -228,7 +247,7 @@ class Blog extends Page implements PermissionProvider
public function RoleOf($member)
{
if (is_numeric($member)) {
$member = DataObject::get_by_id('Member', $member);
$member = DataObject::get_by_id('SilverStripe\\Security\\Member', $member);
}
if (!$member) {
@ -779,7 +798,7 @@ class Blog_Controller extends Page_Controller
return (int) $year;
}
} elseif ($this->request->param('Action') == 'archive') {
return SS_Datetime::now()->Year();
return DBDatetime::now()->Year();
}
return null;

View File

@ -1,5 +1,11 @@
<?php
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Control\Controller;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\DataObject;
/**
* A blog category for generalising blog posts.
*

View File

@ -1,5 +1,21 @@
<?php
use SilverStripe\ORM\UnsavedRelationList;
use SilverStripe\View\Requirements;
use SilverStripe\Forms\UploadField;
use SilverStripe\Forms\ToggleCompositeField;
use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\ListboxField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\DatetimeField;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ArrayData;
/**
* An individual blog post.
*
@ -37,7 +53,7 @@ class BlogPost extends Page
* @var array
*/
private static $has_one = array(
'FeaturedImage' => 'Image',
'FeaturedImage' => 'SilverStripe\\Assets\\Image',
);
/**
@ -46,7 +62,7 @@ class BlogPost extends Page
private static $many_many = array(
'Categories' => 'BlogCategory',
'Tags' => 'BlogTag',
'Authors' => 'Member',
'Authors' => 'SilverStripe\\Security\\Member',
);
/**
@ -419,7 +435,7 @@ class BlogPost extends Page
$publishDate = $this->dbObject('PublishDate');
if (!$publishDate->getValue()) {
$this->PublishDate = SS_Datetime::now()->getValue();
$this->PublishDate = DBDatetime::now()->getValue();
$this->write();
}
}

View File

@ -1,5 +1,11 @@
<?php
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Control\Controller;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\DataObject;
/**
* A blog tag for keyword descriptions of a blog post.
*

View File

@ -1,5 +1,11 @@
<?php
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\NumericField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Control\Controller;
use SilverStripe\View\ArrayData;
if (!class_exists('Widget')) {
return;
}

View File

@ -1,5 +1,10 @@
<?php
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Core\Convert;
if (!class_exists("Widget")) {
return;
}

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\NumericField;
if (!class_exists("Widget")) {
return;
}

View File

@ -1,5 +1,11 @@
<?php
use SilverStripe\Forms\DropdownField;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
if (!class_exists('Widget')) {
return;
}

View File

@ -1,5 +1,9 @@
<?php
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Core\Convert;
if (!class_exists("Widget")) {
return;
}

View File

@ -1,5 +1,11 @@
<?php
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Member;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Dev\FunctionalTest;
/**
* @mixin PHPUnit_Framework_TestCase
*/
@ -17,7 +23,7 @@ class BlogCategoryTest extends FunctionalTest
{
parent::setUp();
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
DBDatetime::set_mock_now('2013-10-10 20:00:00');
}
/**
@ -25,7 +31,7 @@ class BlogCategoryTest extends FunctionalTest
*/
public function tearDown()
{
SS_Datetime::clear_mock_now();
DBDatetime::clear_mock_now();
parent::tearDown();
}
@ -72,9 +78,9 @@ class BlogCategoryTest extends FunctionalTest
{
$this->useDraftSite();
$this->objFromFixture('Member', 'Admin');
$this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$category = $this->objFromFixture('BlogCategory', 'SecondCategory');
$this->assertFalse($category->canView($editor), 'Editor should not be able to view category.');
@ -87,8 +93,8 @@ class BlogCategoryTest extends FunctionalTest
{
$this->useDraftSite();
$admin = $this->objFromFixture('Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$category = $this->objFromFixture('BlogCategory', 'FirstCategory');
@ -110,8 +116,8 @@ class BlogCategoryTest extends FunctionalTest
{
$this->useDraftSite();
$admin = $this->objFromFixture('Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$category = singleton('BlogCategory');
@ -123,8 +129,8 @@ class BlogCategoryTest extends FunctionalTest
{
$this->useDraftSite();
$admin = $this->objFromFixture('Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$category = $this->objFromFixture('BlogCategory', 'FirstCategory');

View File

@ -1,5 +1,9 @@
<?php
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Member;
use SilverStripe\Dev\SapphireTest;
/**
* @mixin PHPUnit_Framework_TestCase
*/
@ -14,12 +18,12 @@ class BlogPostFilterTest extends SapphireTest
{
parent::setUp();
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
DBDatetime::set_mock_now('2013-10-10 20:00:00');
}
public function tearDown()
{
SS_Datetime::clear_mock_now();
DBDatetime::clear_mock_now();
parent::tearDown();
}
@ -39,7 +43,7 @@ class BlogPostFilterTest extends SapphireTest
$this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts');
SS_Datetime::set_mock_now('2020-01-01 00:00:00');
DBDatetime::set_mock_now('2020-01-01 00:00:00');
$this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts');
}

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\Dev\SapphireTest;
class BlogPostNotificationsTest extends SapphireTest
{
/**

View File

@ -1,5 +1,9 @@
<?php
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\SapphireTest;
class BlogPostTest extends SapphireTest
{
/**
@ -20,7 +24,7 @@ class BlogPostTest extends SapphireTest
*/
public function tearDown()
{
SS_Datetime::clear_mock_now();
DBDatetime::clear_mock_now();
parent::tearDown();
}
@ -29,9 +33,9 @@ class BlogPostTest extends SapphireTest
*/
public function testCanView($date, $user, $page, $canView)
{
$userRecord = $this->objFromFixture('Member', $user);
$userRecord = $this->objFromFixture('SilverStripe\\Security\\Member', $user);
$pageRecord = $this->objFromFixture('BlogPost', $page);
SS_Datetime::set_mock_now($date);
DBDatetime::set_mock_now($date);
$this->assertEquals($canView, $pageRecord->canView($userRecord));
}
@ -88,10 +92,10 @@ class BlogPostTest extends SapphireTest
{
$blogPost = $this->objFromFixture('BlogPost', 'NullPublishDate');
$editor = $this->objFromFixture('Member', 'BlogEditor');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'BlogEditor');
$this->assertTrue($blogPost->canView($editor));
$visitor = $this->objFromFixture('Member', 'Visitor');
$visitor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Visitor');
$this->assertFalse($blogPost->canView($visitor));
}

View File

@ -1,5 +1,11 @@
<?php
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Member;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Dev\FunctionalTest;
/**
* @mixin PHPUnit_Framework_TestCase
*/
@ -17,7 +23,7 @@ class BlogTagTest extends FunctionalTest
{
parent::setUp();
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
DBDatetime::set_mock_now('2013-10-10 20:00:00');
}
/**
@ -25,7 +31,7 @@ class BlogTagTest extends FunctionalTest
*/
public function tearDown()
{
SS_Datetime::clear_mock_now();
DBDatetime::clear_mock_now();
parent::tearDown();
}
@ -75,8 +81,8 @@ class BlogTagTest extends FunctionalTest
{
$this->useDraftSite();
$admin = $this->objFromFixture('Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$tag = $this->objFromFixture('BlogTag', 'FirstTag');
@ -93,8 +99,8 @@ class BlogTagTest extends FunctionalTest
{
$this->useDraftSite();
$admin = $this->objFromFixture('Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$tag = $this->objFromFixture('BlogTag', 'FirstTag');
@ -116,8 +122,8 @@ class BlogTagTest extends FunctionalTest
{
$this->useDraftSite();
$admin = $this->objFromFixture('Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$tag = singleton('BlogTag');
@ -129,8 +135,8 @@ class BlogTagTest extends FunctionalTest
{
$this->useDraftSite();
$admin = $this->objFromFixture('Member', 'Admin');
$editor = $this->objFromFixture('Member', 'Editor');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
$tag = $this->objFromFixture('BlogTag', 'FirstTag');

View File

@ -1,5 +1,9 @@
<?php
use SilverStripe\Control\Director;
use SilverStripe\Control\Controller;
use SilverStripe\Dev\SapphireTest;
class BlogTagsCloudWidgetTest extends SapphireTest {
/**

View File

@ -1,5 +1,16 @@
<?php
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Member;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\ORM\DataModel;
use SilverStripe\ORM\SS_List;
use SilverStripe\Dev\SapphireTest;
/**
* @mixin PHPUnit_Framework_TestCase
*/
@ -18,7 +29,7 @@ class BlogTest extends SapphireTest
parent::setUp();
Config::nest();
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
DBDatetime::set_mock_now('2013-10-10 20:00:00');
/**
* @var Blog $blog
@ -33,7 +44,7 @@ class BlogTest extends SapphireTest
*/
public function tearDown()
{
SS_Datetime::clear_mock_now();
DBDatetime::clear_mock_now();
Config::unnest();
parent::tearDown();
@ -181,22 +192,22 @@ class BlogTest extends SapphireTest
/**
* @var Member $editor
*/
$editor = $this->objFromFixture('Member', 'BlogEditor');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'BlogEditor');
/**
* @var Member $writer
*/
$writer = $this->objFromFixture('Member', 'Writer');
$writer = $this->objFromFixture('SilverStripe\\Security\\Member', 'Writer');
/**
* @var Member $contributor
*/
$contributor = $this->objFromFixture('Member', 'Contributor');
$contributor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Contributor');
/**
* @var Member $visitor
*/
$visitor = $this->objFromFixture('Member', 'Visitor');
$visitor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Visitor');
$this->assertEquals('Editor', $fourthBlog->RoleOf($editor));
$this->assertEquals('Contributor', $fourthBlog->RoleOf($contributor));
@ -321,7 +332,7 @@ class BlogTest extends SapphireTest
*/
protected function requestURL(ContentController $controller, $url)
{
$request = new SS_HTTPRequest('get', $url);
$request = new HTTPRequest('get', $url);
$request->match('$URLSegment//$Action/$ID/$OtherID');
$request->shift();
$controller->init();