Commit 1b27c4b1 authored by git's avatar git Committed by Neslee

Issue #3096958 by mbovan, gooodwill, vsujeetkumar, Suresh Prabhu Parkala:...

Issue #3096958 by mbovan, gooodwill, vsujeetkumar, Suresh Prabhu Parkala: Drupal 9 Deprecated Code Report
parent abb598e3
......@@ -2,7 +2,7 @@ name: 'Colorbox'
type: module
description: 'A light-weight, customizable lightbox plugin for jQuery.'
package: Media
core: 8.x
core_version_requirement: ^8.8 || ^9
configure: colorbox.admin_settings
dependencies:
......
......@@ -11,8 +11,8 @@ use Drupal\Core\Url;
* Implements hook_install().
*/
function colorbox_install() {
drupal_set_message(t('Thanks for installing Colorbox'));
drupal_set_message(t('You may configure Colorbox by visiting <a href="@url_settings">@url_settings</a>', [
\Drupal::messenger()->addMessage(t('Thanks for installing Colorbox'));
\Drupal::messenger()->addMessage(t('You may configure Colorbox by visiting <a href="@url_settings">@url_settings</a>', [
'@url_settings' => Url::fromRoute('colorbox.admin_settings')->toString(),
]));
}
......
......@@ -6,7 +6,6 @@
*/
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Unicode;
use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;
......@@ -85,8 +84,8 @@ function template_preprocess_colorbox_formatter(&$variables) {
$config = \Drupal::config('colorbox.settings');
$colorbox_style = $config->get('colorbox_style');
$trim_length = $config->get('colorbox_caption_trim_length');
if (((strpos($colorbox_style, 'colorbox/example') !== FALSE) || $config->get('colorbox_caption_trim')) && (Unicode::strlen($caption) > $trim_length)) {
$caption = Unicode::substr($caption, 0, $trim_length - 5) . '...';
if (((strpos($colorbox_style, 'colorbox/example') !== FALSE) || $config->get('colorbox_caption_trim')) && (mb_strlen($caption) > $trim_length)) {
$caption = mb_substr($caption, 0, $trim_length - 5) . '...';
}
// Build the gallery id.
......@@ -153,7 +152,7 @@ function template_preprocess_colorbox_formatter(&$variables) {
$variables['image']['#attributes'] = $item_attributes;
// Do not output an empty 'title' attribute.
if (Unicode::strlen($item->title) != 0) {
if (mb_strlen($item->title) != 0) {
$variables['image']['#title'] = $item->title;
$data_cbox_img_attrs['title'] = '"title":"' . $item->title . '"';
}
......
<?php
use Symfony\Component\Filesystem\Filesystem;
/**
* @file
* Drush integration for colorbox.
......@@ -60,7 +61,7 @@ function drush_colorbox_plugin() {
// Create the path if it does not exist.
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', ['@path' => $path]), 'notice');
\Drupal::logger(dt('Directory @path was created', ['@path' => $path]))->notice('notice');
}
// Set the directory to the download location.
......@@ -74,9 +75,9 @@ function drush_colorbox_plugin() {
// Remove any existing Colorbox plugin directory.
if (is_dir($dirname) || is_dir('colorbox')) {
drush_delete_dir($dirname, TRUE);
drush_delete_dir('colorbox', TRUE);
drush_log(dt('A existing Colorbox plugin was deleted from @path', ['@path' => $path]), 'notice');
Filesystem::remove($dirname, TRUE);
Filesystem::remove('colorbox', TRUE);
\Drupal::logger(dt('A existing Colorbox plugin was deleted from @path', ['@path' => $path]))->notice('notice');
}
// Decompress the zip archive.
......@@ -90,10 +91,10 @@ function drush_colorbox_plugin() {
}
if (is_dir($dirname)) {
drush_log(dt('Colorbox plugin has been installed in @path', ['@path' => $path]), 'success');
\Drupal::logger(dt('Colorbox plugin has been installed in @path', ['@path' => $path]))->success('success');
}
else {
drush_log(dt('Drush was unable to install the Colorbox plugin to @path', ['@path' => $path]), 'error');
\Drupal::logger(dt('Drush was unable to install the Colorbox plugin to @path', ['@path' => $path]))->error('error');
}
// Set working directory back to the previous working directory.
......
......@@ -4,6 +4,7 @@ namespace Drupal\colorbox;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
......@@ -47,7 +48,7 @@ class ColorboxAttachment implements ElementAttachmentInterface {
* {@inheritdoc}
*/
public function isApplicable() {
return !drupal_installation_attempted() && $this->activation->isActive();
return !InstallerKernel::installationAttempted() && $this->activation->isActive();
}
/**
......
......@@ -99,7 +99,7 @@ class ColorboxFormatter extends ImageFormatterBase implements ContainerFactoryPl
$configuration['view_mode'],
$configuration['third_party_settings'],
$container->get('current_user'),
$container->get('entity.manager')->getStorage('image_style'),
$container->get('entity_type.manager')->getStorage('image_style'),
$container->get('colorbox.attachment'),
$container->get('module_handler')
);
......
......@@ -3,4 +3,4 @@ description: Ensure colorbox can be tested properly with the downloaded library.
type: module
hidden: true
package: Testing
core: 8.x
core_version_requirement: ^8.8 || ^9
......@@ -5,6 +5,7 @@
* Install file for the colorbox library test module.
*/
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Site\Settings;
/**
......@@ -17,7 +18,7 @@ function colorbox_library_test_install() {
if (file_exists($colorbox_folder)) {
return;
}
file_prepare_directory($library_folder, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY);
\Drupal::service('file_system')->prepareDirectory($library_folder, FileSystemInterface::MODIFY_PERMISSIONS | FileSystemInterface::CREATE_DIRECTORY);
copy('https://github.com/jackmoore/colorbox/archive/master.zip', $zip_file);
$zip = new \ZipArchive();
$zip->open($zip_file);
......
......@@ -19,6 +19,13 @@ class ColorboxJavascriptTest extends WebDriverTestBase {
use NodeCreationTrait;
use ContentTypeCreationTrait;
/**
* Theme to use.
*
* @var string
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
......@@ -158,7 +165,7 @@ class ColorboxJavascriptTest extends WebDriverTestBase {
'settings' => [],
])
->save();
file_unmanaged_copy(DRUPAL_ROOT . '/core/modules/simpletest/files/image-1.png', 'public://test.png');
\Drupal::service('file_system')->copy(__DIR__ . '/../../../images/admin/colorbox_example_1.png', 'public://test.png');
$file_a = File::create([
'uri' => 'public://test.png',
'filename' => 'test.png',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment