You are here

protected function PrintableCssInclude::extractCssIncludeToken in Printer and PDF versions for Drupal 8+ 8

Same name and namespace in other branches
  1. 2.x src/PrintableCssInclude.php \Drupal\printable\PrintableCssInclude::extractCssIncludeToken()

Extract the theme token from a CSS include path.

Parameters

string $path: An include path (optionally) with a taken to extract in the form: "[theme:theme_machine_name]".

Return value

string|null The extracted token in the form "[theme:theme_machine_name]" or NULL if no token exists in the string.

1 call to PrintableCssInclude::extractCssIncludeToken()
PrintableCssInclude::getCssIncludePath in src/PrintableCssInclude.php
Get the configured CSS include path for printable pages.

File

src/PrintableCssInclude.php, line 64

Class

PrintableCssInclude
Helper class for the printable module.

Namespace

Drupal\printable

Code

protected function extractCssIncludeToken($path) {
  $start = '[theme:';
  $end = ']';

  // Fail fast.
  if (strpos($path, $start) === FALSE) {
    return NULL;
  }
  $index = strpos($path, $start);

  // Here strpos is zero indexed.
  $length = strpos($path, $end, $index) + 1;
  return substr($path, $index, $length);
}