Skip to content

Commit

Permalink
Merge pull request #449 from creative-commoners/pulls/2.2/remove-self
Browse files Browse the repository at this point in the history
ENH Use class name instead of self
  • Loading branch information
GuySartorelli authored Jun 17, 2024
2 parents 22c72a4 + 09902f9 commit 0a279c4
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 80 deletions.
6 changes: 3 additions & 3 deletions src/ChangeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,11 @@ public function getPublishedLabel()
public function getStateLabel()
{
switch ($this->State) {
case self::STATE_OPEN:
case ChangeSet::STATE_OPEN:
return _t(__CLASS__.'.STATE_OPEN', 'Active');
case self::STATE_PUBLISHED:
case ChangeSet::STATE_PUBLISHED:
return _t(__CLASS__.'.STATE_PUBLISHED', 'Published');
case self::STATE_REVERTED:
case ChangeSet::STATE_REVERTED:
return _t(__CLASS__.'.STATE_REVERTED', 'Reverted');
default:
return null;
Expand Down
12 changes: 6 additions & 6 deletions src/ChangeSetItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function getChangeType()

// Unversioned classes have no change type
if (!$this->isVersioned()) {
return self::CHANGE_NONE;
return ChangeSetItem::CHANGE_NONE;
}

// Get change versions
Expand All @@ -153,13 +153,13 @@ public function getChangeType()

// Version comparisons
if ($draftVersion == $liveVersion) {
$type = self::CHANGE_NONE;
$type = ChangeSetItem::CHANGE_NONE;
} elseif (!$liveVersion) {
$type = self::CHANGE_CREATED;
$type = ChangeSetItem::CHANGE_CREATED;
} elseif (!$draftVersion) {
$type = self::CHANGE_DELETED;
$type = ChangeSetItem::CHANGE_DELETED;
} else {
$type = self::CHANGE_MODIFIED;
$type = ChangeSetItem::CHANGE_MODIFIED;
}
$this->extend('updateChangeType', $type, $draftVersion, $liveVersion);
return $type;
Expand Down Expand Up @@ -402,7 +402,7 @@ public function canPublish($member = null)
{
// No action for unversiond objects so no action to deny
// Implicitly added items allow publish
if (!$this->isVersioned() || $this->Added === self::IMPLICITLY) {
if (!$this->isVersioned() || $this->Added === ChangeSetItem::IMPLICITLY) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Plugins/UnpublishOnDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class UnpublishOnDelete implements ModelMutationPlugin
*/
public function getIdentifier(): string
{
return self::IDENTIFIER;
return UnpublishOnDelete::IDENTIFIER;
}

public function apply(ModelMutation $mutation, Schema $schema, array $config = []): void
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Plugins/VersionedDataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class VersionedDataObject implements ModelTypePlugin, SchemaUpdater
*/
public function getIdentifier(): string
{
return self::IDENTIFIER;
return VersionedDataObject::IDENTIFIER;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Plugins/VersionedRead.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class VersionedRead implements ModelQueryPlugin
*/
public function getIdentifier(): string
{
return self::IDENTIFIER;
return VersionedRead::IDENTIFIER;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Resolvers/VersionedResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function resolveVersionList(array $resolverContext): Closure
}

// Get all versions
return self::getVersionsList($object);
return VersionedResolver::getVersionsList($object);
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/ReadingMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public static function toDataQueryParams($mode)
switch ($parts[0]) {
case 'Archive':
$archiveStage = isset($parts[2]) ? $parts[2] : Versioned::DRAFT;
self::validateStage($archiveStage);
ReadingMode::validateStage($archiveStage);
return [
'Versioned.mode' => 'archive',
'Versioned.date' => $parts[1],
'Versioned.stage' => $archiveStage,
];
case 'Stage':
self::validateStage($parts[1]);
ReadingMode::validateStage($parts[1]);
return [
'Versioned.mode' => 'stage',
'Versioned.stage' => $parts[1],
Expand Down Expand Up @@ -133,13 +133,13 @@ public static function toQueryString($mode)
switch ($parts[0]) {
case 'Archive':
$archiveStage = isset($parts[2]) ? $parts[2] : Versioned::DRAFT;
self::validateStage($archiveStage);
ReadingMode::validateStage($archiveStage);
return [
'archiveDate' => $parts[1],
'stage' => $archiveStage,
];
case 'Stage':
self::validateStage($parts[1]);
ReadingMode::validateStage($parts[1]);
return [
'stage' => $parts[1],
];
Expand Down
2 changes: 1 addition & 1 deletion src/RecursivePublishable.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected function lookupReverseOwners()
array_shift($classes); // skip DataObject
foreach ($classes as $class) {
// Ensure this class is RecursivePublishable
if (!DataObject::has_extension($class, self::class)) {
if (!DataObject::has_extension($class, RecursivePublishable::class)) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/RestoreAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function restore($item)
);
}

$changedLocation = self::shouldRestoreToRoot($item);
$changedLocation = RestoreAction::shouldRestoreToRoot($item);

$archivedItem = Versioned::get_latest_version($classname, $id);

Expand All @@ -69,7 +69,7 @@ public static function restore($item)
->byID($archivedItem->ID);
}

$message = self::getRestoreMessage($item, $restoredItem, $changedLocation);
$message = RestoreAction::getRestoreMessage($item, $restoredItem, $changedLocation);

return $message;
}
Expand Down
Loading

0 comments on commit 0a279c4

Please sign in to comment.