You are here

class Markdown in Markdown 3.0.x

Same name in this branch
  1. 3.0.x src/Markdown.php \Drupal\markdown\Markdown
  2. 3.0.x src/Plugin/Filter/Markdown.php \Drupal\markdown\Plugin\Filter\Markdown
Same name and namespace in other branches
  1. 8.2 src/Markdown.php \Drupal\markdown\Markdown

Class Markdown.

Hierarchy

Expanded class hierarchy of Markdown

1 file declares its use of Markdown
markdown.module in ./markdown.module
Markdown module.
3 string references to 'Markdown'
markdown.info.yml in ./markdown.info.yml
markdown.info.yml
markdown.services.yml in ./markdown.services.yml
markdown.services.yml
markdown_requirements in ./markdown.install
Implements hook_requirements().
1 service uses Markdown
markdown in ./markdown.services.yml
Drupal\markdown\Markdown

File

src/Markdown.php, line 15

Namespace

Drupal\markdown
View source
class Markdown implements MarkdownInterface {
  use ContainerAwareTrait;
  use DependencySerializationTrait;
  use StringTranslationTrait;

  /**
   * The MarkdownParser Plugin Manager.
   *
   * @var \Drupal\markdown\MarkdownParserManagerInterface
   */
  protected $parsers;

  /**
   * Markdown constructor.
   *
   * @param \Drupal\markdown\MarkdownParserManagerInterface $markdown_parsers
   *   The MarkdownParser Plugin Manager service.
   */
  public function __construct(MarkdownParserManagerInterface $markdown_parsers) {
    $this->parsers = $markdown_parsers;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container = NULL) {
    if (!isset($container)) {
      $container = \Drupal::getContainer();
    }
    return new static($container
      ->get('plugin.manager.markdown.parser'));
  }

  /**
   * {@inheritdoc}
   */
  public static function load($id, $markdown = NULL, $parser = NULL, $filter = NULL, AccountInterface $account = NULL, LanguageInterface $language = NULL) {
    return static::create()
      ->getParser($parser, $filter, $account)
      ->load($id, $markdown, $language);
  }

  /**
   * {@inheritdoc}
   */
  public static function loadPath($id, $path, $parser = NULL, $filter = NULL, AccountInterface $account = NULL, LanguageInterface $language = NULL) {
    return static::create()
      ->getParser($parser, $filter, $account)
      ->loadPath($id, $path, $language);
  }

  /**
   * {@inheritdoc}
   */
  public static function loadUrl($id, $url, $parser = NULL, $filter = NULL, AccountInterface $account = NULL, LanguageInterface $language = NULL) {
    return static::create()
      ->getParser($parser, $filter, $account)
      ->loadUrl($id, $url, $language);
  }

  /**
   * {@inheritdoc}
   */
  public static function parse($markdown, $parser = NULL, $filter = NULL, AccountInterface $account = NULL, LanguageInterface $language = NULL) {
    return static::create()
      ->getParser($parser, $filter, $account)
      ->parse($markdown, $language);
  }

  /**
   * {@inheritdoc}
   */
  public static function parsePath($path, $parser = NULL, $filter = NULL, AccountInterface $account = NULL, LanguageInterface $language = NULL) {
    return static::create()
      ->getParser($parser, $filter, $account)
      ->parsePath($path, $language);
  }

  /**
   * {@inheritdoc}
   */
  public static function parseUrl($url, $parser = NULL, $filter = NULL, AccountInterface $account = NULL, LanguageInterface $language = NULL) {
    return static::create()
      ->getParser($parser, $filter, $account)
      ->parseUrl($url, $language);
  }

  /**
   * {@inheritdoc}
   */
  public function getParser($parser = NULL, $filter = NULL, AccountInterface $account = NULL) {
    return $this->parsers
      ->createInstance($parser, [
      'filter' => $filter,
      'account' => $account,
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
Markdown::$parsers protected property The MarkdownParser Plugin Manager.
Markdown::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
Markdown::getParser public function Retrieves a specific MarkdownParser. Overrides MarkdownInterface::getParser
Markdown::load public static function Loads a cached ParsedMarkdown object. Overrides MarkdownInterface::load
Markdown::loadPath public static function Loads a cached ParsedMarkdown object. Overrides MarkdownInterface::loadPath
Markdown::loadUrl public static function Loads a cached ParsedMarkdown object. Overrides MarkdownInterface::loadUrl
Markdown::parse public static function Parses markdown into HTML. Overrides MarkdownInterface::parse
Markdown::parsePath public static function Parses the file contents of a markdown file into HTML. Overrides MarkdownInterface::parsePath
Markdown::parseUrl public static function Parses the contents of a URL containing markdown into HTML. Overrides MarkdownInterface::parseUrl
Markdown::__construct public function Markdown constructor.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.