Skip to content
Snippets Groups Projects
Commit c447a9a9 authored by Andrii Podanenko's avatar Andrii Podanenko Committed by Joseph Olstad
Browse files

Issue #3119010 by podarok, xeM8VfDh, douggreen, Suresh Prabhu Parkala,...

Issue #3119010 by podarok, xeM8VfDh, douggreen, Suresh Prabhu Parkala, boromino, jungle, aspilicious, sajid_007, GaëlG, podarok, devdesagar, FatGuyLaughing, Anybody, Raunak.singh, berramou, drupgirl, fgm, joseph.olstad, dksdev01: Drupal 9 Deprecated Code Report
parent 3b7ae61a
No related branches found
No related tags found
No related merge requests found
......@@ -62,8 +62,8 @@ function libraries_drush_invalidate_cache() {
*/
function libraries_drush_list() {
$libraries = array();
foreach (libraries_info() as $name => $info) {
$libraries[$name] = libraries_detect($name);
foreach (\Drupal::service('libraries.manager')->info() as $name => $info) {
$libraries[$name] = \Drupal::service('libraries.manager')->getLibrary($name);
}
ksort($libraries);
......
......@@ -2,3 +2,4 @@ name: Libraries
type: module
description: Allows version-dependent and shared usage of external libraries.
core: 8.x
core_version_requirement: ^8 || ^9
......@@ -23,6 +23,6 @@ function libraries_install() {
*/
function libraries_uninstall() {
if (is_dir('public://library-definitions')) {
file_unmanaged_delete_recursive('public://library-definitions');
\Drupal::service('file_system')->deleteRecursive('public://library-definitions');
}
}
......@@ -11,6 +11,7 @@ use Drupal\libraries\ExternalLibrary\Asset\AttachableAssetLibraryRegistrationInt
use Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorInterface;
use Drupal\libraries\ExternalLibrary\Utility\LibraryIdAccessorInterface;
use Symfony\Component\Yaml\Parser;
use Drupal\Core\Extension\Dependency;
/**
* Implements hook_library_info_build().
......@@ -115,7 +116,7 @@ function libraries_get_libraries() {
// Similar to 'modules' and 'themes' directories inside an installation
// profile, installation profiles may want to place libraries into a
// 'libraries' directory.
if ($profile = drupal_get_profile()) {
if ($profile = \Drupal::installProfile()) {
$profile_path = drupal_get_path('profile', $profile);
$searchdir[] = "$profile_path/libraries";
};
......@@ -167,7 +168,7 @@ function libraries_get_libraries() {
* https://www.drupal.org/node/2170763
*/
function libraries_scan_info_files() {
$profile = drupal_get_path('profile', drupal_get_profile());
$profile = \Drupal\Core\Extension\ExtensionList::getPath('profile', \Drupal::installProfile());
$config = DrupalKernel::findSitePath(\Drupal::request());
// Build a list of directories.
......@@ -345,9 +346,9 @@ function libraries_prepare_files(&$library, $version = NULL, $variant = NULL) {
function libraries_detect_dependencies(&$library, $version = NULL, $variant = NULL) {
if (isset($library['dependencies'])) {
foreach ($library['dependencies'] as &$dependency_string) {
$dependency_info = ModuleHandler::parseDependency($dependency_string);
$dependency = libraries_detect($dependency_info['name']);
if (!$dependency['installed']) {
$dependency = Dependency::createFromString($dependency_string);
$info = libraries_detect($dependency->getName());
if (!$info['installed']) {
$library['installed'] = FALSE;
$library['error'] = 'missing dependency';
$library['error message'] = t('The %dependency library, which the %library library depends on, is not installed.', array(
......@@ -355,12 +356,12 @@ function libraries_detect_dependencies(&$library, $version = NULL, $variant = NU
'%library' => $library['name'],
));
}
elseif (drupal_check_incompatibility($dependency_info, $dependency['version'])) {
elseif (!$dependency->isCompatible($info['version'])) {
$library['installed'] = FALSE;
$library['error'] = 'incompatible dependency';
$library['error message'] = t('The version %dependency_version of the %dependency library is not compatible with the %library library.', array(
'%dependency_version' => $dependency['version'],
'%dependency' => $dependency['name'],
'%dependency_version' => $info['version'],
'%dependency' => $info['name'],
'%library' => $library['name'],
));
}
......
......@@ -61,7 +61,9 @@ class LibraryManager implements LibraryManagerInterface {
public function getRequiredLibraryIds() {
$library_ids = [];
foreach (['module', 'theme'] as $type) {
foreach (system_get_info($type) as $info) {
$service_id = 'extension.list.' . $type;
$extension_list = \Drupal::service($service_id);
foreach ($extension_list->getAllInstalledInfo() as $info) {
if (isset($info['library_dependencies'])) {
$library_ids = array_merge($library_ids, $info['library_dependencies']);
}
......
......@@ -6,6 +6,7 @@
*/
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Messenger\MessengerTrait;
/**
* Implements hook_libraries_info().
......@@ -461,7 +462,7 @@ function _libraries_test_callback(&$library, $version, $variant, $group) {
// Only set the message for the top-level library to prevent confusing,
// duplicate messages.
if (!isset($version) && !isset($variant) && \Drupal::state()->get('libraries_test.cache', FALSE)) {
drupal_set_message(SafeMarkup::set("The <em>$group</em> callback group was invoked."));
\Drupal::messenger()->addMessage(SafeMarkup::set("The <em>$group</em> callback group was invoked."));
}
}
......
......@@ -23,7 +23,7 @@ class ExampleController implements ContainerInjectionInterface {
* more information.
*/
private function buildPage($library, $variant = NULL) {
libraries_load($library, $variant);
\Drupal::service('libraries.manager')->load($library, $variant);
// JavaScript and CSS files can be checked directly by SimpleTest, so we only
// need to manually check for PHP files.
$output = '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment