You are here

protected function AnchorLink::getLibraryUrl in CKEditor Anchor Link - For Drupal 8 and 9 8.2

Get the CKEditor Link library URL.

1 call to AnchorLink::getLibraryUrl()
AnchorLink::getButtons in src/Plugin/CKEditorPlugin/AnchorLink.php
Returns the buttons that this plugin provides, along with metadata.

File

src/Plugin/CKEditorPlugin/AnchorLink.php, line 114

Class

AnchorLink
Defines the "link" plugin.

Namespace

Drupal\anchor_link\Plugin\CKEditorPlugin

Code

protected function getLibraryUrl() {
  $originUrl = \Drupal::request()
    ->getSchemeAndHttpHost() . \Drupal::request()
    ->getBaseUrl();
  $librarayPath = DRUPAL_ROOT . '/libraries/link';
  $librarayUrl = $originUrl . '/libraries/link';

  // Is the library found in the root libraries path.
  $libraryFound = file_exists($librarayPath . '/plugin.js');

  // If library is not found, then look in the current profile libraries path.
  if (!$libraryFound) {
    if ($installProfile = \Drupal::installProfile()) {
      $profilePath = drupal_get_path('profile', $installProfile);
      $profilePath .= '/libraries/link';

      // Is the library found in the current profile libraries path.
      if (file_exists(DRUPAL_ROOT . '/' . $profilePath . '/plugin.js')) {
        $libraryFound = TRUE;
        $librarayUrl = $originUrl . '/' . $profilePath;
      }
    }
  }
  if ($libraryFound) {
    return $librarayUrl;
  }
  else {
    return $originUrl . '/libraries/link';
  }
}