MAJOR: upgrade to new version of Silverstripe - step: Apply PSR2 Cleanup.

This commit is contained in:
thiemen 2019-04-23 18:32:44 +12:00
parent e392cba53a
commit 682caa3bca
25 changed files with 100 additions and 263 deletions

View File

@ -2,24 +2,6 @@
namespace Sunnysideup\DMS\Cms;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\CMS\Controllers\CMSMain;
use Sunnysideup\DMS\Model\DMSDocumentSet;
@ -41,8 +23,6 @@ use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Admin\LeftAndMain;
/**
* @package dms
*/
@ -125,14 +105,14 @@ class DMSDocumentAddController extends LeftAndMain
*/
Requirements::javascript(SilverStripe\Core\Manifest\ModuleLoader::getModule('silverstripe/framework')->getResource('UPGRADE-FIX-REQUIRED.php')->getRelativePath() . '/javascript/AssetUploadField.js');
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: FRAMEWORK_DIR (ignore case)
* NEW: SilverStripe\Core\Manifest\ModuleLoader::getModule('silverstripe/framework')->getResource('UPGRADE-FIX-REQUIRED.php')->getRelativePath() (COMPLEX)
* EXP: Please review update and fix as required
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: FRAMEWORK_DIR (ignore case)
* NEW: SilverStripe\Core\Manifest\ModuleLoader::getModule('silverstripe/framework')->getResource('UPGRADE-FIX-REQUIRED.php')->getRelativePath() (COMPLEX)
* EXP: Please review update and fix as required
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
Requirements::css(SilverStripe\Core\Manifest\ModuleLoader::getModule('silverstripe/framework')->getResource('UPGRADE-FIX-REQUIRED.php')->getRelativePath() . '/css/AssetUploadField.css');
Requirements::css(DMS_DIR . '/dist/css/cmsbundle.css');

View File

@ -2,9 +2,6 @@
namespace Sunnysideup\DMS\Cms;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\ORM\DataObject;
@ -12,8 +9,6 @@ use SilverStripe\View\Requirements;
use Sunnysideup\DMS\Cms\DMSDocumentAddExistingField;
use SilverStripe\Forms\CompositeField;
class DMSDocumentAddExistingField extends CompositeField
{
public $useFieldContext = true;

View File

@ -2,8 +2,6 @@
namespace Sunnysideup\DMS\Cms;
use CMSForm;
@ -19,8 +17,6 @@ use SilverStripe\Forms\GridField\GridFieldDataColumns;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Admin\ModelAdmin;
class DMSDocumentAdmin extends ModelAdmin
{
private static $managed_models = array(

View File

@ -2,12 +2,6 @@
namespace Sunnysideup\DMS\Cms;
use Sunnysideup\DMS\Cms\DMSDocumentAddController;
use SilverStripe\Control\Controller;
use Sunnysideup\DMS\Model\DMSDocumentSet;
@ -17,8 +11,6 @@ use Sunnysideup\DMS\Cms\DMSGridFieldAddNewButton;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
class DMSGridFieldAddNewButton extends GridFieldAddNewButton implements GridField_HTMLProvider
{
/**

View File

@ -2,13 +2,9 @@
namespace Sunnysideup\DMS\Cms;
use Sunnysideup\DMS\Tools\ShortCodeRelationFinder;
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
/**
* Custom ItemRequest class the provides custom delete behaviour for the CMSFields of DMSDocument
*/

View File

@ -2,18 +2,12 @@
namespace Sunnysideup\DMS\Cms;
use SilverStripe\Control\Controller;
use SilverStripe\View\ArrayData;
use SilverStripe\Forms\GridField\GridFieldEditButton;
use SilverStripe\Forms\GridField\GridFieldViewButton;
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
class DMSGridFieldEditButton extends GridFieldEditButton implements GridField_ColumnProvider
{

View File

@ -2,11 +2,6 @@
namespace Sunnysideup\DMS\Cms;
use Exception;
@ -28,8 +23,6 @@ use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\Validator;
use SilverStripe\AssetAdmin\Forms\UploadField;
/**
* Field for uploading files into a DMSDocument. Replacing the existing file.
* Not ideally suited for the purpose, as the base implementation

View File

@ -9,8 +9,6 @@ namespace Sunnysideup\DMS\Cms;
use Sunnysideup\DMS\Model\DMSDocument;
use SilverStripe\Forms\Form;
class DMSUploadField_ItemHandler
{
private static $allowed_actions = array(

View File

@ -2,16 +2,11 @@
namespace Sunnysideup\DMS\Cms;
use SilverStripe\Forms\Form;
use Sunnysideup\DMS\DMS;
use SilverStripe\Forms\HiddenField;
use SilverStripe\Core\Extension;
/**
* Extends the original toolbar with document picking capability - modified lines are commented.
*/
@ -50,7 +45,7 @@ class DocumentHTMLEditorFieldToolbar extends Extension
$fieldList->push(HiddenField::create('DMSShortcodeHandlerKey', false, DMS::inst()->getShortcodeHandlerKey()));
// Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
// Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
// Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js");
//
// // create additional field, rebase to 'documents' directory

View File

@ -2,7 +2,6 @@
namespace Sunnysideup\DMS;
use SilverStripe\Core\Injector\Injector;
@ -19,7 +18,6 @@ use SilverStripe\Core\Config\Config;
use Sunnysideup\DMS\DMS;
use Sunnysideup\DMS\Interfaces\DMSInterface;
class DMS extends ViewableData implements DMSInterface
{
/**

View File

@ -2,15 +2,10 @@
namespace Sunnysideup\DMS;
use SilverStripe\View\Parsers\ShortcodeParser;
use Sunnysideup\DMS\Model\DMSDocument;
use SilverStripe\ErrorPage\ErrorPage;
/**
* Handles replacing `dms_document_link` shortcodes with links to the actual
* document.

View File

@ -2,9 +2,6 @@
namespace Sunnysideup\DMS\Extensions;
use TaxonomyTerm;
use SilverStripe\Forms\FieldList;
@ -13,9 +10,6 @@ use SilverStripe\Core\Config\Config;
use Sunnysideup\DMS\Extensions\DMSTaxonomyTypeExtension;
use SilverStripe\ORM\DataExtension;
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4

View File

@ -2,16 +2,6 @@
namespace Sunnysideup\DMS\Extensions;
use Sunnysideup\DMS\Model\DMSDocumentSet;
use SilverStripe\Forms\FieldList;
use SilverStripe\Security\Member;
@ -24,8 +14,6 @@ use SilverStripe\ORM\ArrayList;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DataExtension;
/**
* @package dms
*/

View File

@ -2,13 +2,10 @@
namespace Sunnysideup\DMS\Extensions;
use TaxonomyType;
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DataExtension;
/**
* Creates default taxonomy type records if they don't exist already
*/

View File

@ -2,15 +2,10 @@
namespace Sunnysideup\DMS\Forms;
use SilverStripe\Forms\FieldList;
use SilverStripe\Core\Convert;
use SilverStripe\Forms\CompositeField;
/**
* Combines form inputs into a key-value pair
*/
@ -106,7 +101,7 @@ class DMSJsonField extends CompositeField
*
* @return $this
*/
public function setValue($value, $data = NULL)
public function setValue($value, $data = null)
{
$this->value = $value;
if (is_string($value) && !empty($value)) {

View File

@ -2,14 +2,13 @@
namespace Sunnysideup\DMS\Interfaces;
/**
* Interface for a DMSDocument used in the Document Management System. A DMSDocument is create by storing a File
* object in an instance of the DMSInterface. All write operations on the DMSDocument create a new relation, so we
* never need to explicitly call the write() method on the DMSDocument DataObject
*/
interface DMSDocumentInterface {
interface DMSDocumentInterface
{
/**
* Returns a link to download this DMSDocument from the DMS store
* @return String

View File

@ -2,30 +2,13 @@
namespace Sunnysideup\DMS\Interfaces;
use SilverStripe\CMS\Model\SiteTree;
/**
*
*/
interface DMSInterface {
interface DMSInterface
{
/**
* Factory method that returns an instance of the DMS. This could be any class that implements the DMSInterface.
* @static

View File

@ -2,17 +2,6 @@
namespace Sunnysideup\DMS\Model;
use Exception;
@ -97,8 +86,6 @@ use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataObject;
use Sunnysideup\DMS\Interfaces\DMSDocumentInterface;
/**
* @package dms
*
@ -142,14 +129,14 @@ class DMSDocument extends DataObject implements DMSDocumentInterface
private static $table_name = 'DMSDocument';
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $db = (case sensitive)
* NEW: private static $db = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $db = (case sensitive)
* NEW: private static $db = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
private static $db = array(
"Filename" => "Varchar(255)", // eg. 3469~2011-energysaving-report.pdf
"Folder" => "Varchar(255)", // eg. 0
@ -170,14 +157,14 @@ class DMSDocument extends DataObject implements DMSDocumentInterface
);
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $has_one = (case sensitive)
* NEW: private static $has_one = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $has_one = (case sensitive)
* NEW: private static $has_one = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
private static $has_one = array(
'CoverImage' => Image::class,
'CreatedBy' => Member::class,
@ -759,14 +746,14 @@ class DMSDocument extends DataObject implements DMSDocumentInterface
DMSDocument_versions::create_version($this);
} else { //otherwise delete the old document file
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: ->getFullPath() (case sensitive)
* NEW: ->getFilename() (COMPLEX)
* EXP: You may need to add ASSETS_PATH."/" in front of this ...
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: ->getFullPath() (case sensitive)
* NEW: ->getFilename() (COMPLEX)
* EXP: You may need to add ASSETS_PATH."/" in front of this ...
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
$oldPath = $this->getFilename();
if (file_exists($oldPath)) {
unlink($oldPath);
@ -1303,14 +1290,14 @@ class DMSDocument extends DataObject implements DMSDocumentInterface
$fields->addExtraClass('dmsdocument-documentdetails');
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: ->dontEscape (case sensitive)
* NEW: ->dontEscape (COMPLEX)
* EXP: dontEscape is not longer in use for form fields, please use HTMLReadonlyField (or similar) instead.
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: ->dontEscape (case sensitive)
* NEW: ->dontEscape (COMPLEX)
* EXP: dontEscape is not longer in use for form fields, please use HTMLReadonlyField (or similar) instead.
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
$urlField->dontEscape = true;
$this->extend('updateFieldsForFile', $fields);

View File

@ -2,18 +2,6 @@
namespace Sunnysideup\DMS\Model;
use GridFieldPaginatorWithShowAll;
use GridFieldSortableRows;
@ -68,7 +56,6 @@ use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\DataObject;
/**
* A document set is attached to Pages, and contains many DMSDocuments
*
@ -94,14 +81,14 @@ class DMSDocumentSet extends DataObject
private static $table_name = 'DMSDocumentSet';
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $db = (case sensitive)
* NEW: private static $db = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $db = (case sensitive)
* NEW: private static $db = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
private static $db = array(
'Title' => 'Varchar(255)',
'KeyValuePairs' => 'Text',
@ -110,14 +97,14 @@ class DMSDocumentSet extends DataObject
);
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $has_one = (case sensitive)
* NEW: private static $has_one = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $has_one = (case sensitive)
* NEW: private static $has_one = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
private static $has_one = array(
'Page' => SiteTree::class,
);
@ -509,7 +496,8 @@ class DMSDocumentSet extends DataObject
$member = Member::currentUser();
}
$result = ($member &&
$result = (
$member &&
Permission::checkMember(
$member,
array('ADMIN', 'SITETREE_EDIT_ALL', 'CMS_ACCESS_DMSDocumentAdmin')

View File

@ -2,10 +2,6 @@
namespace Sunnysideup\DMS\Model;
use InvalidArgumentException;
use SilverStripe\Versioned\Versioned;
@ -16,8 +12,6 @@ use Sunnysideup\DMS\Model\DMSDocument;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\Controller;
class DMSDocument_Controller extends Controller
{
/**

View File

@ -2,12 +2,6 @@
namespace Sunnysideup\DMS\Model;
use Sunnysideup\DMS\Model\DMSDocument;
use Sunnysideup\DMS\Interfaces\DMSDocumentInterface;
use SilverStripe\ORM\DataObject;
@ -17,8 +11,6 @@ use Sunnysideup\DMS\DMS;
use SilverStripe\Assets\File;
use SilverStripe\ORM\DB;
/**
* DataObject to store versions of uploaded Documents.
*
@ -38,42 +30,42 @@ class DMSDocument_versions extends DataObject
public static $enable_versions = true;
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* OLD: private static $db (case sensitive)
* NEW:
private static $table_name = '[SEARCH_REPLACE_CLASS_NAME_GOES_HERE]';
private static $db (COMPLEX)
* EXP: Check that is class indeed extends DataObject and that it is not a data-extension!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* OLD: private static $db (case sensitive)
* NEW:
private static $table_name = '[SEARCH_REPLACE_CLASS_NAME_GOES_HERE]';
private static $db (COMPLEX)
* EXP: Check that is class indeed extends DataObject and that it is not a data-extension!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
private static $table_name = 'DMSDocument_versions';
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $db = (case sensitive)
* NEW: private static $db = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $db = (case sensitive)
* NEW: private static $db = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
private static $db = array(
'VersionCounter' => 'Int',
'VersionViewCount' => 'Int'
);
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $has_one = (case sensitive)
* NEW: private static $has_one = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: private static $has_one = (case sensitive)
* NEW: private static $has_one = (COMPLEX)
* EXP: Make sure to add a private static $table_name!
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
private static $has_one = array(
'Document' => DMSDocument::class
);
@ -119,14 +111,14 @@ class DMSDocument_versions extends DataObject
$success = false;
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: ->getFullPath() (case sensitive)
* NEW: ->getFilename() (COMPLEX)
* EXP: You may need to add ASSETS_PATH."/" in front of this ...
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
/**
* ### @@@@ START REPLACEMENT @@@@ ###
* WHY: upgrade to SS4
* OLD: ->getFullPath() (case sensitive)
* NEW: ->getFilename() (COMPLEX)
* EXP: You may need to add ASSETS_PATH."/" in front of this ...
* ### @@@@ STOP REPLACEMENT @@@@ ###
*/
$existingPath = $doc->getFilename();
if (is_file($existingPath)) {
$docData = $doc->toMap();

View File

@ -2,12 +2,6 @@
namespace Sunnysideup\DMS\Tasks;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\Queries\SQLSelect;
use Sunnysideup\DMS\Model\DMSDocument;
@ -15,7 +9,6 @@ use Sunnysideup\DMS\Model\DMSDocumentSet;
use SilverStripe\Control\Director;
use SilverStripe\Dev\BuildTask;
/**
* This build task helps to migrate DMS data structures from DMS 1.x to 2.x which introduces document sets.
*

View File

@ -2,10 +2,6 @@
namespace Sunnysideup\DMS\Tools;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\DataList;
use Sunnysideup\DMS\DMS;
@ -13,7 +9,6 @@ use SilverStripe\Core\ClassInfo;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
/**
* Finds {@link DataObject} instances using certain shortcodes
* by fulltext-querying only fields which are capable of parsing shortcodes.

View File

@ -12,7 +12,7 @@ class DMSSiteTreeExtensionTest extends SapphireTest
{
protected static $fixture_file = 'dms/tests/dmstest.yml';
protected $required_extensions = array(
protected static $required_extensions = array(
'SiteTree' => array(DMSSiteTreeExtension::class)
);

View File

@ -8,7 +8,7 @@ class DMSTaxonomyTypeExtensionTest extends SapphireTest
{
protected $usesDatabase = true;
protected $required_extensions = array(
protected static $required_extensions = array(
'TaxonomyType' => array(DMSTaxonomyTypeExtension::class)
);