Issue #3425419 by andypost, smustgrave: [11.x] Remove deprecated code from system module
parent
2ab774d6b8
commit
ad62036ad4
|
@ -483,11 +483,6 @@ function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
|
|||
* unit tests with a clean environment.
|
||||
*/
|
||||
function drupal_static_reset($name = NULL) {
|
||||
switch ($name) {
|
||||
case 'system_get_module_admin_tasks':
|
||||
@trigger_error("Calling " . __FUNCTION__ . "() with 'system_get_module_admin_tasks' as an argument is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3038972", E_USER_DEPRECATED);
|
||||
break;
|
||||
}
|
||||
drupal_static($name, NULL, TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\Asset;
|
||||
|
||||
@trigger_error('The ' . __NAMESPACE__ . '\CssCollectionOptimizer is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Instead, use ' . __NAMESPACE__ . '\CssCollectionOptimizerLazy. See https://www.drupal.org/node/2888767', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Core\File\FileSystemInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
|
||||
/**
|
||||
* Optimizes CSS assets.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Instead, use
|
||||
* \Drupal\Core\Asset\CssCollectionOptimizerLazy.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2888767
|
||||
*/
|
||||
class CssCollectionOptimizer implements AssetCollectionOptimizerInterface {
|
||||
|
||||
/**
|
||||
* A CSS asset grouper.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\CssCollectionGrouper
|
||||
*/
|
||||
protected $grouper;
|
||||
|
||||
/**
|
||||
* A CSS asset optimizer.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\CssOptimizer
|
||||
*/
|
||||
protected $optimizer;
|
||||
|
||||
/**
|
||||
* An asset dumper.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\AssetDumper
|
||||
*/
|
||||
protected $dumper;
|
||||
|
||||
/**
|
||||
* The state key/value store.
|
||||
*
|
||||
* @var \Drupal\Core\State\StateInterface
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The file system service.
|
||||
*
|
||||
* @var \Drupal\Core\File\FileSystemInterface
|
||||
*/
|
||||
protected $fileSystem;
|
||||
|
||||
/**
|
||||
* Constructs a CssCollectionOptimizer.
|
||||
*
|
||||
* @param \Drupal\Core\Asset\AssetCollectionGrouperInterface $grouper
|
||||
* The grouper for CSS assets.
|
||||
* @param \Drupal\Core\Asset\AssetOptimizerInterface $optimizer
|
||||
* The optimizer for a single CSS asset.
|
||||
* @param \Drupal\Core\Asset\AssetDumperInterface $dumper
|
||||
* The dumper for optimized CSS assets.
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
* The state key/value store.
|
||||
* @param \Drupal\Core\File\FileSystemInterface $file_system
|
||||
* The file system service.
|
||||
*/
|
||||
public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state, FileSystemInterface $file_system) {
|
||||
$this->grouper = $grouper;
|
||||
$this->optimizer = $optimizer;
|
||||
$this->dumper = $dumper;
|
||||
$this->state = $state;
|
||||
$this->fileSystem = $file_system;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* The cache file name is retrieved on a page load via a lookup variable that
|
||||
* contains an associative array. The array key is the hash of the file names
|
||||
* in $css while the value is the cache file name. The cache file is generated
|
||||
* in two cases. First, if there is no file name value for the key, which will
|
||||
* happen if a new file name has been added to $css or after the lookup
|
||||
* variable is emptied to force a rebuild of the cache. Second, the cache file
|
||||
* is generated if it is missing on disk. Old cache files are not deleted
|
||||
* immediately when the lookup variable is emptied, but are deleted after a
|
||||
* configurable period (@code system.performance.stale_file_threshold @endcode)
|
||||
* to ensure that files referenced by a cached page will still be available.
|
||||
*/
|
||||
public function optimize(array $css_assets, array $libraries) {
|
||||
// Group the assets.
|
||||
$css_groups = $this->grouper->group($css_assets);
|
||||
|
||||
// Now optimize (concatenate + minify) and dump each asset group, unless
|
||||
// that was already done, in which case it should appear in
|
||||
// drupal_css_cache_files.
|
||||
// Drupal contrib can override this default CSS aggregator to keep the same
|
||||
// grouping, optimizing and dumping, but change the strategy that is used to
|
||||
// determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …).
|
||||
$map = $this->state->get('drupal_css_cache_files', []);
|
||||
$css_assets = [];
|
||||
foreach ($css_groups as $order => $css_group) {
|
||||
// We have to return a single asset, not a group of assets. It is now up
|
||||
// to one of the pieces of code in the switch statement below to set the
|
||||
// 'data' property to the appropriate value.
|
||||
$css_assets[$order] = $css_group;
|
||||
unset($css_assets[$order]['items']);
|
||||
|
||||
switch ($css_group['type']) {
|
||||
case 'file':
|
||||
// No preprocessing, single CSS asset: just use the existing URI.
|
||||
if (!$css_group['preprocess']) {
|
||||
$uri = $css_group['items'][0]['data'];
|
||||
$css_assets[$order]['data'] = $uri;
|
||||
}
|
||||
// Preprocess (aggregate), unless the aggregate file already exists.
|
||||
else {
|
||||
$key = $this->generateHash($css_group);
|
||||
$uri = '';
|
||||
if (isset($map[$key])) {
|
||||
$uri = $map[$key];
|
||||
}
|
||||
if (empty($uri) || !file_exists($uri)) {
|
||||
// Optimize each asset within the group.
|
||||
$data = '';
|
||||
$current_license = FALSE;
|
||||
foreach ($css_group['items'] as $css_asset) {
|
||||
// Ensure license information is available as a comment after
|
||||
// optimization.
|
||||
if ($css_asset['license'] !== $current_license) {
|
||||
$data .= "/* @license " . $css_asset['license']['name'] . " " . $css_asset['license']['url'] . " */\n";
|
||||
}
|
||||
$current_license = $css_asset['license'];
|
||||
$data .= $this->optimizer->optimize($css_asset);
|
||||
}
|
||||
// Per the W3C specification at
|
||||
// http://www.w3.org/TR/REC-CSS2/cascade.html#at-import, @import
|
||||
// rules must precede any other style, so we move those to the
|
||||
// top. The regular expression is expressed in NOWDOC since it is
|
||||
// detecting backslashes as well as single and double quotes. It
|
||||
// is difficult to read when represented as a quoted string.
|
||||
$regexp = <<<'REGEXP'
|
||||
/@import\s*(?:'(?:\\'|.)*'|"(?:\\"|.)*"|url\(\s*(?:\\[\)\'\"]|[^'")])*\s*\)|url\(\s*'(?:\'|.)*'\s*\)|url\(\s*"(?:\"|.)*"\s*\)).*;/iU
|
||||
REGEXP;
|
||||
preg_match_all($regexp, $data, $matches);
|
||||
$data = preg_replace($regexp, '', $data);
|
||||
$data = implode('', $matches[0]) . (!empty($matches[0]) ? "\n" : '') . $data;
|
||||
// Dump the optimized CSS for this group into an aggregate file.
|
||||
$uri = $this->dumper->dump($data, 'css');
|
||||
// Set the URI for this group's aggregate file.
|
||||
$css_assets[$order]['data'] = $uri;
|
||||
// Persist the URI for this aggregate file.
|
||||
$map[$key] = $uri;
|
||||
$this->state->set('drupal_css_cache_files', $map);
|
||||
}
|
||||
else {
|
||||
// Use the persisted URI for the optimized CSS file.
|
||||
$css_assets[$order]['data'] = $uri;
|
||||
}
|
||||
$css_assets[$order]['preprocessed'] = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'external':
|
||||
// We don't do any aggregation and hence also no caching for external
|
||||
// CSS assets.
|
||||
$uri = $css_group['items'][0]['data'];
|
||||
$css_assets[$order]['data'] = $uri;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $css_assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a hash for a given group of CSS assets.
|
||||
*
|
||||
* @param array $css_group
|
||||
* A group of CSS assets.
|
||||
*
|
||||
* @return string
|
||||
* A hash to uniquely identify the given group of CSS assets.
|
||||
*/
|
||||
protected function generateHash(array $css_group) {
|
||||
$css_data = [];
|
||||
foreach ($css_group['items'] as $css_file) {
|
||||
$css_data[] = $css_file['data'];
|
||||
}
|
||||
return hash('sha256', serialize($css_data));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAll() {
|
||||
return $this->state->get('drupal_css_cache_files');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteAll() {
|
||||
$this->state->delete('drupal_css_cache_files');
|
||||
|
||||
$delete_stale = function ($uri) {
|
||||
// Default stale file threshold is 30 days.
|
||||
if (\Drupal::time()->getRequestTime() - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
|
||||
$this->fileSystem->delete($uri);
|
||||
}
|
||||
};
|
||||
if (is_dir('assets://css')) {
|
||||
$this->fileSystem->scanDirectory('assets://css', '/.*/', ['callback' => $delete_stale]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Core\Asset;
|
||||
|
||||
@trigger_error('The ' . __NAMESPACE__ . '\JsCollectionOptimizer is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. Instead, use ' . __NAMESPACE__ . '\JsCollectionOptimizerLazy. See https://www.drupal.org/node/2888767', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Core\File\FileSystemInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
|
||||
/**
|
||||
* Optimizes JavaScript assets.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Instead use
|
||||
* \Drupal\Core\Asset\JsCollectionOptimizerLazy.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2888767
|
||||
*/
|
||||
class JsCollectionOptimizer implements AssetCollectionOptimizerInterface {
|
||||
|
||||
/**
|
||||
* A JS asset grouper.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\JsCollectionGrouper
|
||||
*/
|
||||
protected $grouper;
|
||||
|
||||
/**
|
||||
* A JS asset optimizer.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\JsOptimizer
|
||||
*/
|
||||
protected $optimizer;
|
||||
|
||||
/**
|
||||
* An asset dumper.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\AssetDumper
|
||||
*/
|
||||
protected $dumper;
|
||||
|
||||
/**
|
||||
* The state key/value store.
|
||||
*
|
||||
* @var \Drupal\Core\State\StateInterface
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The file system service.
|
||||
*
|
||||
* @var \Drupal\Core\File\FileSystemInterface
|
||||
*/
|
||||
protected $fileSystem;
|
||||
|
||||
/**
|
||||
* Constructs a JsCollectionOptimizer.
|
||||
*
|
||||
* @param \Drupal\Core\Asset\AssetCollectionGrouperInterface $grouper
|
||||
* The grouper for JS assets.
|
||||
* @param \Drupal\Core\Asset\AssetOptimizerInterface $optimizer
|
||||
* The optimizer for a single JS asset.
|
||||
* @param \Drupal\Core\Asset\AssetDumperInterface $dumper
|
||||
* The dumper for optimized JS assets.
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
* The state key/value store.
|
||||
* @param \Drupal\Core\File\FileSystemInterface $file_system
|
||||
* The file system service.
|
||||
*/
|
||||
public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state, FileSystemInterface $file_system) {
|
||||
$this->grouper = $grouper;
|
||||
$this->optimizer = $optimizer;
|
||||
$this->dumper = $dumper;
|
||||
$this->state = $state;
|
||||
$this->fileSystem = $file_system;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* The cache file name is retrieved on a page load via a lookup variable that
|
||||
* contains an associative array. The array key is the hash of the names in
|
||||
* $files while the value is the cache file name. The cache file is generated
|
||||
* in two cases. First, if there is no file name value for the key, which will
|
||||
* happen if a new file name has been added to $files or after the lookup
|
||||
* variable is emptied to force a rebuild of the cache. Second, the cache file
|
||||
* is generated if it is missing on disk. Old cache files are not deleted
|
||||
* immediately when the lookup variable is emptied, but are deleted after a
|
||||
* configurable period (@code system.performance.stale_file_threshold @endcode)
|
||||
* to ensure that files referenced by a cached page will still be available.
|
||||
*/
|
||||
public function optimize(array $js_assets, array $libraries) {
|
||||
// Group the assets.
|
||||
$js_groups = $this->grouper->group($js_assets);
|
||||
|
||||
// Now optimize (concatenate, not minify) and dump each asset group, unless
|
||||
// that was already done, in which case it should appear in
|
||||
// system.js_cache_files.
|
||||
// Drupal contrib can override this default JS aggregator to keep the same
|
||||
// grouping, optimizing and dumping, but change the strategy that is used to
|
||||
// determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …).
|
||||
$map = $this->state->get('system.js_cache_files', []);
|
||||
$js_assets = [];
|
||||
foreach ($js_groups as $order => $js_group) {
|
||||
// We have to return a single asset, not a group of assets. It is now up
|
||||
// to one of the pieces of code in the switch statement below to set the
|
||||
// 'data' property to the appropriate value.
|
||||
$js_assets[$order] = $js_group;
|
||||
unset($js_assets[$order]['items']);
|
||||
|
||||
switch ($js_group['type']) {
|
||||
case 'file':
|
||||
// No preprocessing, single JS asset: just use the existing URI.
|
||||
if (!$js_group['preprocess']) {
|
||||
$uri = $js_group['items'][0]['data'];
|
||||
$js_assets[$order]['data'] = $uri;
|
||||
}
|
||||
// Preprocess (aggregate), unless the aggregate file already exists.
|
||||
else {
|
||||
$key = $this->generateHash($js_group);
|
||||
$uri = '';
|
||||
if (isset($map[$key])) {
|
||||
$uri = $map[$key];
|
||||
}
|
||||
if (empty($uri) || !file_exists($uri)) {
|
||||
// Concatenate each asset within the group.
|
||||
$data = '';
|
||||
$current_license = FALSE;
|
||||
foreach ($js_group['items'] as $js_asset) {
|
||||
// Ensure license information is available as a comment after
|
||||
// optimization.
|
||||
if ($js_asset['license'] !== $current_license) {
|
||||
$data .= "/* @license " . $js_asset['license']['name'] . " " . $js_asset['license']['url'] . " */\n";
|
||||
}
|
||||
$current_license = $js_asset['license'];
|
||||
// Optimize this JS file, but only if it's not yet minified.
|
||||
if (isset($js_asset['minified']) && $js_asset['minified']) {
|
||||
$data .= file_get_contents($js_asset['data']);
|
||||
}
|
||||
else {
|
||||
$data .= $this->optimizer->optimize($js_asset);
|
||||
}
|
||||
// Append a ';' and a newline after each JS file to prevent them
|
||||
// from running together.
|
||||
$data .= ";\n";
|
||||
}
|
||||
// Remove unwanted JS code that cause issues.
|
||||
$data = $this->optimizer->clean($data);
|
||||
// Dump the optimized JS for this group into an aggregate file.
|
||||
$uri = $this->dumper->dump($data, 'js');
|
||||
// Set the URI for this group's aggregate file.
|
||||
$js_assets[$order]['data'] = $uri;
|
||||
// Persist the URI for this aggregate file.
|
||||
$map[$key] = $uri;
|
||||
$this->state->set('system.js_cache_files', $map);
|
||||
}
|
||||
else {
|
||||
// Use the persisted URI for the optimized JS file.
|
||||
$js_assets[$order]['data'] = $uri;
|
||||
}
|
||||
$js_assets[$order]['preprocessed'] = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'external':
|
||||
// We don't do any aggregation and hence also no caching for external
|
||||
// JS assets.
|
||||
$uri = $js_group['items'][0]['data'];
|
||||
$js_assets[$order]['data'] = $uri;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $js_assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a hash for a given group of JavaScript assets.
|
||||
*
|
||||
* @param array $js_group
|
||||
* A group of JavaScript assets.
|
||||
*
|
||||
* @return string
|
||||
* A hash to uniquely identify the given group of JavaScript assets.
|
||||
*/
|
||||
protected function generateHash(array $js_group) {
|
||||
$js_data = [];
|
||||
foreach ($js_group['items'] as $js_file) {
|
||||
$js_data[] = $js_file['data'];
|
||||
}
|
||||
return hash('sha256', serialize($js_data));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAll() {
|
||||
return $this->state->get('system.js_cache_files');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteAll() {
|
||||
$this->state->delete('system.js_cache_files');
|
||||
$delete_stale = function ($uri) {
|
||||
// Default stale file threshold is 30 days.
|
||||
if (\Drupal::time()->getRequestTime() - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
|
||||
$this->fileSystem->delete($uri);
|
||||
}
|
||||
};
|
||||
if (is_dir('assets://js')) {
|
||||
$this->fileSystem->scanDirectory('assets://js', '/.*/', ['callback' => $delete_stale]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -248,9 +248,6 @@ trait BlockPluginTrait {
|
|||
$definition = $this->getPluginDefinition();
|
||||
$admin_label = $definition['admin_label'];
|
||||
|
||||
// @todo This is basically the same as what is done in
|
||||
// \Drupal\system\MachineNameController::transliterate(), so it might make
|
||||
// sense to provide a common service for the two.
|
||||
$transliterated = $this->transliteration()->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_');
|
||||
$transliterated = mb_strtolower($transliterated);
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ use Drupal\Core\Breadcrumb\Breadcrumb;
|
|||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldFormatter\TimestampFormatter;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Core\Render\Element;
|
||||
|
@ -18,7 +17,6 @@ use Drupal\Core\Url;
|
|||
use Drupal\field\FieldConfigInterface;
|
||||
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
|
||||
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage;
|
||||
use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface;
|
||||
use Drupal\layout_builder\Form\DefaultsEntityForm;
|
||||
use Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm;
|
||||
use Drupal\layout_builder\Form\OverridesEntityForm;
|
||||
|
@ -414,44 +412,3 @@ function layout_builder_theme_suggestions_field_alter(&$suggestions, array $vari
|
|||
}
|
||||
return $suggestions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for entity_view_display entities.
|
||||
*
|
||||
* Provides a BC layer for modules providing old configurations.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2993639
|
||||
*
|
||||
* @todo Remove this BC layer in drupal:11.0.0.
|
||||
*/
|
||||
function layout_builder_entity_view_display_presave(EntityViewDisplayInterface $entity_view_display): void {
|
||||
if (!$entity_view_display instanceof LayoutEntityDisplayInterface || !$entity_view_display->isLayoutBuilderEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Drupal\Core\Field\FormatterPluginManager $field_formatter_manager */
|
||||
$field_formatter_manager = \Drupal::service('plugin.manager.field.formatter');
|
||||
|
||||
foreach ($entity_view_display->getSections() as $section) {
|
||||
foreach ($section->getComponents() as $component) {
|
||||
if (str_starts_with($component->getPluginId(), 'field_block:')) {
|
||||
$configuration = $component->get('configuration');
|
||||
$formatter =& $configuration['formatter'];
|
||||
if ($formatter && isset($formatter['type'])) {
|
||||
$plugin_definition = $field_formatter_manager->getDefinition($formatter['type'], FALSE);
|
||||
// Check also potential plugins extending TimestampFormatter.
|
||||
if (!$plugin_definition || !is_a($plugin_definition['class'], TimestampFormatter::class, TRUE)) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($formatter['settings']['tooltip']) || !isset($formatter['settings']['time_diff'])) {
|
||||
@trigger_error("Using the 'timestamp' formatter plugin without the 'tooltip' and 'time_diff' settings is deprecated in drupal:10.1.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/2993639", E_USER_DEPRECATED);
|
||||
$formatter['settings'] += $plugin_definition['class']::defaultSettings();
|
||||
// Existing timestamp formatters don't have tooltip.
|
||||
$formatter['settings']['tooltip']['date_format'] = '';
|
||||
$component->set('configuration', $configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,6 @@ class MediaSourceImageTest extends MediaSourceTestBase {
|
|||
'administer media types',
|
||||
'administer media display',
|
||||
'view media',
|
||||
// We need 'access content' for system.machine_name_transliterate.
|
||||
'access content',
|
||||
]));
|
||||
|
||||
$page = $this->getSession()->getPage();
|
||||
|
@ -126,8 +124,6 @@ class MediaSourceImageTest extends MediaSourceTestBase {
|
|||
'administer media',
|
||||
'administer media types',
|
||||
'view media',
|
||||
// We need 'access content' for system.machine_name_transliterate.
|
||||
'access content',
|
||||
]));
|
||||
// Test that hook_requirements adds warning about the lack of an image
|
||||
// style.
|
||||
|
|
|
@ -182,10 +182,6 @@ system.performance:
|
|||
gzip:
|
||||
type: boolean
|
||||
label: 'Compress JavaScript files.'
|
||||
stale_file_threshold:
|
||||
type: integer
|
||||
label: 'Stale file threshold'
|
||||
deprecated: 'The system.performance.stale_file_threshold config key is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3301744'
|
||||
|
||||
system.rss:
|
||||
type: config_object
|
||||
|
|
|
@ -6,67 +6,20 @@ use Drupal\Core\Controller\ControllerBase;
|
|||
use Drupal\Core\Extension\ModuleExtensionList;
|
||||
use Drupal\system\ModuleAdminLinksHelper;
|
||||
use Drupal\user\ModulePermissionsLinkHelper;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Controller for admin section.
|
||||
*/
|
||||
class AdminController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* The module extension list.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleExtensionList
|
||||
*/
|
||||
protected $moduleExtensionList;
|
||||
|
||||
/**
|
||||
* The module admin links service.
|
||||
*
|
||||
* @var \Drupal\system\ModuleAdminLinksHelper
|
||||
*/
|
||||
protected ModuleAdminLinksHelper $moduleAdminLinks;
|
||||
|
||||
/**
|
||||
* The module permissions link service.
|
||||
*
|
||||
* @var \Drupal\user\ModulePermissionsLinkHelper
|
||||
*/
|
||||
protected ModulePermissionsLinkHelper $modulePermissionsLinks;
|
||||
|
||||
/**
|
||||
* AdminController constructor.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
|
||||
* The module extension list.
|
||||
* @param \Drupal\system\ModuleAdminLinksHelper|null $module_admin_links
|
||||
* The module admin links.
|
||||
* @param \Drupal\user\ModulePermissionsLinkHelper|null $module_permissions_link
|
||||
* The module permission link.
|
||||
*/
|
||||
public function __construct(ModuleExtensionList $extension_list_module, ModuleAdminLinksHelper $module_admin_links = NULL, ModulePermissionsLinkHelper $module_permissions_link = NULL) {
|
||||
$this->moduleExtensionList = $extension_list_module;
|
||||
if (!isset($module_admin_links)) {
|
||||
@trigger_error('Calling ' . __METHOD__ . '() without the $module_admin_tasks_helper argument is deprecated in drupal:10.2.0 and the $module_admin_tasks_helper argument will be required in drupal:11.0.0. See https://www.drupal.org/node/3038972', E_USER_DEPRECATED);
|
||||
$module_admin_links = \Drupal::service('system.module_admin_links_helper');
|
||||
}
|
||||
$this->moduleAdminLinks = $module_admin_links;
|
||||
if (!isset($module_permissions_link)) {
|
||||
@trigger_error('Calling ' . __METHOD__ . ' without the $module_permissions_link argument is deprecated in drupal:10.2.0 and the $module_permissions_link argument will be required in drupal:11.0.0. See https://www.drupal.org/node/3038972', E_USER_DEPRECATED);
|
||||
$module_permissions_link = \Drupal::service('user.module_permissions_link_helper');
|
||||
}
|
||||
$this->modulePermissionsLinks = $module_permissions_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('extension.list.module'),
|
||||
$container->get('system.module_admin_links_helper'),
|
||||
$container->get('user.module_permissions_link_helper')
|
||||
);
|
||||
public function __construct(
|
||||
protected ModuleExtensionList $moduleExtensionList,
|
||||
protected ModuleAdminLinksHelper $moduleAdminLinks,
|
||||
protected ModulePermissionsLinkHelper $modulePermissionsLinks,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -101,7 +101,17 @@ class DbUpdateController extends ControllerBase {
|
|||
* @param \Drupal\Core\Asset\AssetQueryStringInterface $assetQueryString
|
||||
* The asset query string.
|
||||
*/
|
||||
public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry, protected ?AssetQueryStringInterface $assetQueryString = NULL) {
|
||||
public function __construct(
|
||||
$root,
|
||||
KeyValueExpirableFactoryInterface $key_value_expirable_factory,
|
||||
CacheBackendInterface $cache,
|
||||
StateInterface $state,
|
||||
ModuleHandlerInterface $module_handler,
|
||||
AccountInterface $account,
|
||||
BareHtmlPageRendererInterface $bare_html_page_renderer,
|
||||
UpdateRegistry $post_update_registry,
|
||||
protected AssetQueryStringInterface $assetQueryString,
|
||||
) {
|
||||
$this->root = $root;
|
||||
$this->keyValueExpirableFactory = $key_value_expirable_factory;
|
||||
$this->cache = $cache;
|
||||
|
@ -110,11 +120,6 @@ class DbUpdateController extends ControllerBase {
|
|||
$this->account = $account;
|
||||
$this->bareHtmlPageRenderer = $bare_html_page_renderer;
|
||||
$this->postUpdateRegistry = $post_update_registry;
|
||||
if ($this->assetQueryString === NULL) {
|
||||
$this->assetQueryString = \Drupal::service('asset.query_string');
|
||||
@trigger_error('Calling' . __METHOD__ . '() without the $assetQueryString argument is deprecated in drupal:10.2.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3358337', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,13 +17,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class DateFormatListBuilder extends ConfigEntityListBuilder {
|
||||
|
||||
/**
|
||||
* The date formatter service.
|
||||
*
|
||||
* @var \Drupal\Core\Datetime\DateFormatterInterface
|
||||
*/
|
||||
protected $dateFormatter;
|
||||
|
||||
/**
|
||||
* Constructs a new DateFormatListBuilder object.
|
||||
*
|
||||
|
@ -31,19 +24,18 @@ class DateFormatListBuilder extends ConfigEntityListBuilder {
|
|||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
|
||||
* The entity storage class.
|
||||
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
|
||||
* @param \Drupal\Core\Datetime\DateFormatterInterface $dateFormatter
|
||||
* The date formatter service.
|
||||
* @param \Drupal\Component\Datetime\TimeInterface|null $time
|
||||
* @param \Drupal\Component\Datetime\TimeInterface $time
|
||||
* The time service.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $date_formatter, protected ?TimeInterface $time = NULL) {
|
||||
public function __construct(
|
||||
EntityTypeInterface $entity_type,
|
||||
EntityStorageInterface $storage,
|
||||
protected DateFormatterInterface $dateFormatter,
|
||||
protected TimeInterface $time,
|
||||
) {
|
||||
parent::__construct($entity_type, $storage);
|
||||
|
||||
$this->dateFormatter = $date_formatter;
|
||||
if ($this->time === NULL) {
|
||||
@trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3112298', E_USER_DEPRECATED);
|
||||
$this->time = \Drupal::service('datetime.time');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,37 +14,14 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||
*/
|
||||
class ConfigCacheTag implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* The theme handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ThemeHandlerInterface
|
||||
*/
|
||||
protected $themeHandler;
|
||||
|
||||
/**
|
||||
* The cache tags invalidator.
|
||||
*
|
||||
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
|
||||
*/
|
||||
protected $cacheTagsInvalidator;
|
||||
|
||||
/**
|
||||
* Constructs a ConfigCacheTag object.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
|
||||
* The theme handler.
|
||||
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
|
||||
* The cache tags invalidator.
|
||||
* @param \Drupal\Core\Theme\Registry|null $themeRegistry
|
||||
* The theme registry.
|
||||
*/
|
||||
public function __construct(ThemeHandlerInterface $theme_handler, CacheTagsInvalidatorInterface $cache_tags_invalidator, protected ?Registry $themeRegistry = NULL) {
|
||||
$this->themeHandler = $theme_handler;
|
||||
$this->cacheTagsInvalidator = $cache_tags_invalidator;
|
||||
if ($this->themeRegistry === NULL) {
|
||||
@trigger_error('Calling ' . __METHOD__ . '() without the $themeRegistry argument is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3355227', E_USER_DEPRECATED);
|
||||
$this->themeRegistry = \Drupal::service('theme.registry');
|
||||
}
|
||||
public function __construct(
|
||||
protected ThemeHandlerInterface $themeHandler,
|
||||
protected CacheTagsInvalidatorInterface $cacheTagsInvalidator,
|
||||
protected Registry $themeRegistry,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,27 +14,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class DateFormatDeleteForm extends EntityDeleteForm {
|
||||
|
||||
/**
|
||||
* The date formatter service.
|
||||
*
|
||||
* @var \Drupal\Core\Datetime\DateFormatterInterface
|
||||
*/
|
||||
protected $dateFormatter;
|
||||
|
||||
/**
|
||||
* Constructs a DateFormatDeleteForm object.
|
||||
*
|
||||
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
|
||||
* The date formatter service.
|
||||
* @param \Drupal\Component\Datetime\TimeInterface|null $time
|
||||
* The time service.
|
||||
*/
|
||||
public function __construct(DateFormatterInterface $date_formatter, protected ?TimeInterface $time = NULL) {
|
||||
$this->dateFormatter = $date_formatter;
|
||||
if ($this->time === NULL) {
|
||||
@trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3112298', E_USER_DEPRECATED);
|
||||
$this->time = \Drupal::service('datetime.time');
|
||||
}
|
||||
public function __construct(
|
||||
protected DateFormatterInterface $dateFormatter,
|
||||
protected TimeInterface $time,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,15 +22,15 @@ class DateFormatEditForm extends DateFormatFormBase {
|
|||
* The date service.
|
||||
* @param \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $date_format_storage
|
||||
* The date format storage.
|
||||
* @param \Drupal\Component\Datetime\TimeInterface|null $time
|
||||
* @param \Drupal\Component\Datetime\TimeInterface $time
|
||||
* The time service.
|
||||
*/
|
||||
public function __construct(DateFormatterInterface $date_formatter, ConfigEntityStorageInterface $date_format_storage, protected ?TimeInterface $time = NULL) {
|
||||
public function __construct(
|
||||
DateFormatterInterface $date_formatter,
|
||||
ConfigEntityStorageInterface $date_format_storage,
|
||||
protected TimeInterface $time,
|
||||
) {
|
||||
parent::__construct($date_formatter, $date_format_storage);
|
||||
if ($this->time === NULL) {
|
||||
@trigger_error('Calling ' . __METHOD__ . ' without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3112298', E_USER_DEPRECATED);
|
||||
$this->time = \Drupal::service('datetime.time');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\system;
|
||||
|
||||
use Drupal\Component\Transliteration\TransliterationInterface;
|
||||
use Drupal\Core\Access\CsrfTokenGenerator;
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Controller routines for machine name transliteration routes.
|
||||
*
|
||||
* @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2662330
|
||||
*/
|
||||
class MachineNameController implements ContainerInjectionInterface {
|
||||
|
||||
/**
|
||||
* The transliteration helper.
|
||||
*
|
||||
* @var \Drupal\Component\Transliteration\TransliterationInterface
|
||||
*/
|
||||
protected $transliteration;
|
||||
|
||||
/**
|
||||
* The token generator.
|
||||
*
|
||||
* @var \Drupal\Core\Access\CsrfTokenGenerator
|
||||
*/
|
||||
protected $tokenGenerator;
|
||||
|
||||
/**
|
||||
* Constructs a MachineNameController object.
|
||||
*
|
||||
* @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
|
||||
* The transliteration helper.
|
||||
* @param \Drupal\Core\Access\CsrfTokenGenerator $token_generator
|
||||
* The token generator.
|
||||
*/
|
||||
public function __construct(TransliterationInterface $transliteration, CsrfTokenGenerator $token_generator) {
|
||||
$this->transliteration = $transliteration;
|
||||
$this->tokenGenerator = $token_generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('transliteration'),
|
||||
$container->get('csrf_token')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transliterates a string in given language. Various postprocessing possible.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* The input string and language for the transliteration.
|
||||
* Optionally may contain the replace_pattern, replace, lowercase parameters.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
* The transliterated string.
|
||||
*/
|
||||
public function transliterate(Request $request) {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3367037', E_USER_DEPRECATED);
|
||||
$text = $request->query->get('text');
|
||||
$langcode = $request->query->get('langcode');
|
||||
$replace_pattern = $request->query->get('replace_pattern');
|
||||
$replace_token = $request->query->get('replace_token');
|
||||
$replace = $request->query->get('replace');
|
||||
$lowercase = $request->query->get('lowercase');
|
||||
|
||||
$transliterated = $this->transliteration->transliterate($text, $langcode, '_');
|
||||
if ($lowercase) {
|
||||
$transliterated = mb_strtolower($transliterated);
|
||||
}
|
||||
|
||||
if (isset($replace_pattern) && isset($replace)) {
|
||||
if (!isset($replace_token)) {
|
||||
throw new AccessDeniedHttpException("Missing 'replace_token' query parameter.");
|
||||
}
|
||||
elseif (!$this->tokenGenerator->validate($replace_token, $replace_pattern)) {
|
||||
throw new AccessDeniedHttpException("Invalid 'replace_token' query parameter.");
|
||||
}
|
||||
|
||||
// Quote the pattern delimiter and remove null characters to avoid the e
|
||||
// or other modifiers being injected.
|
||||
$transliterated = preg_replace('@' . strtr($replace_pattern, ['@' => '\@', chr(0) => '']) . '@', $replace, $transliterated);
|
||||
}
|
||||
return new JsonResponse($transliterated);
|
||||
}
|
||||
|
||||
}
|
|
@ -111,85 +111,6 @@ class GDToolkit extends ImageToolkitBase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __get(string $name) {
|
||||
if ($name === 'resource') {
|
||||
@trigger_error('Accessing the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED);
|
||||
return $this->image;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __set(string $name, mixed $value): void {
|
||||
if ($name === 'resource') {
|
||||
@trigger_error('Setting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED);
|
||||
$this->image = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __isset(string $name): bool {
|
||||
if ($name === 'resource') {
|
||||
@trigger_error('Checking the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED);
|
||||
return isset($this->image);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __unset(string $name): void {
|
||||
if ($name === 'resource') {
|
||||
@trigger_error('Unsetting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED);
|
||||
unset($this->image);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the GD image resource.
|
||||
*
|
||||
* @param \GdImage $resource
|
||||
* The GD image resource.
|
||||
*
|
||||
* @return $this
|
||||
* An instance of the current toolkit object.
|
||||
*
|
||||
* @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use
|
||||
* \Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3265963
|
||||
*/
|
||||
public function setResource($resource) {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage() instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED);
|
||||
if (!$resource instanceof \GdImage) {
|
||||
throw new \InvalidArgumentException('Invalid resource argument');
|
||||
}
|
||||
return $this->setImage($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the GD image resource.
|
||||
*
|
||||
* @return \GdImage|null
|
||||
* The GD image resource, or NULL if not available.
|
||||
*
|
||||
* @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use
|
||||
* \Drupal\system\Plugin\ImageToolkit\GDToolkit::getImage() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3265963
|
||||
*/
|
||||
public function getResource() {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::getImage() instead. See https://www.drupal.org/node/3265963', E_USER_DEPRECATED);
|
||||
return $this->getImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an image or resets existing one.
|
||||
*
|
||||
|
|
|
@ -13,16 +13,8 @@ use Drupal\Core\Asset\AttachedAssetsInterface;
|
|||
use Drupal\Core\Block\BlockPluginInterface;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Database\Query\AlterableInterface;
|
||||
use Drupal\Core\Datetime\TimeZoneFormHelper;
|
||||
use Drupal\Core\Entity\ContentEntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityViewModeInterface;
|
||||
use Drupal\Core\Entity\EntityFormModeInterface;
|
||||
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldFormatter\TimestampFormatter;
|
||||
use Drupal\Core\File\Exception\FileException;
|
||||
use Drupal\Core\File\Exception\InvalidStreamWrapperException;
|
||||
use Drupal\Core\File\FileSystemInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\KeyValueStore\KeyValueDatabaseExpirableFactory;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
@ -35,7 +27,6 @@ use Drupal\Core\Site\Settings;
|
|||
use Drupal\Core\StreamWrapper\LocalStream;
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperManager;
|
||||
use Drupal\Core\Url;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
|
@ -967,35 +958,6 @@ function system_admin_compact_mode() {
|
|||
return \Drupal::request()->cookies->get('Drupal_visitor_admin_compact_mode', \Drupal::config('system.site')->get('admin_compact_mode'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a list of tasks offered by a specified module.
|
||||
*
|
||||
* @param string $module
|
||||
* Module name.
|
||||
* @param string|array $module_name
|
||||
* The module's display name. Passing information, as provided by
|
||||
* \Drupal::service('extension.list.module')->getExtensionInfo() is
|
||||
* deprecated in drupal:10.2.0. Pass only $info["name"] instead.
|
||||
*
|
||||
* @return array
|
||||
* An array of task links.
|
||||
*
|
||||
* @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the
|
||||
* 'system.module_admin_links_helper' service with the getModuleAdminLinks() method
|
||||
* and 'user.module_permissions_link_helper' service with the
|
||||
* ::getModulePermissionsLink() method instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3038972
|
||||
*/
|
||||
function system_get_module_admin_tasks($module, string|array $module_name) {
|
||||
@trigger_error("system_get_module_admin_tasks() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the 'system.module_admin_links_helper' service with the getModuleAdminLinks() method and 'user.module_permissions_link_helper' service with the ::getModulePermissionsLink() method instead. See https://www.drupal.org/node/3038972", E_USER_DEPRECATED);
|
||||
$module_admin_links = \Drupal::service('system.module_admin_links_helper')->getModuleAdminLinks($module);
|
||||
if ($module_permissions_link = \Drupal::service('user.module_permissions_link_helper')->getModulePermissionsLink($module, $module_name)) {
|
||||
$module_admin_links["user.admin_permissions.{$module}"] = $module_permissions_link;
|
||||
}
|
||||
return $module_admin_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_cron().
|
||||
*
|
||||
|
@ -1055,111 +1017,6 @@ function system_mail($key, &$message, $params) {
|
|||
$message['body'][] = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an array of time zones and their local time&date.
|
||||
*
|
||||
* @param mixed $blank
|
||||
* If evaluates true, prepend an empty time zone option to the array.
|
||||
* @param bool $grouped
|
||||
* (optional) Whether the timezones should be grouped by region.
|
||||
*
|
||||
* @return array
|
||||
* An array or nested array containing time zones, keyed by the system name.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. This function
|
||||
* is no longer used in Drupal core. Use
|
||||
* \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList() or
|
||||
* \DateTimeZone::listIdentifiers() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3023528
|
||||
*/
|
||||
function system_time_zones($blank = NULL, $grouped = FALSE) {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. This function is no longer used in Drupal core. Use \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(), \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion() or \DateTimeZone::listIdentifiers() instead. See https://www.drupal.org/node/3023528', E_USER_DEPRECATED);
|
||||
return $grouped ? TimeZoneFormHelper::getOptionsListByRegion((bool) $blank) : TimeZoneFormHelper::getOptionsList((bool) $blank);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get a file using Guzzle HTTP client and to store it locally.
|
||||
*
|
||||
* @param string $url
|
||||
* The URL of the file to grab.
|
||||
* @param string $destination
|
||||
* Stream wrapper URI specifying where the file should be placed. If a
|
||||
* directory path is provided, the file is saved into that directory under
|
||||
* its original name. If the path contains a filename as well, that one will
|
||||
* be used instead.
|
||||
* If this value is omitted, the site's default files scheme will be used,
|
||||
* usually "public://".
|
||||
* @param bool $managed
|
||||
* If this is set to TRUE, the file API hooks will be invoked and the file is
|
||||
* registered in the database.
|
||||
* @param int $replace
|
||||
* Replace behavior when the destination file already exists:
|
||||
* - FileSystemInterface::EXISTS_REPLACE: Replace the existing file.
|
||||
* - FileSystemInterface::EXISTS_RENAME: Append _{incrementing number} until
|
||||
* the filename is unique.
|
||||
* - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE.
|
||||
*
|
||||
* @return mixed
|
||||
* One of these possibilities:
|
||||
* - If it succeeds and $managed is FALSE, the location where the file was
|
||||
* saved.
|
||||
* - If it succeeds and $managed is TRUE, a \Drupal\file\FileInterface
|
||||
* object which describes the file.
|
||||
* - If it fails, FALSE.
|
||||
*
|
||||
* @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3223362
|
||||
*/
|
||||
function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FileSystemInterface::EXISTS_RENAME) {
|
||||
@trigger_error('system_retrieve_file is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3223362', E_USER_DEPRECATED);
|
||||
$parsed_url = parse_url($url);
|
||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
||||
$file_system = \Drupal::service('file_system');
|
||||
if (!isset($destination)) {
|
||||
$path = $file_system->basename($parsed_url['path']);
|
||||
$path = \Drupal::config('system.file')->get('default_scheme') . '://' . $path;
|
||||
$path = \Drupal::service('stream_wrapper_manager')->normalizeUri($path);
|
||||
}
|
||||
else {
|
||||
if (is_dir($file_system->realpath($destination))) {
|
||||
// Prevent URIs with triple slashes when glueing parts together.
|
||||
$path = str_replace('///', '//', "$destination/") . \Drupal::service('file_system')->basename($parsed_url['path']);
|
||||
}
|
||||
else {
|
||||
$path = $destination;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$data = (string) \Drupal::httpClient()
|
||||
->get($url)
|
||||
->getBody();
|
||||
if ($managed) {
|
||||
/** @var \Drupal\file\FileRepositoryInterface $file_repository */
|
||||
$file_repository = \Drupal::service('file.repository');
|
||||
$local = $file_repository->writeData($data, $path, $replace);
|
||||
}
|
||||
else {
|
||||
$local = $file_system->saveData($data, $path, $replace);
|
||||
}
|
||||
}
|
||||
catch (ClientExceptionInterface $exception) {
|
||||
\Drupal::messenger()->addError(t('Failed to fetch file due to error "%error"', ['%error' => $exception->getMessage()]));
|
||||
return FALSE;
|
||||
}
|
||||
catch (FileException | InvalidStreamWrapperException $e) {
|
||||
\Drupal::messenger()->addError(t('Failed to save file due to error "%error"', ['%error' => $e->getMessage()]));
|
||||
return FALSE;
|
||||
}
|
||||
if (!$local) {
|
||||
\Drupal::messenger()->addError(t('@remote could not be saved to @path.', ['@remote' => $url, '@path' => $path]));
|
||||
}
|
||||
|
||||
return $local;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_type_build().
|
||||
*/
|
||||
|
@ -1363,62 +1220,3 @@ function system_archiver_info_alter(&$info) {
|
|||
unset($info['Zip']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for entity_view_display entities.
|
||||
*
|
||||
* Provides a BC layer for modules providing old configurations.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2993639
|
||||
*
|
||||
* @todo Remove this BC layer in drupal:11.0.0.
|
||||
*/
|
||||
function system_entity_view_display_presave(EntityViewDisplayInterface $entity_view_display): void {
|
||||
/** @var \Drupal\Core\Field\FormatterPluginManager $field_formatter_manager */
|
||||
$field_formatter_manager = \Drupal::service('plugin.manager.field.formatter');
|
||||
|
||||
foreach ($entity_view_display->getComponents() as $name => $component) {
|
||||
if (empty($component['type'])) {
|
||||
continue;
|
||||
}
|
||||
if (!$plugin_definition = $field_formatter_manager->getDefinition($component['type'], FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check also potential plugins that extends TimestampFormatter.
|
||||
if (!is_a($plugin_definition['class'], TimestampFormatter::class, TRUE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($component['settings']['tooltip']) || !isset($component['settings']['time_diff'])) {
|
||||
@trigger_error("Using the 'timestamp' formatter plugin without the 'tooltip' and 'time_diff' settings is deprecated in drupal:10.1.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/2993639", E_USER_DEPRECATED);
|
||||
$entity_view_display->setComponent($name, $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for view mode entities.
|
||||
*
|
||||
* Sets the description property to an empty string.
|
||||
*
|
||||
* @todo Remove this BC layer in drupal:11.0.0.
|
||||
*/
|
||||
function system_entity_view_mode_presave(EntityViewModeInterface $entity_view_mode) {
|
||||
if ($entity_view_mode->get('description') === NULL) {
|
||||
$entity_view_mode->set('description', '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for form mode entities.
|
||||
*
|
||||
* Sets the description property to an empty string.
|
||||
*
|
||||
* @todo Remove this BC layer in drupal:11.0.0.
|
||||
*/
|
||||
function system_entity_form_mode_presave(EntityFormModeInterface $entity_form_mode) {
|
||||
if ($entity_form_mode->get('description') === NULL) {
|
||||
$entity_form_mode->set('description', '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,16 +143,6 @@ system.admin_compact_page:
|
|||
requirements:
|
||||
_permission: 'access administration pages'
|
||||
|
||||
# @todo Deprecate this route once
|
||||
# https://www.drupal.org/i/3159210 is fixed, or remove it in Drupal 11.
|
||||
# @see https://www.drupal.org/node/3367037
|
||||
system.machine_name_transliterate:
|
||||
path: '/machine_name/transliterate'
|
||||
defaults:
|
||||
_controller: '\Drupal\system\MachineNameController::transliterate'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
system.site_information_settings:
|
||||
path: '/admin/config/system/site-information'
|
||||
defaults:
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
name: 'Database Statement Monitoring Test'
|
||||
type: module
|
||||
description: 'Support module for Database layer tests that need to monitor executed database statements.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
lifecycle: deprecated
|
||||
lifecycle_link: 'https://www.drupal.org/node/3318162'
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\database_statement_monitoring_test;
|
||||
|
||||
@trigger_error('\Drupal\database_statement_monitoring_test\LoggedStatementsTrait is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3318162', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Trait for Connection classes that can store logged statements.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3318162
|
||||
*/
|
||||
trait LoggedStatementsTrait {
|
||||
|
||||
/**
|
||||
* Logged statements.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $loggedStatements;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query($query, array $args = [], $options = []) {
|
||||
// Log the query if it is a string, can receive statement objects e.g
|
||||
// in the pgsql driver. These are hard to log as the table name has already
|
||||
// been replaced.
|
||||
if (is_string($query)) {
|
||||
$stringified_args = array_map(function ($v) {
|
||||
return is_array($v) ? implode(',', $v) : $v;
|
||||
}, $args);
|
||||
$this->loggedStatements[] = str_replace(array_keys($stringified_args), array_values($stringified_args), $query);
|
||||
}
|
||||
return parent::query($query, $args, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets logged statements.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function resetLoggedStatements() {
|
||||
$this->loggedStatements = [];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDriverClass($class) {
|
||||
static $fixed_namespace;
|
||||
if (!$fixed_namespace) {
|
||||
// Override because we've altered the namespace in
|
||||
// \Drupal\KernelTests\Core\Cache\EndOfTransactionQueriesTest::getDatabaseConnectionInfo()
|
||||
// to use the logging Connection classes. Set to a proper database driver
|
||||
// namespace.
|
||||
$this->connectionOptions['namespace'] = (new \ReflectionClass(get_parent_class($this)))->getNamespaceName();
|
||||
$fixed_namespace = TRUE;
|
||||
}
|
||||
return parent::getDriverClass($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the executed queries.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getLoggedStatements() {
|
||||
return $this->loggedStatements;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\database_statement_monitoring_test\mysql;
|
||||
|
||||
use Drupal\mysql\Driver\Database\mysql\Connection as BaseConnection;
|
||||
use Drupal\database_statement_monitoring_test\LoggedStatementsTrait;
|
||||
|
||||
@trigger_error('\Drupal\database_statement_monitoring_test\mysql\Connection is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3318162', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* MySQL Connection class that can log executed queries.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3318162
|
||||
*/
|
||||
class Connection extends BaseConnection {
|
||||
use LoggedStatementsTrait;
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\database_statement_monitoring_test\mysql\Install;
|
||||
|
||||
use Drupal\mysql\Driver\Database\mysql\Install\Tasks as BaseTasks;
|
||||
|
||||
@trigger_error('\Drupal\database_statement_monitoring_test\mysql\Install\Tasks is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3318162', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3318162
|
||||
*/
|
||||
class Tasks extends BaseTasks {
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\database_statement_monitoring_test\pgsql;
|
||||
|
||||
use Drupal\pgsql\Driver\Database\pgsql\Connection as BaseConnection;
|
||||
use Drupal\database_statement_monitoring_test\LoggedStatementsTrait;
|
||||
|
||||
@trigger_error('\Drupal\database_statement_monitoring_test\pgsql\Connection is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3318162', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* PostgreSQL Connection class that can log executed queries.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3318162
|
||||
*/
|
||||
class Connection extends BaseConnection {
|
||||
use LoggedStatementsTrait;
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\database_statement_monitoring_test\pgsql\Install;
|
||||
|
||||
use Drupal\pgsql\Driver\Database\pgsql\Install\Tasks as BaseTasks;
|
||||
|
||||
@trigger_error('\Drupal\database_statement_monitoring_test\pgsql\Install\Tasks is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3318162', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3318162
|
||||
*/
|
||||
class Tasks extends BaseTasks {
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\database_statement_monitoring_test\sqlite;
|
||||
|
||||
use Drupal\sqlite\Driver\Database\sqlite\Connection as BaseConnection;
|
||||
use Drupal\database_statement_monitoring_test\LoggedStatementsTrait;
|
||||
|
||||
@trigger_error('\Drupal\database_statement_monitoring_test\sqlite\Connection is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3318162', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* SQlite Connection class that can log executed queries.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3318162
|
||||
*/
|
||||
class Connection extends BaseConnection {
|
||||
use LoggedStatementsTrait;
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\database_statement_monitoring_test\sqlite\Install;
|
||||
|
||||
use Drupal\sqlite\Driver\Database\sqlite\Install\Tasks as BaseTasks;
|
||||
|
||||
@trigger_error('\Drupal\database_statement_monitoring_test\sqlite\Install\Tasks is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3318162', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3318162
|
||||
*/
|
||||
class Tasks extends BaseTasks {
|
||||
}
|
|
@ -610,32 +610,6 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
|
|||
$this->verifyPageCache($nonempty_entity_listing_url, 'HIT', $nonempty_entity_listing_cache_tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cache ID from a list of cache keys and a set of cache contexts.
|
||||
*
|
||||
* @param string[] $keys
|
||||
* A list of cache keys.
|
||||
* @param string[] $contexts
|
||||
* A set of cache contexts.
|
||||
*
|
||||
* @return string
|
||||
* The cache ID string.
|
||||
*
|
||||
* @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3354596
|
||||
*/
|
||||
protected function createCacheId(array $keys, array $contexts) {
|
||||
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3354596', E_USER_DEPRECATED);
|
||||
$cid_parts = $keys;
|
||||
|
||||
$contexts = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($contexts);
|
||||
$cid_parts = array_merge($cid_parts, $contexts->getKeys());
|
||||
|
||||
return implode(':', $cid_parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that a given render cache entry exists, with the correct cache tags.
|
||||
*
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\system\Functional\System;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests HTTP file fetching and error handling.
|
||||
*
|
||||
* @group system
|
||||
* @group legacy
|
||||
*/
|
||||
class RetrieveFileTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Invokes system_retrieve_file() in several scenarios.
|
||||
*/
|
||||
public function testFileRetrieving() {
|
||||
// Test 404 handling by trying to fetch a randomly named file.
|
||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
||||
$file_system = \Drupal::service('file_system');
|
||||
$file_system->mkdir($source_dir = 'public://' . $this->randomMachineName());
|
||||
// cSpell:disable-next-line
|
||||
$filename = 'Файл для тестирования ' . $this->randomMachineName();
|
||||
$url = \Drupal::service('file_url_generator')->generateAbsoluteString($source_dir . '/' . $filename);
|
||||
$retrieved_file = system_retrieve_file($url);
|
||||
$this->assertFalse($retrieved_file, 'Non-existent file not fetched.');
|
||||
|
||||
// Actually create that file, download it via HTTP and test the returned path.
|
||||
file_put_contents($source_dir . '/' . $filename, 'testing');
|
||||
$retrieved_file = system_retrieve_file($url);
|
||||
|
||||
// URLs could not contains characters outside the ASCII set so $filename
|
||||
// has to be encoded.
|
||||
$encoded_filename = rawurlencode($filename);
|
||||
|
||||
$this->assertEquals('public://' . $encoded_filename, $retrieved_file, 'Sane path for downloaded file returned (public:// scheme).');
|
||||
$this->assertFileExists($retrieved_file);
|
||||
$this->assertEquals(7, filesize($retrieved_file), 'File size of downloaded file is correct (public:// scheme).');
|
||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
||||
$file_system = \Drupal::service('file_system');
|
||||
$file_system->delete($retrieved_file);
|
||||
|
||||
// Test downloading file to a different location.
|
||||
$file_system->mkdir($target_dir = 'temporary://' . $this->randomMachineName());
|
||||
$retrieved_file = system_retrieve_file($url, $target_dir);
|
||||
$this->assertEquals("{$target_dir}/{$encoded_filename}", $retrieved_file, 'Sane path for downloaded file returned (temporary:// scheme).');
|
||||
$this->assertFileExists($retrieved_file);
|
||||
$this->assertEquals(7, filesize($retrieved_file), 'File size of downloaded file is correct (temporary:// scheme).');
|
||||
$file_system->delete($retrieved_file);
|
||||
|
||||
$file_system->deleteRecursive($source_dir);
|
||||
$file_system->deleteRecursive($target_dir);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\system\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
/**
|
||||
* Tests the update of timestamp formatter settings.
|
||||
*
|
||||
* @group system
|
||||
* @group legacy
|
||||
*/
|
||||
class TimestampFormatterSettingsUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles(): void {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz',
|
||||
__DIR__ . '/../../../../../layout_builder/tests/fixtures/update/layout-builder.php',
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal.timestamp-formatter-settings-2921810.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the update of timestamp formatter settings.
|
||||
*
|
||||
* @covers \system_post_update_timestamp_formatter
|
||||
* @covers \views_post_update_timestamp_formatter
|
||||
* @covers \layout_builder_post_update_timestamp_formatter
|
||||
*/
|
||||
public function testPostUpdateTimestampFormatter(): void {
|
||||
$config_factory = \Drupal::configFactory();
|
||||
|
||||
$test_cases = [
|
||||
// Timestamp formatter in entity view display.
|
||||
'content.field_foo.settings' => 'core.entity_view_display.node.page.default',
|
||||
// Timestamp formatter in view.
|
||||
'display.default.display_options.fields.changed.settings' => 'views.view.content',
|
||||
// Timestamp formatter in Layout Builder field block.
|
||||
'third_party_settings.layout_builder.sections.0.components.93bf4359-06a6-4263-bce9-15c90dc8f357.configuration.formatter.settings' => 'core.entity_view_display.node.page.default',
|
||||
];
|
||||
|
||||
foreach ($test_cases as $config_path => $config_name) {
|
||||
// Check that 'tooltip' and 'time_diff' are missing before update.
|
||||
$settings = $config_factory->get($config_name)->get($config_path);
|
||||
Assert::assertArrayNotHasKey('tooltip', $settings);
|
||||
Assert::assertArrayNotHasKey('time_diff', $settings);
|
||||
}
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
foreach ($test_cases as $config_path => $config_name) {
|
||||
// Check that 'tooltip' and 'time_diff' were created after update.
|
||||
$settings = $config_factory->get($config_name)->get($config_path);
|
||||
Assert::assertArrayHasKey('tooltip', $settings);
|
||||
// Check that 'tooltip' is disabled for existing formatters.
|
||||
Assert::assertSame([
|
||||
'date_format' => '',
|
||||
'custom_date_format' => '',
|
||||
], $settings['tooltip']);
|
||||
Assert::assertArrayHasKey('time_diff', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\system\Functional\Update;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewMode;
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
|
||||
/**
|
||||
* @covers system_post_update_add_description_to_entity_view_mode
|
||||
* @covers system_post_update_add_description_to_entity_form_mode
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class UpdateDescriptionConfigurationPostUpdate extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that an empty string is added as a default value for description.
|
||||
*/
|
||||
public function testUpdateDescriptionConfigurationPostUpdate(): void {
|
||||
$view_mode = EntityViewMode::load('block_content.full');
|
||||
$this->assertNull($view_mode->get('description'));
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
$view_mode = EntityViewMode::load('block_content.full');
|
||||
$this->assertSame('', $view_mode->get('description'));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Kernel\System;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests the deprecations in the system module.
|
||||
*
|
||||
* @group system
|
||||
* @group legacy
|
||||
*/
|
||||
class SystemFunctionsLegacyTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'system',
|
||||
// Test system_get_module_admin_tasks() require user.permissions service.
|
||||
'user',
|
||||
];
|
||||
|
||||
/**
|
||||
* @covers ::system_time_zones
|
||||
*/
|
||||
public function testSystemTimeZones() {
|
||||
$this->expectDeprecation('system_time_zones() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. This function is no longer used in Drupal core. Use \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(), \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion() or \DateTimeZone::listIdentifiers() instead. See https://www.drupal.org/node/3023528');
|
||||
system_time_zones();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::system_retrieve_file
|
||||
*/
|
||||
public function testSystemRetrieveFile() {
|
||||
$this->expectDeprecation('system_retrieve_file is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3223362');
|
||||
$retrieved_file = system_retrieve_file('http://example.com/foo.txt');
|
||||
$this->assertFalse($retrieved_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests system_get_module_admin_tasks() deprecation.
|
||||
*
|
||||
* @see system_get_module_admin_tasks()
|
||||
* @see drupal_static_reset()
|
||||
*/
|
||||
public function testSystemGetModuleAdminTasksDeprecation(): void {
|
||||
$this->expectDeprecation("system_get_module_admin_tasks() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the 'system.module_admin_links_helper' service with the getModuleAdminLinks() method and 'user.module_permissions_link_helper' service with the ::getModulePermissionsLink() method instead. See https://www.drupal.org/node/3038972");
|
||||
system_get_module_admin_tasks('foo', 'Foo');
|
||||
$this->expectDeprecation("Calling drupal_static_reset() with 'system_get_module_admin_tasks' as an argument is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3038972");
|
||||
drupal_static_reset('system_get_module_admin_tasks');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\system\Unit\Transliteration;
|
||||
|
||||
use Drupal\Core\Access\CsrfTokenGenerator;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Component\Transliteration\PhpTransliteration;
|
||||
use Drupal\system\MachineNameController;
|
||||
use Prophecy\Argument;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
// cspell:ignore aewesome
|
||||
|
||||
/**
|
||||
* Tests that the machine name controller can transliterate strings as expected.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
class MachineNameControllerTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The machine name controller.
|
||||
*
|
||||
* @var \Drupal\system\MachineNameController
|
||||
*/
|
||||
protected $machineNameController;
|
||||
|
||||
/**
|
||||
* The CSRF token generator.
|
||||
*
|
||||
* @var \Drupal\Core\Access\CsrfTokenGenerator
|
||||
*/
|
||||
protected $tokenGenerator;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
// Create the machine name controller.
|
||||
$this->tokenGenerator = $this->prophesize(CsrfTokenGenerator::class);
|
||||
$this->tokenGenerator->validate(Argument::cetera())->will(function ($args) {
|
||||
return $args[0] === 'token-' . $args[1];
|
||||
});
|
||||
|
||||
$this->machineNameController = new MachineNameController(new PhpTransliteration(), $this->tokenGenerator->reveal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testMachineNameController().
|
||||
*
|
||||
* @see testMachineNameController()
|
||||
*
|
||||
* @return array
|
||||
* An array containing:
|
||||
* - An array of request parameters.
|
||||
* - The expected content of the JSONresponse.
|
||||
*/
|
||||
public static function providerTestMachineNameController() {
|
||||
// cspell:ignore äwesome
|
||||
$valid_data = [
|
||||
[['text' => 'Bob', 'langcode' => 'en'], '"Bob"'],
|
||||
[['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE], '"bob"'],
|
||||
[['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob'], '"Alice"'],
|
||||
[['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Tom'], '"Bob"'],
|
||||
[['text' => 'Äwesome', 'langcode' => 'en', 'lowercase' => TRUE], '"awesome"'],
|
||||
[['text' => 'Äwesome', 'langcode' => 'de', 'lowercase' => TRUE], '"aewesome"'],
|
||||
// Tests special characters replacement in the input text.
|
||||
[['text' => 'B?!"@\/-ob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.]+'], '"b_ob_e"'],
|
||||
// Tests @ character in the replace_pattern regex.
|
||||
[['text' => 'Bob@e\0', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.@]+'], '"bob@e_0"'],
|
||||
// Tests null byte in the replace_pattern regex.
|
||||
[['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"bob"'],
|
||||
[['text' => 'Bob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"fail()"'],
|
||||
];
|
||||
|
||||
$valid_data = array_map(function ($data) {
|
||||
if (isset($data[0]['replace_pattern'])) {
|
||||
$data[0]['replace_token'] = 'token-' . $data[0]['replace_pattern'];
|
||||
}
|
||||
return $data;
|
||||
}, $valid_data);
|
||||
|
||||
return $valid_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests machine name controller's transliteration functionality.
|
||||
*
|
||||
* @param array $request_params
|
||||
* An array of request parameters.
|
||||
* @param $expected_content
|
||||
* The expected content of the JSONresponse.
|
||||
*
|
||||
* @see \Drupal\system\MachineNameController::transliterate()
|
||||
*
|
||||
* @dataProvider providerTestMachineNameController
|
||||
*/
|
||||
public function testMachineNameController(array $request_params, $expected_content) {
|
||||
$request = Request::create('', 'GET', $request_params);
|
||||
$json = $this->machineNameController->transliterate($request);
|
||||
$this->assertEquals($expected_content, $json->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the pattern validation.
|
||||
*/
|
||||
public function testMachineNameControllerWithInvalidReplacePattern() {
|
||||
$request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob', 'replace_token' => 'invalid']);
|
||||
|
||||
$this->expectException(AccessDeniedHttpException::class);
|
||||
$this->expectExceptionMessage("Invalid 'replace_token' query parameter.");
|
||||
$this->machineNameController->transliterate($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the pattern validation with a missing token.
|
||||
*/
|
||||
public function testMachineNameControllerWithMissingToken() {
|
||||
$request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob']);
|
||||
|
||||
$this->expectException(AccessDeniedHttpException::class);
|
||||
$this->expectExceptionMessage("Missing 'replace_token' query parameter.");
|
||||
$this->machineNameController->transliterate($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecation of MachineNameController.
|
||||
*/
|
||||
public function testMachineNameControllerDeprecation(): void {
|
||||
$request = Request::create('', 'GET', ['text' => 'Bob', 'langcode' => 'en']);
|
||||
$this->expectDeprecation('Drupal\system\MachineNameController::transliterate() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3367037');
|
||||
$json = $this->machineNameController->transliterate($request);
|
||||
$this->assertEquals('"Bob"', $json->getContent());
|
||||
}
|
||||
|
||||
}
|
|
@ -537,29 +537,4 @@ class ToolkitGdTest extends KernelTestBase {
|
|||
], $this->imageFactory->get()->getToolkit()->getRequirements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecated setResource() and getResource().
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testResourceDeprecation() {
|
||||
$toolkit = $this->imageFactory->get()->getToolkit();
|
||||
$image = imagecreate(10, 10);
|
||||
$this->expectDeprecation('Drupal\system\Plugin\ImageToolkit\GDToolkit::setResource() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage() instead. See https://www.drupal.org/node/3265963');
|
||||
$toolkit->setResource($image);
|
||||
$this->expectDeprecation('Checking the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
|
||||
$this->assertTrue(isset($toolkit->resource));
|
||||
$this->expectDeprecation('Drupal\system\Plugin\ImageToolkit\GDToolkit::getResource() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::getImage() instead. See https://www.drupal.org/node/3265963');
|
||||
$this->assertSame($image, $toolkit->getResource());
|
||||
$this->expectDeprecation('Accessing the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
|
||||
$this->assertSame($image, $toolkit->resource);
|
||||
$this->expectDeprecation('Setting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
|
||||
$toolkit->resource = NULL;
|
||||
$this->assertNull($toolkit->getImage());
|
||||
$this->expectDeprecation('Unsetting the \Drupal\system\Plugin\ImageToolkit\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\system\Plugin\ImageToolkit\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
|
||||
$toolkit->setImage($image);
|
||||
unset($toolkit->resource);
|
||||
$this->assertNull($toolkit->getImage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,158 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\Core\Asset;
|
||||
|
||||
use Drupal\Core\Asset\AssetCollectionGrouperInterface;
|
||||
use Drupal\Core\Asset\AssetDumperInterface;
|
||||
use Drupal\Core\Asset\AssetOptimizerInterface;
|
||||
use Drupal\Core\Asset\CssCollectionOptimizer;
|
||||
use Drupal\Core\File\FileSystemInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Tests the CSS asset optimizer.
|
||||
*
|
||||
* @group Asset
|
||||
*/
|
||||
class CssCollectionOptimizerUnitTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The data from the dumper.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dumperData;
|
||||
|
||||
/**
|
||||
* A CSS Collection optimizer.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\AssetCollectionOptimizerInterface
|
||||
*/
|
||||
protected $optimizer;
|
||||
|
||||
/**
|
||||
* Tests that CSS imports with strange letters do not destroy the CSS output.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testCssImport() {
|
||||
$mock_grouper = $this->createMock(AssetCollectionGrouperInterface::class);
|
||||
$mock_grouper->method('group')
|
||||
->willReturnCallback(function ($assets) {
|
||||
return [
|
||||
[
|
||||
'items' => $assets,
|
||||
'type' => 'file',
|
||||
'preprocess' => TRUE,
|
||||
],
|
||||
];
|
||||
});
|
||||
$mock_optimizer = $this->createMock(AssetOptimizerInterface::class);
|
||||
$mock_optimizer->method('optimize')
|
||||
->willReturn(
|
||||
file_get_contents(__DIR__ . '/css_test_files/css_input_with_import.css.optimized.css'),
|
||||
file_get_contents(__DIR__ . '/css_test_files/css_subfolder/css_input_with_import.css.optimized.css')
|
||||
);
|
||||
$mock_dumper = $this->createMock(AssetDumperInterface::class);
|
||||
$mock_dumper->method('dump')
|
||||
->willReturnCallback(function ($css) {
|
||||
$this->dumperData = $css;
|
||||
});
|
||||
$mock_state = $this->createMock(StateInterface::class);
|
||||
$mock_file_system = $this->createMock(FileSystemInterface::class);
|
||||
$this->optimizer = new CssCollectionOptimizer($mock_grouper, $mock_optimizer, $mock_dumper, $mock_state, $mock_file_system);
|
||||
$gpl_license = [
|
||||
'name' => 'GNU-GPL-2.0-or-later',
|
||||
'url' => 'https://www.drupal.org/licensing/faq',
|
||||
'gpl-compatible' => TRUE,
|
||||
];
|
||||
$this->optimizer->optimize([
|
||||
'core/modules/system/tests/modules/common_test/common_test_css_import.css' => [
|
||||
'type' => 'file',
|
||||
'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css',
|
||||
'preprocess' => TRUE,
|
||||
'license' => $gpl_license,
|
||||
],
|
||||
'core/modules/system/tests/modules/common_test/common_test_css_import_not_preprocessed.css' => [
|
||||
'type' => 'file',
|
||||
'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css',
|
||||
'preprocess' => TRUE,
|
||||
'license' => $gpl_license,
|
||||
],
|
||||
],
|
||||
[]);
|
||||
self::assertEquals(file_get_contents(__DIR__ . '/css_test_files/css_input_with_import.css.optimized.aggregated.css'), $this->dumperData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that CSS imports with strange letters do not destroy the CSS output.
|
||||
*
|
||||
* Checks that license information is added only once when several files
|
||||
* have the same license. Checks that multiple licenses are added properly.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testCssLicenseAggregation() {
|
||||
$mock_grouper = $this->createMock(AssetCollectionGrouperInterface::class);
|
||||
$mock_grouper->method('group')
|
||||
->willReturnCallback(function ($assets) {
|
||||
return [
|
||||
[
|
||||
'items' => $assets,
|
||||
'type' => 'file',
|
||||
'preprocess' => TRUE,
|
||||
],
|
||||
];
|
||||
});
|
||||
$mock_optimizer = $this->createMock(AssetOptimizerInterface::class);
|
||||
$mock_optimizer->method('optimize')
|
||||
->willReturn(
|
||||
file_get_contents(__DIR__ . '/css_test_files/css_input_with_import.css.optimized.css'),
|
||||
file_get_contents(__DIR__ . '/css_test_files/css_subfolder/css_input_with_import.css.optimized.css'),
|
||||
file_get_contents(__DIR__ . '/css_test_files/css_input_without_import.css.optimized.css')
|
||||
);
|
||||
$mock_dumper = $this->createMock(AssetDumperInterface::class);
|
||||
$mock_dumper->method('dump')
|
||||
->willReturnCallback(function ($css) {
|
||||
$this->dumperData = $css;
|
||||
});
|
||||
$mock_state = $this->createMock(StateInterface::class);
|
||||
$mock_file_system = $this->createMock(FileSystemInterface::class);
|
||||
$this->optimizer = new CssCollectionOptimizer($mock_grouper, $mock_optimizer, $mock_dumper, $mock_state, $mock_file_system);
|
||||
$gpl_license = [
|
||||
'name' => 'GNU-GPL-2.0-or-later',
|
||||
'url' => 'https://www.drupal.org/licensing/faq',
|
||||
'gpl-compatible' => TRUE,
|
||||
];
|
||||
$this->optimizer->optimize([
|
||||
'core/modules/system/tests/modules/common_test/common_test_css_import.css' => [
|
||||
'type' => 'file',
|
||||
'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css',
|
||||
'preprocess' => TRUE,
|
||||
'license' => $gpl_license,
|
||||
],
|
||||
'core/modules/system/tests/modules/common_test/common_test_css_import_not_preprocessed.css' => [
|
||||
'type' => 'file',
|
||||
'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css',
|
||||
'preprocess' => TRUE,
|
||||
'license' => $gpl_license,
|
||||
],
|
||||
'core/modules/system/tests/modules/common_test/css_input_without_import.css' => [
|
||||
'type' => 'file',
|
||||
'data' => 'core/modules/system/tests/modules/common_test/css_input_without_import.css',
|
||||
'preprocess' => TRUE,
|
||||
'license' => [
|
||||
'name' => 'MIT',
|
||||
'url' => 'https://opensource.org/licenses/MIT',
|
||||
'gpl-compatible' => TRUE,
|
||||
],
|
||||
],
|
||||
],
|
||||
[]);
|
||||
self::assertEquals(file_get_contents(__DIR__ . '/css_test_files/css_license.css.optimized.aggregated.css'), $this->dumperData);
|
||||
}
|
||||
|
||||
}
|
|
@ -99,8 +99,8 @@ class StorageComparerTest extends UnitTestCase {
|
|||
],
|
||||
],
|
||||
// Simple config.
|
||||
'system.performance' => [
|
||||
'stale_file_threshold' => 2592000,
|
||||
'system.logging' => [
|
||||
'error_level' => 'hide',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue