Skip to content

Commit d19ef66

Browse files
authored
Merge pull request #715 from ucfopen/issue/713-disable-link-rules
Issue/713 disable link rules
2 parents 1702d81 + 9ff90fe commit d19ef66

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ MESSENGER_TRANSPORT_DSN=doctrine://default
4848

4949
###> phpally ###
5050
# Rule exclusion list as a comma-separated list of rule IDs.
51-
PHPALLY_EXCLUDED_RULES=""
51+
PHPALLY_EXCLUDED_RULES="
52+
BrokenLink,
53+
RedirectedLink
54+
"
5255
# Rules to be treated as suggestions rather than errors. Comma-separated list of rule IDs.
5356
PHPALLY_SUGGESTION_RULES="
5457
AnchorLinksToMultiMediaRequireTranscript,

src/Services/PhpAllyService.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
use CidiLabs\PhpAlly\PhpAlly;
77

88
class PhpAllyService {
9-
9+
1010
protected $phpAlly;
1111

1212
/** @var App\Service\HtmlService */
1313
protected $htmlService;
1414

1515
protected $util;
16-
16+
1717
public function __construct(HtmlService $htmlService, UtilityService $util)
1818
{
19-
$this->phpAlly = new PhpAlly();
19+
$this->phpAlly = new PhpAlly();
2020
$this->htmlService = $htmlService;
2121
$this->util = $util;
2222
}
@@ -34,7 +34,7 @@ public function scanContentItem(ContentItem $contentItem)
3434
'vimeoApiKey' => !empty($_ENV['VIMEO_API_KEY']) ? $_ENV['VIMEO_API_KEY'] : '',
3535
'youtubeApiKey' => !empty($_ENV['YOUTUBE_API_KEY']) ? $_ENV['YOUTUBE_API_KEY'] : ''
3636
];
37-
37+
3838
return $this->phpAlly->checkMany($html, $this->getRules(), $options);
3939
}
4040

@@ -52,7 +52,7 @@ public function scanHtml($html, $rules = [])
5252
'vimeoApiKey' => !empty($_ENV['VIMEO_API_KEY']) ? $_ENV['VIMEO_API_KEY'] : '',
5353
'youtubeApiKey' => !empty($_ENV['YOUTUBE_API_KEY']) ? $_ENV['YOUTUBE_API_KEY'] : ''
5454
];
55-
55+
5656
return $this->phpAlly->checkMany($html, $rules, $options);
5757
}
5858

@@ -68,12 +68,19 @@ public function getRules()
6868

6969
protected function getEnvExcludedRules()
7070
{
71-
return array_map('trim', explode(',', $_ENV['PHPALLY_EXCLUDED_RULES']));
71+
$excluded = array_map('trim', explode(',', $_ENV['PHPALLY_EXCLUDED_RULES']));
72+
73+
return array_map(array($this, 'addRulePath'), $excluded);
7274
}
7375

7476
protected function getDbExcludedRules()
7577
{
7678
// TODO: To be implemented with the admin section
7779
return [];
7880
}
79-
}
81+
82+
private function addRulePath($rule)
83+
{
84+
return "CidiLabs\\PhpAlly\\Rule\\" . $rule;
85+
}
86+
}

0 commit comments

Comments
 (0)