-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH More standardisation #223
ENH More standardisation #223
Conversation
2f66966
to
5c1ee0e
Compare
src/Models/FileLink.php
Outdated
public function getDefaultTitle(): string | ||
protected function getDefaultTitle(): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never called outside of Link
models except in tests.
Everywhere else should use getTitle()
to get the real title.
src/Models/FileLink.php
Outdated
if (!$file->exists()) { | ||
if (!$file?->exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matches how it's used elsewhere in this class.
src/Models/Link.php
Outdated
use InvalidArgumentException; | ||
use ReflectionException; | ||
use SilverStripe\Core\ClassInfo; | ||
use SilverStripe\Core\Injector\Injector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used anymore
public function scaffoldLinkFields(array $data): FieldList | ||
{ | ||
return $this->getCMSFields(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused code
src/Models/Link.php
Outdated
public function LinkTypeHandlerName(): string | ||
/** | ||
* Get the react component used to render the modal form. | ||
*/ | ||
public function getLinkTypeHandlerName(): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getters should be prefixed with get
@@ -132,91 +133,9 @@ public function onBeforeWrite(): void | |||
parent::onBeforeWrite(); | |||
} | |||
|
|||
function setData($data): Link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused method
@@ -237,19 +156,6 @@ public function jsonSerialize(): mixed | |||
return $data; | |||
} | |||
|
|||
public function loadLinkData(array $data): Link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused method
$link = FileLink::create(); | ||
$link = new FileLink(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests should avoid using injector when they're not explicitly testing injector
@@ -35,4 +36,26 @@ public function testGetDescription(): void | |||
$link->write(); | |||
$this->assertSame('file-b.png', $link->getDescription()); | |||
} | |||
|
|||
public function testGetDefaultTitle(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matches a test in SiteTreeLinkTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code change look fine, have smoke tested locally
Description
Two commits:
Issues
Pull request checklist