API Move CMSPreviewable to framework module

Remove or soft-link dependency on admin module
This commit is contained in:
Damian Mooyman 2017-03-10 16:43:10 +13:00
parent 12444fd8ae
commit 9f953770f5
12 changed files with 58 additions and 31 deletions

View File

@ -53,13 +53,12 @@ before_script:
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then (vendor/bin/serve --bootstrap-file cms/tests/behat/serve-bootstrap.php &> serve.log &); fi"
script:
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/phpunit; fi"
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/phpunit tests/php; fi"
- "if [ \"$PHPUNIT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/phpunit cms/tests; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/behat --config tests/behat/config.yml .; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/behat @cms --config tests/behat/cms-config.yml; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then git diff-files --quiet -w; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then git diff -w --no-color; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then yarn run test; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then yarn run lint; fi"
- "if [ \"$PHPCS_TEST\" = \"1\" ]; then composer run-script lint; fi"

View File

@ -171,7 +171,7 @@ mappings:
CMSBatchActionHandler: SilverStripe\Admin\CMSBatchActionHandler
CMSMenu: SilverStripe\Admin\CMSMenu
CMSMenuItem: SilverStripe\Admin\CMSMenuItem
CMSPreviewable: SilverStripe\Admin\CMSPreviewable
CMSPreviewable: SilverStripe\ORM\CMSPreviewable
CMSProfileController: SilverStripe\Admin\CMSProfileController
GroupImportForm: SilverStripe\Admin\GroupImportForm
LeftAndMain: SilverStripe\Admin\LeftAndMain

View File

@ -23,7 +23,6 @@
"monolog/monolog": "~1.11",
"nikic/php-parser": "^2 || ^3",
"silverstripe/config": "^1@dev",
"silverstripe/admin": "^1@dev",
"swiftmailer/swiftmailer": "~5.4",
"symfony/cache": "^3.3@dev",
"symfony/config": "^2.8",
@ -32,6 +31,7 @@
"vlucas/phpdotenv": "^2.4"
},
"require-dev": {
"silverstripe/admin": "^1@dev",
"phpunit/PHPUnit": "~4.8",
"silverstripe/behat-extension": "^2.1.0",
"silverstripe/serve": "dev-master",

View File

@ -52,6 +52,7 @@ guide developers in preparing existing 3.x code for compatibility with 4.0
* i18n Updated to use symfony/translation over zend Framework 1. Zend_Translate has been removed.
* Replaced `Zend_Cache` and the `Cache` API with a PSR-16 implementation (symfony/cache)
* _ss_environment.php files have been removed in favour of `.env` and "real" environment variables.
* admin has been moved to a new module [silverstripe/admin](https://github.com/silverstripe/silverstripe-admin).
## <a name="upgrading"></a>Upgrading
@ -1141,6 +1142,7 @@ A very small number of methods were chosen for deprecation, and will be removed
class which can be used to select the correct behaviour:
* `HTMLText`: `DBHTMLText` with shortcodes enabled
* `HTMLFragment`: `DBHTMLText` without shortcodes enabled (as default)
* `CMSPreviewable` has been moved from the `SilverStripe\Admin` namespace to `SilverStripe\ORM`
* Changes to `DBString` formatting:
* `NoHTML` is renamed to `Plain`
* `LimitWordCountXML` is removed. Use `LimitWordCount` instead.

View File

@ -20,7 +20,6 @@
<testsuite name="Default">
<directory>tests/php</directory>
<directory>admin/tests/php</directory>
</testsuite>
<listeners>

View File

@ -2,15 +2,13 @@
namespace SilverStripe\Assets;
use SilverStripe\Admin\AdminRootController;
use SilverStripe\Admin\CMSPreviewable;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\Assets\Storage\AssetNameGenerator;
use SilverStripe\Assets\Storage\DBFile;
use SilverStripe\Assets\Storage\AssetContainer;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Convert;
use SilverStripe\Control\Director;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\DatetimeField;
@ -823,21 +821,6 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer, Thumb
return null;
}
/**
* @todo Coupling with cms module, remove this method.
*
* @return string
*/
public function DeleteLink()
{
return Controller::join_links(
Director::absoluteBaseURL(),
AdminRootController::admin_url(),
"assets/removefile/",
$this->ID
);
}
/**
* Get expected value of Filename tuple value. Will be used to trigger
* a file move on draft stage.

View File

@ -0,0 +1,40 @@
<?php
namespace SilverStripe\ORM;
/**
* Interface to provide enough information about a record to make it previewable
* through the CMS. It uses the record database ID, its "frontend" and "backend"
* links to link up the edit form with its preview.
*
* Also used by {@link SilverStripeNavigator} to generate links - both within
* the CMS preview, and as a frontend utility for logged-in CMS authors in
* custom themes (with the $SilverStripeNavigator template marker).
*/
interface CMSPreviewable
{
/**
* Determine the preview link, if available, for this object.
* If no preview is available for this record, it may return null.
*
* @param string $action
* @return string Link to the end-user view for this record.
* Example: http://mysite.com/my-record
*/
public function PreviewLink($action = null);
/**
* To determine preview mechanism (e.g. embedded / iframe)
*
* @return string
*/
public function getMimeType();
/**
* @return string Link to the CMS-author view. Should point to a
* controller subclassing {@link LeftAndMain}. Example:
* http://mysite.com/admin/edit/6
*/
public function CMSEditLink();
}

View File

@ -770,7 +770,7 @@ class Hierarchy extends DataExtension implements Resettable
*/
public function showingCMSTree()
{
if (!Controller::has_curr()) {
if (!Controller::has_curr() || !class_exists(LeftAndMain::class)) {
return false;
}
$controller = Controller::curr();

View File

@ -2,7 +2,7 @@
namespace SilverStripe\ORM\Versioning;
use SilverStripe\Admin\CMSPreviewable;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\Assets\Thumbnail;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\ArrayList;

View File

@ -195,7 +195,7 @@ PHP
public function success()
{
// Ensure member is properly logged in
if (!Member::currentUserID()) {
if (!Member::currentUserID() || !class_exists(AdminRootController::class)) {
return $this->redirectToExternalLogin();
}

View File

@ -144,10 +144,6 @@ class Group extends DataObject
_t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles')
);
// Filter permissions
// TODO SecurityAdmin coupling, not easy to get to the form fields through GridFieldDetailForm
$permissionsField->setHiddenPermissions((array)Config::inst()->get('SilverStripe\\Admin\\SecurityAdmin', 'hidden_permissions'));
if ($this->ID) {
$group = $this;
$config = GridFieldConfig_RelationEditor::create();
@ -211,7 +207,10 @@ class Group extends DataObject
// Only show the "Roles" tab if permissions are granted to edit them,
// and at least one role exists
if (Permission::check('APPLY_ROLES') && DataObject::get('SilverStripe\\Security\\PermissionRole')) {
if (Permission::check('APPLY_ROLES') &&
PermissionRole::get()->count() &&
class_exists(SecurityAdmin::class)
) {
$fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
$fields->addFieldToTab(
'Root.Roles',

View File

@ -1437,6 +1437,11 @@ class Member extends DataObject implements TemplateGlobalProvider
*/
public static function mapInCMSGroups($groups = null)
{
// Check CMS module exists
if (!class_exists(LeftAndMain::class)) {
return ArrayList::create()->map();
}
if (!$groups || $groups->Count() == 0) {
$perms = array('ADMIN', 'CMS_ACCESS_AssetAdmin');