You are here

function ckeditor_codemirror_requirements in CKEditor CodeMirror 8

Same name and namespace in other branches
  1. 8.2 ckeditor_codemirror.install \ckeditor_codemirror_requirements()
  2. 7 ckeditor_codemirror.install \ckeditor_codemirror_requirements()

Implements hook_requirements().

File

./ckeditor_codemirror.install, line 11
Install, update and uninstall functions for the CKEditor CodeMirror module.

Code

function ckeditor_codemirror_requirements($phase) {
  if ($phase != 'runtime') {
    return FALSE;
  }
  $return = [];

  // If the library is installed.
  $library_path = _ckeditor_codemirror_get_library_path();
  if (file_exists(DRUPAL_ROOT . '/' . $library_path . '/codemirror/plugin.js')) {
    $return['ckeditor_codemirror_library'] = [
      'title' => t('CKEditor CodeMirror'),
      'severity' => REQUIREMENT_OK,
      'value' => t('CKEditor CodeMirror plugin version %version installed at %path.', [
        '%path' => base_path() . $library_path,
        '%version' => _ckeditor_codemirror_get_version(),
      ]),
    ];
  }
  else {
    $return['ckeditor_codemirror_library'] = [
      'title' => t('CKEditor CodeMirror'),
      'severity' => REQUIREMENT_ERROR,
      'value' => t('CKEditor CodeMirror plugin was not found. Download <a href=":link">the latest version of library</a>
        and place it in the libraries directory (/libraries/ckeditor.codemirror).', [
        ':link' => 'https://github.com/w8tcha/CKEditor-CodeMirror-Plugin/releases',
      ]),
    ];
  }
  return $return;
}