You are here

protected function QueryPathXmlParser::loadLibrary in Feeds extensible parsers 8

Loads the necessary library.

Subclasses can override this to load the necessary library. It will be called automatically.

Throws

\RuntimeException Thrown if the library does not exist.

Overrides ParserBase::loadLibrary

1 call to QueryPathXmlParser::loadLibrary()
QueryPathXmlParser::validateExpression in src/Feeds/Parser/QueryPathXmlParser.php
Validates an expression.

File

src/Feeds/Parser/QueryPathXmlParser.php, line 161

Class

QueryPathXmlParser
Defines a XML parser using QueryPath.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function loadLibrary() {
  if (!class_exists('QueryPath')) {

    // Check if the querypath library is installed manually.
    $ns = \Drupal::service('container.namespaces');
    if (!empty($ns['QueryPath']) && is_dir($ns['QueryPath'])) {

      // The querypath namespace is expected to point to
      // feeds_ex/lib/querypath-QueryPath/v3.0.5/src/QueryPath. The file to
      // require should be feeds_ex/lib/querypath-QueryPath/v3.0.5/src/qp.php.
      $path = dirname($ns['QueryPath']) . '/qp.php';
      if (is_file($path)) {
        require_once $path;
      }
    }
  }
  if (!class_exists('QueryPath')) {
    throw new RuntimeException($this
      ->t('The QueryPath library is not installed.'));
  }
}