Created
May 7, 2020 05:07
-
-
Save back-2-95/fe39495086cdace14d521454451432f7 to your computer and use it in GitHub Desktop.
Drupal Rector with Docker image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --rm -it \ | |
-v /path/to/d8-project/vendor:/app/vendor \ | |
-v /path/to/d8-project/public/core:/app/public/core \ | |
-v /path/to/d8-project/public/profiles:/app/public/profiles \ | |
-v /path/to/d8-project/public/modules/contrib/geshifilter:/app/public/modules/contrib/geshifilter \ | |
druidfi/drupal-rector:latest \ | |
bash -c "rector process /app/public/modules/contrib/geshifilter --dry-run" | |
Rector 0.8.x-dev@8896f0a | |
Config file: rector.yml | |
66/66 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% | |
8 files with changes | |
==================== | |
1) public/modules/contrib/geshifilter/geshifield/src/Plugin/Field/FieldFormatter/GeshiFieldDefaultFormatter.php | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -29,7 +29,7 @@ | |
'#language' => $item->language, | |
'#sourcecode' => $item->sourcecode, | |
]; | |
- $elements[$delta] = ['#markup' => drupal_render($source)]; | |
+ $elements[$delta] = ['#markup' => \Drupal::service('renderer')->render($source)]; | |
} | |
return $elements; | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalRenderRector | |
2) public/modules/contrib/geshifilter/geshifilter.install | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -16,13 +16,13 @@ | |
* Implements hook_install(). | |
*/ | |
function geshifilter_install() { | |
- drupal_set_message(t('GeSHi filter is installed. You should now @configure-geshi | |
+ \Drupal::messenger()->addStatus(t('GeSHi filter is installed. You should now @configure-geshi | |
and enable it in the desired @text-formats.', | |
[ | |
// Geshifilter`s route seems to be unknown at this point, so use | |
// Url::fromUri() with base: scheme instead Url::fromRoute(). | |
- '@configure-geshi' => \Drupal::l(t('configure the GeSHi filter'), Url::fromUri('base:admin/config/content/formats/geshifilter')), | |
- '@text-formats' => \Drupal::l(t('text formats'), Url::fromUri('base:admin/config/content/formats')), | |
+ '@configure-geshi' => \Drupal::service('link_generator')->generate(t('configure the GeSHi filter'), Url::fromUri('base:admin/config/content/formats/geshifilter')), | |
+ '@text-formats' => \Drupal::service('link_generator')->generate(t('text formats'), Url::fromUri('base:admin/config/content/formats')), | |
] | |
)); | |
} | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalLRector | |
* DrupalRector\Rector\Deprecation\DrupalSetMessageRector | |
3) public/modules/contrib/geshifilter/src/Form/GeshiFilterLanguagesForm.php | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -55,7 +55,7 @@ | |
// Check if GeSHi library is available. | |
$geshi_library = GeshiFilter::loadGeshi(); | |
if (!$geshi_library['loaded']) { | |
- drupal_set_message($geshi_library['error message'], 'error'); | |
+ $this->messenger()->addError($geshi_library['error message']); | |
return []; | |
} | |
$add_checkbox = TRUE; | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalSetMessageRector | |
4) public/modules/contrib/geshifilter/src/Form/GeshiFilterSettingsForm.php | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -89,7 +89,7 @@ | |
'#title' => $this->t('Use text format specific tag settings.'), | |
'#default_value' => $config->get('use_format_specific_options', FALSE), | |
'#description' => $this->t('Enable seperate tag settings of the GeSHi filter for each @text-format instead of global tag settings.', [ | |
- '@text-format' => \Drupal::l($this->t('text format'), Url::fromRoute('filter.admin_overview')), | |
+ '@text-format' => \Drupal::service('link_generator')->generate($this->t('text format'), Url::fromRoute('filter.admin_overview')), | |
]), | |
]; | |
// Generic tags settings. | |
@@ -133,7 +133,7 @@ | |
GeshiFilter::LINE_NUMBERS_DEFAULT_FANCY20 => $this->t('fancy line numbers (every @n lines)', ['@n' => GeshiFilter::LINE_NUMBERS_DEFAULT_FANCY20]), | |
], | |
'#description' => $this->t('Select the default line numbering scheme: no line numbers, normal line numbers or fancy line numbers. With fancy line numbers every n<sup>th</sup> line number is highlighted. (GeSHi documentation: @line-numbers).', [ | |
- '@line-numbers' => \Drupal::l($this->t('Line numbers'), Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#line-numbers')), | |
+ '@line-numbers' => \Drupal::service('link_generator')->generate($this->t('Line numbers'), Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#line-numbers')), | |
]), | |
]; | |
@@ -150,7 +150,7 @@ | |
'#type' => 'checkbox', | |
'#title' => $this->t('Use built-in PHP function <code>highlight_string()</code> for PHP source code.'), | |
'#description' => $this->t('When enabled, PHP source code will be syntax highlighted with the built-in PHP function <code>@highlight-string</code> instead of with the GeSHi library. GeSHi features, like line numbering and usage of an external CSS stylesheet for example, are not available.', [ | |
- '@highlight-string' => \Drupal::l('highlight_string()', Url::fromUri('http://php.net/manual/en/function.highlight-string.php')), | |
+ '@highlight-string' => \Drupal::service('link_generator')->generate('highlight_string()', Url::fromUri('http://php.net/manual/en/function.highlight-string.php')), | |
]), | |
'#default_value' => $config->get('use_highlight_string_for_php'), | |
]; | |
@@ -159,7 +159,7 @@ | |
'#type' => 'checkbox', | |
'#title' => $this->t('Enable GeSHi keyword URLs'), | |
'#description' => $this->t('For some languages GeSHi can link language keywords (e.g. standard library functions) to their online documentation. (GeSHi documentation: @keyword-urls).', [ | |
- '@keyword-urls' => \Drupal::l($this->t('Keyword URLs'), Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#keyword-urls')), | |
+ '@keyword-urls' => \Drupal::service('link_generator')->generate($this->t('Keyword URLs'), Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#keyword-urls')), | |
]), | |
'#default_value' => $config->get('enable_keyword_urls'), | |
]; | |
@@ -193,11 +193,9 @@ | |
rules to the pages (e.g. based on @css-defaults). | |
(GeSHi documentation: @css-classes).', | |
[ | |
- '@css-classes' => \Drupal::l($this->t('Using CSS Classes'), | |
- Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#using-css-classes') | |
- ), | |
- '@download-method' => \Drupal::l($this->t('download method'), Url::fromRoute('system.file_system_settings')), | |
- '@css-defaults' => \Drupal::l($this->t('these defaults'), Url::fromRoute('geshifilter.generate_css')), | |
+ '@css-classes' => \Drupal::service('link_generator')->generate($this->t('Using CSS Classes'), Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#using-css-classes')), | |
+ '@download-method' => \Drupal::service('link_generator')->generate($this->t('download method'), Url::fromRoute('system.file_system_settings')), | |
+ '@css-defaults' => \Drupal::service('link_generator')->generate($this->t('these defaults'), Url::fromRoute('geshifilter.generate_css')), | |
] | |
), | |
]; | |
@@ -236,7 +234,7 @@ | |
'#type' => 'radios', | |
'#title' => $this->t('Code container, wrapping technique'), | |
'#description' => $this->t('Define the wrapping technique to use for code blocks. (GeSHi documentation: @code-container).', | |
- ['@code-container' => \Drupal::l($this->t('The Code Container'), Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#the-code-container'))] | |
+ ['@code-container' => \Drupal::service('link_generator')->generate($this->t('The Code Container'), Url::fromUri('http://qbnz.com/highlighter/geshi-doc.html#the-code-container'))] | |
), | |
'#options' => $container_options, | |
'#default_value' => $config->get('code_container'), | |
@@ -304,7 +302,7 @@ | |
} | |
$cache = \Drupal::cache(); | |
$cache->delete('geshifilter_available_languages_cache'); | |
- drupal_set_message($this->t('Flushed the GeSHi language definition cache.')); | |
+ $this->messenger()->addStatus($this->t('Flushed the GeSHi language definition cache.')); | |
} | |
/** | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalLRector | |
* DrupalRector\Rector\Deprecation\DrupalSetMessageRector | |
5) public/modules/contrib/geshifilter/src/GeshiFilter.php | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -86,7 +86,7 @@ | |
const BRACKETS_DOUBLESQUARE = 4; | |
/** | |
- * Parse code with tags inside <?php ?>, example, <?php echo('hi'); ?>. | |
+ * Parse code with tags inside , example, <?php echo('hi'); ?>. | |
*/ | |
const BRACKETS_PHPBLOCK = 8; | |
@@ -242,8 +242,8 @@ | |
$library['loaded'] = FALSE; | |
$library['library path'] = ''; | |
$library['error message'] = t('The GeSHi filter requires the GeSHi library (which needs to be @downloaded and installed seperately). Please review the install instruction at @readme.', [ | |
- '@downloaded' => \Drupal::l(t('downloaded'), Url::fromUri('http://qbnz.com/highlighter/')), | |
- '@readme' => \Drupal::l(t('README.TXT'), Url::fromUri('http://cgit.drupalcode.org/geshifilter/tree/README.txt?h=8.x-1.x')), | |
+ '@downloaded' => \Drupal::service('link_generator')->generate(t('downloaded'), Url::fromUri('http://qbnz.com/highlighter/')), | |
+ '@readme' => \Drupal::service('link_generator')->generate(t('README.TXT'), Url::fromUri('http://cgit.drupalcode.org/geshifilter/tree/README.txt?h=8.x-1.x')), | |
]); | |
} | |
return $library; | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalLRector | |
6) public/modules/contrib/geshifilter/src/GeshiFilterCss.php | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -37,7 +37,7 @@ | |
*/ | |
public static function managedExternalStylesheetPossible() { | |
$directory = self::languageCssPath(TRUE); | |
- return file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); | |
+ return \Drupal::service('file_system')->prepareDirectory($directory, \Drupal\Core\File\FileSystemInterface::CREATE_DIRECTORY | \Drupal\Core\File\FileSystemInterface::MODIFY_PERMISSIONS); | |
} | |
/** | |
@@ -50,7 +50,7 @@ | |
* Full path to css file. | |
*/ | |
public static function languageCssPath($dironly = FALSE) { | |
- $directory = file_default_scheme() . '://geshi'; | |
+ $directory = \Drupal::config('system.file')->get('default_scheme') . '://geshi'; | |
if (!$dironly) { | |
$directory .= '/geshifilter-languages.css'; | |
} | |
@@ -79,7 +79,7 @@ | |
} | |
} | |
else { | |
- drupal_set_message($this->t('Error while generating CSS rules: could not load GeSHi library.'), 'error'); | |
+ \Drupal::messenger()->addError($this->t('Error while generating CSS rules: could not load GeSHi library.')); | |
} | |
return $output; | |
} | |
@@ -102,15 +102,15 @@ | |
// Save stylesheet. | |
$stylesheet_filename = self::languageCssPath(); | |
- $ret = file_save_data($stylesheet, $stylesheet_filename, FILE_EXISTS_REPLACE); | |
+ $ret = file_save_data($stylesheet, $stylesheet_filename, \Drupal\Core\File\FileSystemInterface::EXISTS_REPLACE); | |
if ($ret) { | |
- drupal_set_message(t('(Re)generated external CSS style sheet %file.', ['%file' => $ret->getFilename()])); | |
+ \Drupal::messenger()->addStatus(t('(Re)generated external CSS style sheet %file.', ['%file' => $ret->getFilename()])); | |
} | |
else { | |
- drupal_set_message(t('Could not generate external CSS file. Check the settings of your <a href="!filesystem">file system</a>.', | |
+ \Drupal::messenger()->addError(t('Could not generate external CSS file. Check the settings of your <a href="!filesystem">file system</a>.', | |
[ | |
'!filesystem' => Url::fromRoute('system.file_system_settings')->toString(), | |
- ]), 'error'); | |
+ ])); | |
} | |
// Remember for which list of languages the CSS file was generated. | |
\Drupal::state()->set('cssfile_languages', $languages_hash); | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalSetMessageRector | |
* DrupalRector\Rector\Deprecation\FileCreateDirectoryRector | |
* DrupalRector\Rector\Deprecation\FileDefaultSchemeRector | |
* DrupalRector\Rector\Deprecation\FileExistsReplaceRector | |
* DrupalRector\Rector\Deprecation\FileModifyPermissionsRector | |
* DrupalRector\Rector\Deprecation\FilePrepareDirectoryRector | |
7) public/modules/contrib/geshifilter/src/GeshiFilterProcess.php | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -66,7 +66,7 @@ | |
// Load GeSHi library (if not already). | |
$geshi_library = GeshiFilter::loadGeshi(); | |
if (!$geshi_library['loaded']) { | |
- drupal_set_message($geshi_library['error message'], 'error'); | |
+ \Drupal::messenger()->addError($geshi_library['error message']); | |
return $source_code; | |
} | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalSetMessageRector | |
8) public/modules/contrib/geshifilter/src/Plugin/Filter/GeshiFilterFilter.php | |
---------- begin diff ---------- | |
--- Original | |
+++ New | |
@@ -122,7 +122,7 @@ | |
} | |
catch (\Exception $e) { | |
watchdog_exception('geshifilter', $e); | |
- drupal_set_message($geshi_library['error message'], 'error'); | |
+ $this->messenger()->addError($geshi_library['error message']); | |
} | |
return $result; | |
@@ -220,7 +220,7 @@ | |
$tag_style_examples[] = '<code>' . SafeMarkup::checkPlain('```foo ```') . '</code>'; | |
} | |
if (!$bracket_open) { | |
- drupal_set_message($this->t('Could not determine a valid tag style for GeSHi filtering.'), 'error'); | |
+ $this->messenger()->addError($this->t('Could not determine a valid tag style for GeSHi filtering.')); | |
$bracket_open = SafeMarkup::checkPlain('<'); | |
$bracket_close = SafeMarkup::checkPlain('>'); | |
} | |
----------- end diff ----------- | |
Applied rules: | |
* DrupalRector\Rector\Deprecation\DrupalSetMessageRector | |
[OK] Rector is done! 8 files would have changed (dry-run). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Docker image and some notes:
https://hub.docker.com/repository/docker/druidfi/drupal-rector