class RemoveConsoleLog in Advanced CSS/JS Aggregation 8.4
Same name and namespace in other branches
- 8.3 advagg_mod/src/Asset/RemoveConsoleLog.php \Drupal\advagg_mod\Asset\RemoveConsoleLog
Remove console.log() calls from JavaScript Files.
Hierarchy
- class \Drupal\advagg_mod\Asset\RemoveConsoleLog
Expanded class hierarchy of RemoveConsoleLog
1 file declares its use of RemoveConsoleLog
- InitSubscriber.php in advagg_mod/
src/ EventSubscriber/ InitSubscriber.php
1 string reference to 'RemoveConsoleLog'
- advagg_mod.services.yml in advagg_mod/
advagg_mod.services.yml - advagg_mod/advagg_mod.services.yml
1 service uses RemoveConsoleLog
File
- advagg_mod/
src/ Asset/ RemoveConsoleLog.php, line 8
Namespace
Drupal\advagg_mod\AssetView source
class RemoveConsoleLog {
/**
* Scan asset contents for console.log() calls and remove them.
*
* @param string $contents
* The asset contents.
*
* @return string
* The updated contents.
*/
public function optimize($contents) {
$pattern = "/ console.log(.*)/";
return preg_replace_callback($pattern, [
$this,
'removeCallback',
], $contents);
}
/**
* Remove the console.log() call.
*
* @param array $matches
* Array of matches from preg_replace_callback().
*
* @return string
* Replaced string.
*/
protected function removeCallback(array $matches) {
return '';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RemoveConsoleLog:: |
public | function | Scan asset contents for console.log() calls and remove them. | |
RemoveConsoleLog:: |
protected | function | Remove the console.log() call. |