Themsaid\Langman\Manager::getAllViewFilesWithTranslations PHP Méthode

getAllViewFilesWithTranslations() public méthode

e.g. ['users.blade.php' => ['users.name'], 'users/index.blade.php' => ['users.phone', 'users.city']]
    public function getAllViewFilesWithTranslations()
    {
        /*
         * This pattern is derived from Barryvdh\TranslationManager by Barry vd. Heuvel <[email protected]>
         *
         * https://github.com/barryvdh/laravel-translation-manager/blob/master/src/Manager.php
         */
        $functions = ['trans', 'trans_choice', 'Lang::get', 'Lang::choice', 'Lang::trans', 'Lang::transChoice', '@lang', '@choice'];
        $pattern = '[^\\w]' . '(?<!->)' . '(' . implode('|', $functions) . ')' . "\\(" . "[\\'\"]" . '(' . '[a-zA-Z0-9_-]+' . "([.][^)]+)+" . ')' . "[\\'\"]" . "[\\),]";
        $allMatches = [];
        /** @var \Symfony\Component\Finder\SplFileInfo $file */
        foreach ($this->disk->allFiles($this->syncPaths) as $file) {
            if (preg_match_all("/{$pattern}/siU", $file->getContents(), $matches)) {
                $allMatches[$file->getRelativePathname()] = $matches[2];
            }
        }
        return $allMatches;
    }

Usage Example

 /**
  * Get an array of application files containing the old key.
  *
  * @return array
  */
 private function getFilesContainingOldKey()
 {
     $affectedFiles = [];
     foreach ($this->manager->getAllViewFilesWithTranslations() as $file => $keys) {
         foreach ($keys as $key) {
             if ($key == $this->argument('oldKey')) {
                 $affectedFiles[$file][] = $key;
             }
         }
     }
     return $affectedFiles;
 }