コード例 #1
0
ファイル: Routine.php プロジェクト: nickimproove/magento2
 /**
  * Entry point of routine work
  *
  * @static
  * @param string $workingDir
  * @param array $config
  * @param array $blackList
  * @return null
  */
 public static function run($workingDir, $config, $blackList)
 {
     // various display parameters
     $workingDir = realpath($workingDir);
     self::$_workingDirLen = strlen($workingDir);
     self::$_errorsCount = 0;
     self::$_updatedCount = 0;
     self::$_skippedCount = 0;
     // set black list
     self::$skipFiles = array();
     self::$skipDirectories = array();
     self::_setSkippedPaths($workingDir, $blackList);
     $licenseInstances = array();
     foreach ($config as $path => $types) {
         // whether to scan directory recursively
         $recursive = isset($types['_recursive']) ? $types['_recursive'] : true;
         unset($types['_recursive']);
         // update licenses
         foreach ($types as $fileType => $licenseType) {
             if (!isset($licenseInstances[$licenseType])) {
                 $licenseInstances[$licenseType] = Routine::createLicenseInstance($licenseType);
             }
             Routine::updateLicense(array($workingDir . ($path ? DIRECTORY_SEPARATOR . $path : '')), Routine::$fileTypes[$fileType], $licenseInstances[$licenseType], $recursive);
         }
     }
     Routine::printLog(sprintf("\n" . 'Updated: %d; Skipped: %d; Errors: %d.' . "\n", self::$_updatedCount, self::$_skippedCount, self::$_errorsCount));
     if (self::$_errorsCount || self::$_skippedCount) {
         throw new Exception('Failed: check skipped files or errors.' . "\n");
     }
     Routine::printLog('Success.' . "\n");
 }