You are here

function asset_injector_requirements in Asset Injector 8.2

Same name and namespace in other branches
  1. 8 asset_injector.install \asset_injector_requirements()

Implements hook_requirements().

File

./asset_injector.install, line 13
Contains install and uninstall hooks.

Code

function asset_injector_requirements($phase) {
  $requirements = [];
  $uri = 'public://asset_injector';
  $directory = \Drupal::service('stream_wrapper_manager')
    ->normalizeUri($uri);
  \Drupal::service('file_system')
    ->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
  $requirements['asset_injector'] = [
    'title' => t('Asset Injector'),
    'value' => is_writable($directory) ? t('Directory is writable') : t('Directory not writable'),
    'description' => t('%directory should have write access.', [
      '%directory' => $directory,
    ]),
    'severity' => is_writable($directory) ? REQUIREMENT_OK : REQUIREMENT_ERROR,
  ];
  return $requirements;
}