Commit 90c60322 authored by Joshua Sedler's avatar Joshua Sedler 🤸🏼 Committed by Julian Pustkuchen
Browse files

Issue #3269506 by Grevil, Anybody: Fix composer require failure due to npm-asset

parent d1d5be4c
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Install, update and uninstall functions for the drowl_paragraphs module.
 */

use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Entity\Sql\SqlContentEntityStorageException;

/**
 * Implements hook_requirements().
 */
function drowl_paragraphs_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $requirements = [];

  $rellaxLibrary = \Drupal::service('library.discovery')->getLibraryByName('drowl_paragraphs', 'parallax');
  $vergeLibrary = \Drupal::service('library.discovery')->getLibraryByName('drowl_paragraphs', 'global');
  $drowlAdminIconsetLibrary = \Drupal::service('library.discovery')->getLibraryByName('drowl_paragraphs', 'admin_iconset');

  if (empty($rellaxLibrary) || empty($vergeLibrary) || empty($drowlAdminIconsetLibrary)) {
    throw new Exception("Required libraries for the drowl_paragraphs module are not defined in the appropriate libraries.yml file.");
  }

  $rellaxLibraryExist = file_exists(DRUPAL_ROOT . '/' . $rellaxLibrary['js'][0]['data']);
  $vergeLibraryExist = file_exists(DRUPAL_ROOT . '/' . $vergeLibrary['js'][0]['data']);
  $drowlAdminIconseExist = file_exists(DRUPAL_ROOT . '/' . $drowlAdminIconsetLibrary['css'][0]['data']);

  $requirements['rellax'] = [
    'title' => t('Drowl Paragraphs: Missing Rellax library'),
    'value' => $rellaxLibraryExist ? t('Installed') : t('Not installed'),
    'description' => $rellaxLibraryExist ? '' : t('To use the drowl_paragraphs module, the rellax library needs to be required via composer, using "composer require npm-asset/rellax". NOTE, that you need set up the "asset-packagist" repository in your projects composer.json file.<br>See <a href="https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies#third-party-libraries">here</a> on how to do it.'),
    'severity' => $rellaxLibraryExist ? REQUIREMENT_OK : REQUIREMENT_ERROR,
  ];
  $requirements['verge'] = [
    'title' => t('Drowl Paragraphs: Missing Verge library'),
    'value' => $vergeLibraryExist ? t('Installed') : t('Not installed'),
    'description' => $vergeLibraryExist ? '' : t('To use the drowl_paragraphs module, the verge library needs to be required via composer, using "composer require npm-asset/rellax". NOTE, that you need to set up the "asset-packagist" repository in your projects composer.json file.<br>See <a href="https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies#third-party-libraries">here</a> on how to do it.'),
    'severity' => $vergeLibraryExist ? REQUIREMENT_OK : REQUIREMENT_ERROR,
  ];
  $requirements['drowl_admin_iconset'] = [
    'title' => t('Drowl Paragraphs: Missing Drowl Admin Iconset library'),
    'value' => $drowlAdminIconseExist ? t('Installed') : t('Not installed'),
    'description' => $drowlAdminIconseExist ? '' : t('To use the drowl_paragraphs module, the drowl admin iconset library needs to be required via composer, using "composer require npm-asset/drowl-admin-iconset". NOTE, that you need to set up the "asset-packagist" repository in your projects composer.json file.<br>See <a href="https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies#third-party-libraries">here</a> on how to do it.'),
    'severity' => $drowlAdminIconseExist ? REQUIREMENT_OK : REQUIREMENT_ERROR,
  ];
  return $requirements;
}

/**
 * Add further columns: style_textalign, style_textcolumns
 */
+3 −1
Original line number Diff line number Diff line
@@ -11,7 +11,9 @@
    "source": "http://cgit.drupalcode.org/drowl_paragraphs"
  },
  "require": {
    "drupal/drowl_paragraphs": "^4.0",
    "drupal/drowl_paragraphs": "^4.0"
  },
  "suggest": {
    "npm-asset/flipdown": ">=0.3"
  }
}
+3 −1
Original line number Diff line number Diff line
@@ -11,7 +11,9 @@
    "source": "http://cgit.drupalcode.org/drowl_paragraphs"
  },
  "require": {
    "drupal/drowl_paragraphs": "^4.0",
    "drupal/drowl_paragraphs": "^4.0"
  },
  "suggest": {
    "npm-asset/progressbar.js": ">=1"
  }
}