X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FIssue.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FIssue.php;h=77c41a4b0e6ba3fe57b4210a4f491b89bd144b70;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Issue.php b/web/modules/contrib/drupalmoduleupgrader/src/Issue.php new file mode 100644 index 000000000..77c41a4b0 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Issue.php @@ -0,0 +1,231 @@ +target = $target; + $this->setTitle($title); + + if (isset($summary)) { + $this->setSummary($summary); + } + + $this->parser = new Markdown(); + $this->parser->html5 = TRUE; + } + + /** + * {@inheritdoc} + */ + public function getTitle() { + return $this->parser->parseParagraph($this->title); + } + + /** + * {@inheritdoc} + */ + public function setTitle($title) { + $this->title = (string) $title; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getSummary() { + return $this->parser->parse($this->summary); + } + + /** + * {@inheritdoc} + */ + public function setSummary($summary) { + $this->summary = (string) $summary; + return $this; + } + + /** + * {@inheritdoc} + */ + public function addDocumentation($url, $title) { + $this->documentation[] = [ + 'url' => $url, + 'title' => $this->parser->parseParagraph($title), + ]; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getDocumentation() { + return $this->documentation; + } + + /** + * {@inheritdoc} + */ + public function addAffectedFile($file, AnalyzerInterface $detector) { + if (empty($this->violations[$file])) { + $this->violations[$file] = []; + } + $this->addDetector($detector); + return $this; + } + + /** + * {@inheritdoc} + */ + public function addViolation(Node $node, AnalyzerInterface $detector) { + $file = $node->getFilename(); + if ($file) { + $this->violations[$file][] = [ + 'line_number' => $node->getLineNumber(), + ]; + } + else { + throw new \DomainException('Cannot record an issue violation from a detached node.'); + } + $this->addDetector($detector); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getViolations() { + $return_violations = []; + + foreach ($this->violations as $file => $file_violations) { + if ($file_violations) { + foreach ($file_violations as $violation) { + $violation['file'] = $file; + $return_violations[] = $violation; + } + } + else { + $return_violations[] = ['file' => $file]; + } + } + + return $return_violations; + } + + /** + * {@inheritdoc} + */ + public function getDetectors() { + return array_unique($this->detectors); + } + + /** + * {@inheritdoc} + */ + public function hasTag($tag) { + return array_key_exists($tag, $this->tags); + } + + /** + * {@inheritdoc} + */ + public function getTag($tag) { + return $this->tags[$tag]; + } + + /** + * {@inheritdoc} + */ + public function setTag($tag, $value) { + $this->tags[$tag] = $value; + return $this; + } + + /** + * {@inheritdoc} + */ + public function clearTag($tag) { + unset($this->tags[$tag]); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getFixes() { + return $this->fixes; + } + + /** + * {@inheritdoc} + */ + public function addFix($fixer_id, array $configuration = []) { + $this->fixes[] = array_merge($configuration, ['_plugin_id' => $fixer_id]); + $this->setTag('fixable', TRUE); + return $this; + } + + /** + * Stores a reference to an issue detector, if we don't already know about it, + * for use by getDetectors(). + * + * @param AnalyzerInterface $detector + */ + protected function addDetector(AnalyzerInterface $detector) { + if ($detector instanceof PluginInspectionInterface) { + $this->detectors[] = $detector->getPluginId(); + } + } + +}