Merge pull request #1534 from open-sausages/pulls/4.0/namespace-orm

API Update for new SilverStripe\ORM namespace
This commit is contained in:
Ingo Schommer 2016-07-01 15:09:00 +12:00 committed by GitHub
commit d208a6f511
58 changed files with 258 additions and 42 deletions

View File

@ -1,4 +1,9 @@
<?php
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\Versioning\Versioned;
/**
* Publish items batch action.
*

View File

@ -1,6 +1,10 @@
<?php
use SilverStripe\Filesystem\Storage\AssetNameGenerator;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List;
/**
* AssetAdmin is the 'file store' section of the CMS.
@ -171,7 +175,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
'Size' => _t('AssetAdmin.SIZE', 'Size'),
));
$columns->setFieldCasting(array(
'Created' => 'SS_Datetime->Nice'
'Created' => 'DBDatetime->Nice'
));
$gridField->setAttribute(
'data-url-folder-template',
@ -484,7 +488,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
// check addchildren permissions
if(
singleton($class)->hasExtension('Hierarchy')
singleton($class)->hasExtension('SilverStripe\ORM\Hierarchy\Hierarchy')
&& isset($data['ParentID'])
&& is_numeric($data['ParentID'])
&& $data['ParentID']

View File

@ -1,5 +1,13 @@
<?php
use SilverStripe\Model\FieldType\DBHTMLText;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\HiddenClass;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DB;
/**
* The main "content" area of the CMS.
@ -779,8 +787,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$columns->setDisplayFields($fields);
$columns->setFieldCasting(array(
'Created' => 'SS_Datetime->Ago',
'LastEdited' => 'SS_Datetime->FormatFromSettings',
'Created' => 'DBDatetime->Ago',
'LastEdited' => 'DBDatetime->FormatFromSettings',
'getTreeTitle' => 'HTMLText'
));

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationException;
class CMSPageAddController extends CMSPageEditController {
private static $url_segment = 'pages/add';

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage controllers

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\ORM\DataObject;
/**
* @package cms
*/

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* Base class for filtering the subtree for certain node statuses.
*

View File

@ -1,7 +1,14 @@
<?php
use SilverStripe\Model\FieldType\DBVarchar;
use SilverStripe\Model\FieldType\DBHTMLText;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataModel;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\ORM\FieldType\DBHTMLText;
/**
* The most common kind of controller; effectively a controller linked to a {@link DataObject}.
@ -313,7 +320,7 @@ HTML;
} else {
if($date = Versioned::current_archived_date()) {
Requirements::css(CMS_DIR . '/client/dist/styles/SilverStripeNavigator.css');
$dateObj = Datetime::create($date, null);
$dateObj = DBField::create_field('Datetime', $date);
// $dateObj->setVal($date);
return "<div id=\"SilverStripeNavigatorMessage\">". _t('ContentController.ARCHIVEDSITEFROM') ."<br>" . $dateObj->Nice() . "</div>";
}

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
/**
* Decorates {@see File} with ErrorPage support
*/

View File

@ -1,4 +1,9 @@
<?php
use SilverStripe\ORM\DataModel;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
/**
* ModelAsController deals with mapping the initial request to the first {@link SiteTree}/{@link ContentController}
* pair, which are then used to handle the request.

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\ORM\Queries\SQLSelect;
class OldPageRedirector extends Extension {
/**

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\DataModel;
use SilverStripe\ORM\DB;
/**
* @package cms
* @subpackage control

View File

@ -1,5 +1,10 @@
<?php
use SilverStripe\Model\FieldType\DBField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\FieldType\DBField;
/**
* Utility class representing links to different views of a record
@ -191,7 +196,7 @@ abstract class SilverStripeNavigatorItem extends ViewableData {
* @return boolean
*/
public function isArchived() {
if(!$this->record->hasExtension('Versioned')) return false;
if(!$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')) return false;
if(!isset($this->record->_cached_isArchived)) {
$baseClass = $this->record->baseClass();
@ -282,7 +287,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
public function canView($member = null) {
return (
$this->record->hasExtension('Versioned')
$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')
&& $this->getDraftPage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
@ -333,7 +338,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
public function canView($member = null) {
return (
$this->record->hasExtension('Versioned')
$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')
&& $this->getLivePage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
@ -383,7 +388,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
public function canView($member = null) {
return (
$this->record->hasExtension('Versioned')
$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')
&& $this->isArchived()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\ORM\DataObject;
/**
* Used to edit the SiteTree->URLSegment property, and suggest input based on the serverside rules
* defined through {@link SiteTree->generateURLSegment()} and {@link URLSegmentFilter}.
@ -9,7 +11,6 @@
* @package cms
* @subpackage forms
*/
class SiteTreeURLSegmentField extends TextField {
/**
@ -73,6 +74,7 @@ class SiteTreeURLSegmentField extends TextField {
/**
* @param string $string The secondary text to show
* @return $this
*/
public function setHelpText($string){
$this->helpText = $string;
@ -88,7 +90,8 @@ class SiteTreeURLSegmentField extends TextField {
}
/**
* @param the url that prefixes the page url segment field
* @param string $url the url that prefixes the page url segment field
* @return $this
*/
public function setURLPrefix($url){
$this->urlPrefix = $url;
@ -96,7 +99,7 @@ class SiteTreeURLSegmentField extends TextField {
}
/**
* @return the url prefixes the page url segment field to show in template
* @return string the url prefixes the page url segment field to show in template
*/
public function getURLPrefix(){
return $this->urlPrefix;
@ -107,7 +110,7 @@ class SiteTreeURLSegmentField extends TextField {
}
/**
* @return Indicator for UI to respond to changes accurately,
* @return string Indicator for UI to respond to changes accurately,
* and auto-update the field value if changes to the default occur.
* Does not set the field default value.
*/

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\DataObject;
/**
* This interface lets us set up objects that will tell us what the current page is.
* @package cms

View File

@ -1,6 +1,10 @@
<?php
use SilverStripe\Filesystem\Storage\GeneratedAssetHandler;
use SilverStripe\ORM\DataModel;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DB;
/**
* ErrorPage holds the content for the page of an error response.
* Renders the page on each publish action into a static HTML file

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\DataObject;
/**
* A redirector page redirects when the page is visited.
*

View File

@ -1,4 +1,14 @@
<?php
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\HiddenClass;
/**
* Basic data-object representing all pages within the site tree. All page types that live within the hierarchy should
* inherit from this. In addition, it contains a number of static methods for querying the site tree and working with
@ -142,8 +152,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
private static $casting = array(
"Breadcrumbs" => "HTMLText",
"LastEdited" => "SS_Datetime",
"Created" => "SS_Datetime",
'Link' => 'Text',
'RelativeLink' => 'Text',
'AbsoluteLink' => 'Text',
@ -188,8 +196,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
private static $description = 'Generic content page';
private static $extensions = array(
"Hierarchy",
"Versioned",
'SilverStripe\ORM\Hierarchy\Hierarchy',
'SilverStripe\ORM\Versioning\Versioned',
"SiteTreeLinkTracking"
);

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\ORM\DataExtension;
/**
* Plug-ins for additional functionality in your SiteTree classes.
*

View File

@ -1,5 +1,10 @@
<?php
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataExtension;
/**
* Extension applied to {@see File} object to track links to {@see SiteTree} records.
*
@ -109,7 +114,7 @@ class SiteTreeFileExtension extends DataExtension {
*/
public function onAfterDelete() {
// Skip live stage
if(\Versioned::get_stage() === Versioned::LIVE) {
if(Versioned::get_stage() === Versioned::LIVE) {
return;
}

View File

@ -1,5 +1,10 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataExtension;
/**
* @todo Cleanup, refactor, test this class
*

View File

@ -5,7 +5,13 @@
* @subpackage model
*/
use SilverStripe\Model\FieldType\DBHTMLText;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
/**
* Adds tracking of links in any HTMLText fields which reference SiteTree or File items.
@ -195,7 +201,7 @@ class SiteTreeLinkTracking extends DataExtension {
*/
public function augmentSyncLinkTracking() {
// Skip live tracking
if(\Versioned::get_stage() == \Versioned::LIVE) {
if(Versioned::get_stage() == Versioned::LIVE) {
return;
}

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Versioning\Versioned;
/**
* Virtual Page creates an instance of a page, with the same fields that the original page had, but readonly.
* This allows you can have a page in mulitple places in the site structure, with different children without duplicating the content

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage reports

View File

@ -1,11 +1,14 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ArrayList;
/**
* Content side-report listing pages with broken links
* @package cms
* @subpackage content
*/
class BrokenLinksReport extends SS_Report {
public function title() {
@ -100,7 +103,7 @@ class BrokenLinksReport extends SS_Report {
),
"LastEdited" => array(
"title" => $dateTitle,
'casting' => 'SS_Datetime->Full'
'casting' => 'DBDatetime->Full'
),
"BrokenReason" => array(
"title" => _t('BrokenLinksReport.ColumnProblemType', "Problem type")

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage reports

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage reports

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\DataObject;
/**
* @package cms
* @subpackage reports
@ -19,7 +22,7 @@ class RecentlyEditedReport extends SS_Report {
}
public function sourceRecords($params = null) {
$threshold = strtotime('-14 days', SS_Datetime::now()->Format('U'));
$threshold = strtotime('-14 days', DBDatetime::now()->Format('U'));
return DataObject::get("SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC");
}

View File

@ -1,11 +1,13 @@
<?php
use SilverStripe\ORM\FieldType\DBField;
/**
* Extension to provide a search interface when applied to ContentController
*
* @package cms
* @subpackage search
*/
use SilverStripe\Model\FieldType\DBField;
class ContentControllerSearchExtension extends Extension {
private static $allowed_actions = array(
'SearchForm',

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\SS_List;
/**
* Standard basic search form which conducts a fulltext search on all {@link SiteTree}
* objects.

View File

@ -1,4 +1,9 @@
<?php
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
/**
* Rewrites plain internal HTML links into shortcode form, using existing link tracking information.
*

View File

@ -1,5 +1,9 @@
<?php
use SilverStripe\Model\FieldType\DBDatetime;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ArrayList;
/**
* Identify "orphaned" pages which point to a parent

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
/**
* @package cms
* @subpackage tasks

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
/**
* @package cms
* @subpackage tasks

View File

@ -8,7 +8,9 @@ use SilverStripe\BehatExtension\Context\SilverStripeContext,
SilverStripe\BehatExtension\Context\FixtureContext,
SilverStripe\Framework\Test\Behaviour\CmsFormsContext,
SilverStripe\Framework\Test\Behaviour\CmsUiContext,
SilverStripe\Cms\Test\Behaviour;
SilverStripe\Cms\Test\Behaviour,
SilverStripe\ORM\Versioning\Versioned;
/**
* Features context
@ -41,7 +43,7 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
$blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
/** @var \SiteTree $obj */
$obj->copyVersionToStage(\Versioned::DRAFT, \Versioned::LIVE);
$obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
});
$factory->define($class, $blueprint);
}

View File

@ -10,7 +10,9 @@ use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Exception\PendingException,
Behat\Mink\Driver\Selenium2Driver,
Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
Behat\Gherkin\Node\TableNode,
SilverStripe\ORM\Versioning\Versioned;
/**
* Context used to create fixtures in the SilverStripe ORM.
@ -39,7 +41,7 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
$obj = $this->fixtureFactory->createObject($class, $id, $fields);
}
$obj->write();
$obj->copyVersionToStage(\Versioned::DRAFT, \Versioned::LIVE);
$obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
}
/**

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List;
/**
* Tests {@see AssetAdmin}
*/

View File

@ -1,5 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* Tests CMS Specific subclasses of {@see CMSBatchAction}

View File

@ -1,4 +1,10 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\HiddenClass;
/**
* @package cms
* @subpackage tests

View File

@ -1,10 +1,11 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage tests
*/
class CMSPageHistoryControllerTest extends FunctionalTest {
protected static $fixture_file = 'CMSPageHistoryControllerTest.yml';

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
class CMSSiteTreeFilterTest extends SapphireTest {
protected static $fixture_file = 'CMSSiteTreeFilterTest.yml';

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage tests

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
class ContentControllerSearchExtensionTest extends SapphireTest {
public function testCustomSearchFormClassesToTest() {
@ -27,7 +30,7 @@ class ContentControllerSearchExtensionTest extends SapphireTest {
public function tearDownOnce() {
parent::tearDownOnce();
Config::inst()->update('File', 'create_table_options', array('MySQLDatabase' => 'ENGINE=InnoDB'));
Config::inst()->update('File', 'create_table_options', array('SilverStripe\ORM\Connect\MySQLDatabase' => 'ENGINE=InnoDB'));
File::remove_extension('FulltextSearchable');
}

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage tests

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage tests

View File

@ -1,5 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
class ErrorPageFileExtensionTest extends SapphireTest {
protected static $fixture_file = 'ErrorPageTest.yml';

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage tests

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataObject;
/**
* Tests link tracking to files and images.
*/

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DB;
/**
* Possible actions:
* - action_save

View File

@ -1,5 +1,8 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataExtension;
/**
* Tests {@see SiteTreeLinkTracking} broken links feature: LinkTracking
*/

View File

@ -1,4 +1,9 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
/**
* Tests {@see SiteTreeLinkTracking} broken links feature: LinkTracking
*

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage tests

View File

@ -1,4 +1,11 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\DataExtension;
/**
* @package cms
* @subpackage tests

View File

@ -1,6 +1,13 @@
<?php
use SilverStripe\Model\FieldType\DBVarchar;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\ORM\DataExtension;
class VirtualPageTest extends FunctionalTest {
protected static $fixture_file = 'VirtualPageTest.yml';

View File

@ -1,9 +1,12 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBDatetime;
/**
* @package cms
* @subpackage tests
*/
class CmsReportsTest extends SapphireTest {
protected static $fixture_file = 'CmsReportsTest.yml';
@ -48,7 +51,7 @@ class CmsReportsTest extends SapphireTest {
}
public function testRecentlyEdited() {
SS_Datetime::set_mock_now('31-06-2009 00:00:00');
DBDatetime::set_mock_now('31-06-2009 00:00:00');
$after = $this->objFromFixture('SiteTree', 'after');
$before = $this->objFromFixture('SiteTree', 'before');
@ -60,7 +63,7 @@ class CmsReportsTest extends SapphireTest {
$this->assertContains($after->ID, $r->records(array())->column('ID'));
$this->assertNotContains($before->ID, $r->records(array())->column('ID'));
SS_DateTime::clear_mock_now();
DBDatetime::clear_mock_now();
}
/**

View File

@ -1,4 +1,8 @@
<?php
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
/**
* @package cms
* @subpackage testing

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\DataObject;
/**
* @package cms
* @subpackage tests

View File

@ -1,4 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
/**
* <h2>Fixture tree</h2>
* <code>