Skip to content

Commit

Permalink
Merge pull request #295 from creative-commoners/pulls/4.0/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 d1d9a4e + 81a65c0 commit 7c368fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Controllers/LinkFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getClientConfig(): array
'dataUrl' => $this->Link('data'),
'sortUrl' => $this->Link('sort'),
'saveMethod' => 'post',
'formNameTemplate' => sprintf(self::FORM_NAME_TEMPLATE, '{id}'),
'formNameTemplate' => sprintf(LinkFieldController::FORM_NAME_TEMPLATE, '{id}'),
];
return $clientConfig;
}
Expand Down Expand Up @@ -319,7 +319,7 @@ private function createLinkForm(Link $link, string $operation, bool $excludeLink

// Create the form
$formFactory = Injector::inst()->get(DefaultFormFactory::class);
$name = sprintf(self::FORM_NAME_TEMPLATE, $id);
$name = sprintf(LinkFieldController::FORM_NAME_TEMPLATE, $id);
/** @var Form $form */
$form = $formFactory->getForm($this, $name, ['Record' => $link]);
$owner = $this->getOwnerFromRequest();
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getCMSFields(): FieldList
$linkTextField = $fields->dataFieldByName('LinkText');
$linkTextField->setTitle(_t(__CLASS__ . '.LINK_TEXT_TITLE', 'Link text'));
$linkTextField->setTitleTip(new Tip(_t(
self::class . '.LINK_TEXT_TEXT_DESCRIPTION',
Link::class . '.LINK_TEXT_TEXT_DESCRIPTION',
'If left blank, an appropriate default will be used on the front-end',
)));

Expand Down Expand Up @@ -191,7 +191,7 @@ public function onBeforeWrite(): void
// Ensure a Sort value is set and that it's one larger than any other Sort value for
// this owner relation so that newly created Links on MultiLinkField's are properly sorted
if (!$this->Sort) {
$this->Sort = self::get()->filter([
$this->Sort = Link::get()->filter([
'OwnerID' => $this->OwnerID,
'OwnerRelation' => $this->OwnerRelation,
])->max('Sort') + 1;
Expand Down Expand Up @@ -232,7 +232,7 @@ public function forTemplate()
{
// First look for a subclass of the email template e.g. EmailLink.ss which may be defined
// in a project. Fallback to using the generic Link.ss template which this module provides
return $this->renderWith([static::class, self::class]);
return $this->renderWith([static::class, Link::class]);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/php/Controllers/LinkFieldControllerTest/TestPhoneLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ public function getDescription(): string

public function canView($member = null)
{
return self::$fail !== 'can-view';
return TestPhoneLink::$fail !== 'can-view';
}

public function canCreate($member = null, $context = [])
{
return self::$fail !== 'can-create';
return TestPhoneLink::$fail !== 'can-create';
}

public function canEdit($member = null, $context = [])
{
return self::$fail !== 'can-edit';
return TestPhoneLink::$fail !== 'can-edit';
}

public function canDelete($member = null)
{
return self::$fail !== 'can-delete';
return TestPhoneLink::$fail !== 'can-delete';
}

public function validate(): ValidationResult
{
$validationResult = parent::validate();
if (self::$fail === 'validate') {
if (TestPhoneLink::$fail === 'validate') {
$validationResult->addFieldError('Fail', 'Fail was validate');
}
return $validationResult;
Expand Down

0 comments on commit 7c368fd

Please sign in to comment.