Skip to content

Commit

Permalink
MNT lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Sep 20, 2023
1 parent 791cf48 commit c7f49cf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
27 changes: 8 additions & 19 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
<?xml version="1.0"?>
<ruleset name="SS4">
<description>Coding standard for SilverStripe 4.x</description>
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<!-- Don't sniff third party libraries -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/thirdparty/*</exclude-pattern>
<file>src</file>
<file>tests</file>

<!-- Show progress and output sniff names on violation, and add colours -->
<arg value="sp"/>
<arg name="colors"/>

<!-- Use PSR-2 as a base standard -->
<rule ref="PSR2">
<!-- Allow classes to not declare a namespace -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>

<!-- Allow underscores in class names -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>

<!-- Allow non camel cased method names -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>
</ruleset>
8 changes: 7 additions & 1 deletion src/Extension/BaseElementExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ public function updateCMSFields(FieldList $fields)
$tab->setTitle(_t(__CLASS__ . '.LinkedTo', 'Linked To'));

if ($ownerPage = $this->owner->getPage()) {
if ($ownerPage->hasMethod('CMSEditLink')) {
$link = $ownerPage->canEdit() ? $ownerPage->CMSEditLink() : $ownerPage->Link();
} else {
$link = $ownerPage->Link();
}

$fields->addFieldToTab(
'Root.VirtualClones',
LiteralField::create(
Expand All @@ -180,7 +186,7 @@ public function updateCMSFields(FieldList $fields)
"<p>"
. _t(__CLASS__ . '.OriginalContentFrom', 'The original content element appears on')
. " <a href='%s'>%s</a></p>",
($ownerPage->hasMethod('CMSEditLink') && $ownerPage->canEdit()) ? $ownerPage->CMSEditLink() : $ownerPage->Link(),
$link,
$ownerPage->MenuTitle
)
),
Expand Down
15 changes: 12 additions & 3 deletions src/Model/ElementVirtual.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,22 @@ public function getCMSFields()
if ($invalid) {
$warning = _t(
__CLASS__ . '.InvalidPublishStateWarning',
'Error: The original element is not published. This element will not work on the live site until you click the link below and publish it.'
'Error: The original element is not published. This element will not work on the live site until ' .
'you click the link below and publish it.'
);

$fields->addFieldToTab('Root.Main', LiteralField::create('WarningHeader', '<p class="message error">' . $warning . '</p>'));
$fields->addFieldToTab(
'Root.Main',
LiteralField::create(
'WarningHeader',
'<p class="message error">' . $warning . '</p>'
)
);
}

$availableBlocks = BaseElement::get()->filter('AvailableGlobally', 1)->exclude('ClassName', ElementVirtual::class);
$availableBlocks = BaseElement::get()
->filter('AvailableGlobally', 1)
->exclude('ClassName', ElementVirtual::class);

$fields->replaceField(
'LinkedElementID',
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/ResetGloballyEnabledElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ResetGloballyEnabledElements extends BuildTask
{
protected $title = 'Reset Globally Enabled elements';

protected $description = 'Reset individual elements \'AvailableGlobally\' setting with the default_global_elements config';
protected $description = 'Reset individual elements \'AvailableGlobally\' setting via the YAML config';

public function run($request)
{
Expand Down

0 comments on commit c7f49cf

Please sign in to comment.