You are here

protected static function AssetManager::parseForCoreCKEditorVersion in CKEditor Media Embed Plugin 8

1 call to AssetManager::parseForCoreCKEditorVersion()
AssetManager::getCKEditorVersion in src/AssetManager.php

File

src/AssetManager.php, line 191

Class

AssetManager
The AssetManager facade for managing CKEditor plugins.

Namespace

Drupal\ckeditor_media_embed

Code

protected static function parseForCoreCKEditorVersion($path, $extension) {
  $version = '';
  $libraries = [];
  $library_file = \Drupal::root() . '/' . $path . '/' . $extension . '.libraries.yml';
  if (file_exists($library_file)) {
    try {
      $libraries = Yaml::decode(file_get_contents($library_file));
      if (!empty($libraries['ckeditor']['version'])) {
        $version = $libraries['ckeditor']['version'];
        $version_extra_position = strpos($libraries['ckeditor']['version'], '+');
        if ($version_extra_position > 0) {
          $version = substr($version, 0, $version_extra_position);
        }
      }
    } catch (InvalidDataTypeException $e) {

      // Rethrow a more helpful exception to provide context.
      throw new InvalidLibraryFileException(sprintf('Invalid library definition in %s: %s', $library_file, $e
        ->getMessage()), 0, $e);
    }
  }
  return $version;
}