Skip to content

Commit

Permalink
Merge pull request silverstripe#14 from open-sausages/pulls/4.0/remov…
Browse files Browse the repository at this point in the history
…e-object

API Remove object class references
  • Loading branch information
flamerohr authored May 23, 2017
2 parents 5e97112 + 4f7af08 commit 54a5f73
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Versioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use SilverStripe\Control\Cookie;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Object;
use SilverStripe\Core\Resettable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\FieldList;
Expand Down Expand Up @@ -259,8 +258,6 @@ public function augmentDataQueryCreation(SQLSelect &$query, DataQuery &$dataQuer
*/
public function __construct($mode = self::STAGEDVERSIONED)
{
parent::__construct();

// Handle deprecated behaviour
if ($mode === 'Stage' && func_num_args() === 1) {
Deprecation::notice("5.0", "Versioned now takes a mode as a single parameter");
Expand Down Expand Up @@ -1042,9 +1039,9 @@ protected function lookupReverseOwners()
{
// Find all classes with 'owns' config
$lookup = [];
foreach (ClassInfo::subclassesFor('SilverStripe\ORM\DataObject') as $class) {
foreach (ClassInfo::subclassesFor(DataObject::class) as $class) {
// Ensure this class is versioned
if (!Object::has_extension($class, static::class)) {
if (!DataObject::has_extension($class, static::class)) {
continue;
}

Expand Down Expand Up @@ -1112,7 +1109,7 @@ public function findRelatedObjects($source, $recursive = true, $list = null)
"Invalid %s config value \"%s\" on object on class \"%s\"",
$source,
$relationship,
$owner->class
get_class($owner)
), E_USER_WARNING);
continue;
}
Expand Down Expand Up @@ -1362,7 +1359,7 @@ public function canViewVersioned($member = null)

// If we weren't definitely loaded from live, and we can't view non-live content, we need to
// check to make sure this version is the live version and so can be viewed
$latestVersion = Versioned::get_versionnumber_by_stage($owner->class, static::LIVE, $owner->ID);
$latestVersion = Versioned::get_versionnumber_by_stage(get_class($owner), static::LIVE, $owner->ID);
if ($latestVersion == $owner->Version) {
// Even if this is loaded from a non-live stage, this is the live version
return true;
Expand All @@ -1375,7 +1372,7 @@ public function canViewVersioned($member = null)
}

// Fall back to default permission check
$permissions = Config::inst()->get($owner->class, 'non_live_permissions');
$permissions = Config::inst()->get(get_class($owner), 'non_live_permissions');
$check = Permission::checkMember($member, $permissions);
return (bool)$check;
}
Expand All @@ -1399,7 +1396,7 @@ public function canViewStage($stage = 'Live', $member = null)
Versioned::set_stage($stage);

$owner = $this->owner;
$versionFromStage = DataObject::get($owner->class)->byID($owner->ID);
$versionFromStage = DataObject::get(get_class($owner))->byID($owner->ID);

Versioned::set_reading_mode($oldMode);
return $versionFromStage ? $versionFromStage->canView($member) : false;
Expand Down Expand Up @@ -1935,8 +1932,8 @@ public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $
public function compareVersions($from, $to)
{
$owner = $this->owner;
$fromRecord = Versioned::get_version($owner->class, $owner->ID, $from);
$toRecord = Versioned::get_version($owner->class, $owner->ID, $to);
$fromRecord = Versioned::get_version(get_class($owner), $owner->ID, $from);
$toRecord = Versioned::get_version(get_class($owner), $owner->ID, $to);

$diff = new DataDifferencer($fromRecord, $toRecord);

Expand Down Expand Up @@ -2370,7 +2367,7 @@ public function isLatestVersion()
return false;
}

$version = static::get_latest_version($owner->class, $owner->ID);
$version = static::get_latest_version(get_class($owner), $owner->ID);
return ($version->Version == $owner->Version);
}

Expand Down

0 comments on commit 54a5f73

Please sign in to comment.