Commit 51ae74ac authored by znerol's avatar znerol Committed by znerol
Browse files

Issue #3319790 by znerol: Coding style fixes

parent 93825376
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Installation related hooks for Feeds XSLT Pipeline Parser plugin.
 */

use Drupal\Core\Url;

/**
 * Implements hook_requirements().
 */
@@ -19,7 +22,7 @@ function feeds_xsltparser_requirements($phase) {
  ];
  if (!$has_domdocument) {
    $requirements['feeds_xsltparser_php_domdocument']['severity'] = REQUIREMENT_ERROR;
    $requirements['feeds_xsltparser_php_domdocument']['description'] = t('The feeds XSLT pipeline parser module requires the DOMDocument class to be available. Check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', ['@link-phpinfo' => \Drupal\Core\Url::fromRoute('system.php')]);
    $requirements['feeds_xsltparser_php_domdocument']['description'] = t('The feeds XSLT pipeline parser module requires the DOMDocument class to be available. Check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', ['@link-phpinfo' => Url::fromRoute('system.php')]);
  }

  $requirements['feeds_xsltparser_php_xsl'] = [
@@ -28,7 +31,7 @@ function feeds_xsltparser_requirements($phase) {
  ];
  if (!$has_xsl) {
    $requirements['feeds_xsltparser_php_xsl']['severity'] = REQUIREMENT_ERROR;
    $requirements['feeds_xsltparser_php_xsl']['description'] = t('The feeds XSLT pipeline parser module requires the PHP XSL extension to be available. Check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', ['@link-phpinfo' => \Drupal\Core\Url::fromRoute('system.php')]);
    $requirements['feeds_xsltparser_php_xsl']['description'] = t('The feeds XSLT pipeline parser module requires the PHP XSL extension to be available. Check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', ['@link-phpinfo' => Url::fromRoute('system.php')]);
  }

  return $requirements;
+3 −1
Original line number Diff line number Diff line
<?php

/**
 * @file
 * @file:   feeds_xsltparser.module: This module implements a simple XSLT
 *          pipeline for feeds.
 */
@@ -10,7 +12,7 @@
function feeds_xsltparser_theme() {
  $theme['feeds_xsltparser_pipelist'] = [
    'variables' => [
      'pipes' => []
      'pipes' => [],
    ],
  ];

+16 −14
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ use Drupal\feeds_xsltparser\XSLTPipeRepository;
 * The configuration form for the XSLT pipeline parser.
 */
class XsltPipelineParserForm extends ExternalPluginFormBase {

  /**
   * {@inheritdoc}
   */
@@ -25,7 +26,8 @@ class XsltPipelineParserForm extends ExternalPluginFormBase {
    $xslt_dir = $this->configGetXsltDirectory();
    if ($xslt_dir === FALSE) {
      $count = 0;
    } else {
    }
    else {
      $repository = new XSLTPipeRepository($xslt_dir);
      $config = $repository->config();
      $fieldmap = $repository->extractFieldmap($config);
@@ -40,7 +42,8 @@ class XsltPipelineParserForm extends ExternalPluginFormBase {
         $this->t('In order to create pipelines upload your XSLT files into the specified directory. If you place folders containing XSLT files under the XSLT pipeline path, the stylesheets will be executed in alphabetic order, each operating on the result of its predecessor.') . '<br/>' .
         $this->t('Each pipeline is exposed as a source field in the mapping section'),
      ];
    } else {
    }
    else {
      $items = $fieldmap['mapper']['items'];
      $pipes = [];
      foreach ($fieldLabels as $label) {
@@ -56,15 +59,13 @@ class XsltPipelineParserForm extends ExternalPluginFormBase {
    return $form;
  }


  /**
   * Returns a string describing the given field extractor fragemnt from a
   * pipeline config. Typically you use this to generate help text. See
   * FeedsXSLTPipelineParser:configForm for an example of how this function
   * is called.
   */
  private function describeFieldExtractor($item, string $base_dir)
  {
  private function describeFieldExtractor($item, string $base_dir) {
    $reloffset = mb_strlen($base_dir) + 1;

    $output = $this->t('Unknown extractor type');
@@ -94,14 +95,15 @@ class XsltPipelineParserForm extends ExternalPluginFormBase {
        $output .= ' ';
        $output .= $this->t('Input gets preprocessed using @filetext %files, counting and value extraction is done on the result obtained form the preprocessor.', [
          '@filetext' => $this->formatPlural(count($preprocs), 'stylesheet', 'stylesheet chain comprised of the files'),
          '%files' => implode(', ', $preprocs)
          '%files' => implode(', ', $preprocs),
        ]);
      }
    } elseif ($item['type'] == 'XSLTChain') {
    }
    elseif ($item['type'] == 'XSLTChain') {
      $extractors = substr_replace($item['stylesheets'], '', 0, $reloffset);
      $output = $this->t('Extract one field value using @filetext %files.', [
        '@filetext' => $this->formatPlural(count($extractors), 'stylesheet', 'stylesheet chain comprised of the files'),
        '%files' => implode(', ', $extractors)
        '%files' => implode(', ', $extractors),
      ]);
    }

+5 −3
Original line number Diff line number Diff line
<?php

namespace Drupal\feeds_xsltparser\Feeds\Parser;

use Drupal\feeds\FeedInterface;
@@ -23,6 +24,7 @@ use Drupal\feeds_xsltparser\XSLTPipeRepository;
 * )
 */
class XSLTPipelineParser extends ParserBase {

  private function configGetXsltDirectory() {
    $xslt_dir = $this->configuration['xslt_dir'];
    if ($xslt_dir[0] != '/') {
@@ -79,9 +81,8 @@ class XSLTPipelineParser extends ParserBase {
    return (new ParserResult())->addItems($items);
  }


  /**
   * Return the list of XSLT pipelines found in the pipelines directory
   * Return the list of XSLT pipelines found in the pipelines directory.
   */
  public function getMappingSources() {
    $xslt_dir = $this->configGetXsltDirectory();
@@ -114,4 +115,5 @@ class XSLTPipelineParser extends ParserBase {
      'xslt_dir' => 'sites/all/libraries/xslt_pipelines',
    ];
  }

}
+3 −1
Original line number Diff line number Diff line
<?php

namespace Drupal\feeds_xsltparser;

use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -84,7 +85,7 @@ class FeedsXSLTChainLogProxy implements XSLTChainLogProxy {
  }

  /**
   * Reset original error
   * Reset original error.
   */
  public function resetOriginalError() {
    $this->originalError = NULL;
@@ -98,4 +99,5 @@ class FeedsXSLTChainLogProxy implements XSLTChainLogProxy {
  public function getOriginalError() {
    return [$this->originalError, $this->originalPrefix, $this->originalXslt];
  }

}
Loading