Same name and namespace in other branches
  1. 5.0.x advagg_mod/src/Asset/RemoveConsoleLog.php \Drupal\advagg_mod\Asset\RemoveConsoleLog 1 commentaire
  2. 8.x-3.x advagg_mod/src/Asset/RemoveConsoleLog.php \Drupal\advagg_mod\Asset\RemoveConsoleLog 1 commentaire
  3. 8.x-4.x advagg_mod/src/Asset/RemoveConsoleLog.php \Drupal\advagg_mod\Asset\RemoveConsoleLog 1 commentaire

Remove console.log() calls from JavaScript Files.

Hierarchy

Expanded class hierarchy of RemoveConsoleLog

1 file declares its use of RemoveConsoleLog
InitSubscriber.php dans advagg_mod/src/EventSubscriber/InitSubscriber.php
2 string references to 'RemoveConsoleLog'
advagg_mod.services.yml dans advagg_mod/advagg_mod.services.yml
advagg_mod/advagg_mod.services.yml
InitSubscriber::getSubscribedEvents dans advagg_mod/src/EventSubscriber/InitSubscriber.php
1 service uses RemoveConsoleLog
advagg_mod.remove_console_log dans advagg_mod/advagg_mod.services.yml
Drupal\advagg_mod\Asset\RemoveConsoleLog

Fichier

advagg_mod/src/Asset/RemoveConsoleLog.php, line 8

Namespace

Drupal\advagg_mod\Asset
View 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

Titre Trier par ordre décroissant Modifiers Object type Résumé
RemoveConsoleLog::optimize public function Scan asset contents for console.log() calls and remove them.
RemoveConsoleLog::removeCallback protected function Remove the console.log() call.