Same name in other branches
- 5.0.x advagg_mod/src/Asset/RemoveConsoleLog.php \Drupal\advagg_mod\Asset\RemoveConsoleLog
- 6.0.x advagg_mod/src/Asset/RemoveConsoleLog.php \Drupal\advagg_mod\Asset\RemoveConsoleLog
- 8.x-4.x 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
2 string references to 'RemoveConsoleLog'
- advagg_mod.services.yml in advagg_mod/
advagg_mod.services.yml - advagg_mod/advagg_mod.services.yml
- InitSubscriber::getSubscribedEvents in advagg_mod/
src/ EventSubscriber/ InitSubscriber.php
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
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
RemoveConsoleLog::optimize | public | function | Scan asset contents for console.log() calls and remove them. |
RemoveConsoleLog::removeCallback | protected | function | Remove the console.log() call. |