Skip to content

Commit

Permalink
API Remove deprecated 5.0 methods
Browse files Browse the repository at this point in the history
API Support new extend*() format for extension methods
  • Loading branch information
Damian Mooyman committed Jan 12, 2018
1 parent 5299ec3 commit d57333e
Showing 1 changed file with 24 additions and 59 deletions.
83 changes: 24 additions & 59 deletions src/Versioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,6 @@ public function augmentDataQueryCreation(SQLSelect &$query, DataQuery &$dataQuer
*/
public function __construct($mode = self::STAGEDVERSIONED)
{
// Handle deprecated behaviour
if ($mode === 'Stage' && func_num_args() === 1) {
Deprecation::notice("5.0", "Versioned now takes a mode as a single parameter");
$mode = static::VERSIONED;
} elseif (is_array($mode) || func_num_args() > 1) {
Deprecation::notice("5.0", "Versioned now takes a mode as a single parameter");
$mode = func_num_args() > 1 || count($mode) > 1
? static::STAGEDVERSIONED
: static::VERSIONED;
}

if (!in_array($mode, [static::STAGEDVERSIONED, static::VERSIONED])) {
throw new InvalidArgumentException("Invalid mode: {$mode}");
}
Expand Down Expand Up @@ -1143,11 +1132,6 @@ protected function lookupReverseOwners()
*/
public function canPublish($member = null)
{
// Skip if invoked by extendedCan()
if (func_num_args() > 4) {
return null;
}

if (!$member) {
$member = Security::getCurrentUser();
}
Expand All @@ -1167,6 +1151,12 @@ public function canPublish($member = null)
return $owner->canEdit($member);
}

protected function extendCanPublish()
{
// prevent canPublish() from extending itself
return null;
}

/**
* Check if the current user can delete this record from live
*
Expand All @@ -1175,11 +1165,6 @@ public function canPublish($member = null)
*/
public function canUnpublish($member = null)
{
// Skip if invoked by extendedCan()
if (func_num_args() > 4) {
return null;
}

if (!$member) {
$member = Security::getCurrentUser();
}
Expand All @@ -1199,6 +1184,12 @@ public function canUnpublish($member = null)
return $owner->canPublish($member);
}

protected function extendCanUnpublish()
{
// prevent canUnpublish() extending itself
return null;
}

/**
* Check if the current user is allowed to archive this record.
* If extended, ensure that both canDelete and canUnpublish are extended also
Expand All @@ -1208,11 +1199,6 @@ public function canUnpublish($member = null)
*/
public function canArchive($member = null)
{
// Skip if invoked by extendedCan()
if (func_num_args() > 4) {
return null;
}

if (!$member) {
$member = Security::getCurrentUser();
}
Expand Down Expand Up @@ -1242,6 +1228,12 @@ public function canArchive($member = null)
return true;
}

protected function extendCanArchive()
{
// Prevent canArchive() extending itself
return null;
}

/**
* Check if the user can revert this record to live
*
Expand All @@ -1252,11 +1244,6 @@ public function canRevertToLive($member = null)
{
$owner = $this->owner;

// Skip if invoked by extendedCan()
if (func_num_args() > 4) {
return null;
}

// Can't revert if not on live
if (!$owner->isPublished()) {
return false;
Expand All @@ -1280,6 +1267,12 @@ public function canRevertToLive($member = null)
return $owner->canEdit($member);
}

protected function extendCanRevertToLive()
{
// Prevent canRevertToLive() extending itself
return null;
}

/**
* Extend permissions to include additional security for objects that are not published to live.
*
Expand Down Expand Up @@ -1452,15 +1445,6 @@ public function latestPublished()
)->value();
}

/**
* @deprecated 4.0..5.0
*/
public function doPublish()
{
Deprecation::notice('5.0', 'Use publishRecursive instead');
return $this->owner->publishRecursive();
}

/**
* Publish this object and all owned objects to Live
*
Expand Down Expand Up @@ -1714,15 +1698,6 @@ public function onAfterRevertToLive()
$owner->unlinkDisownedObjects(Versioned::LIVE, Versioned::DRAFT);
}

/**
* @deprecated 4.0..5.0
*/
public function publish($fromStage, $toStage, $createNewVersion = false)
{
Deprecation::notice('5.0', 'Use copyVersionToStage instead');
$this->owner->copyVersionToStage($fromStage, $toStage, $createNewVersion);
}

/**
* Move a database record from one stage to the other.
*
Expand Down Expand Up @@ -1805,16 +1780,6 @@ public function getMigratingVersion()
return $this->owner->getField(self::MIGRATING_VERSION);
}

/**
* @deprecated 4.0...5.0
* @param string $version The version.
*/
public function migrateVersion($version)
{
Deprecation::notice('5.0', 'use setMigratingVersion instead');
$this->setMigratingVersion($version);
}

/**
* Set the migrating version.
*
Expand Down

0 comments on commit d57333e

Please sign in to comment.