warning() public méthode

Write an warning messages
public warning ( string $message ) : DbPatch_Core_Writer
$message string
Résultat DbPatch_Core_Writer
Exemple #1
0
 /**
  * Store patchfile entry to the changelog table
  * 
  * @param array $patchFile
  * @param string $description
  * @return void
  */
 protected function addToChangelog($patchFile, $description = null)
 {
     if ($description == null) {
         $description = $patchFile->description;
     }
     if ($this->isPatchApplied($patchFile->patch_number, $patchFile->branch)) {
         $this->writer->warning(sprintf('Skip %s, already exists in the changelog', $patchFile->basename));
     } else {
         $db = $this->getDb();
         $sql = sprintf("\n                INSERT INTO %s (patch_number, branch, completed, filename, description, hash)\n                VALUES(%d, %s, NOW(), %s, %s, %s)", $db->quoteIdentifier(self::TABLE), $patchFile->patch_number, $db->quote($patchFile->branch), $db->quote($patchFile->basename), $db->quote($description), $db->quote($patchFile->hash));
         $db->query($sql);
         $db->commit();
         $this->writer->line(sprintf('added %s to the changelog ', $patchFile->basename));
     }
 }
 public function execute()
 {
     if (!file_exists(self::ENGINEBLOCK_LOCAL_CONFIG_FILE)) {
         $this->_writer->warning("Local config '" . self::ENGINEBLOCK_LOCAL_CONFIG_FILE . "'does not exist? Not doing anything");
         return;
     }
     $engineBlock = EngineBlock_ApplicationSingleton::getInstance();
     $configuration = $engineBlock->getConfiguration()->toArray();
     if (!isset($configuration['groupProviders'])) {
         $this->_writer->warning("No groupProviders found in INI file (already ran?). Not doing anything");
         return;
     }
     $fileLines = file(self::ENGINEBLOCK_LOCAL_CONFIG_FILE);
     foreach ($configuration['groupProviders'] as $groupProviderIdentifier) {
         if (!isset($configuration[$groupProviderIdentifier])) {
             $this->_writer->warning("GroupProvider '{$groupProviderIdentifier}' mentioned, but not found? Not processing...");
             continue;
         }
         // Remove configuration lines for this specific group provider
         foreach ($fileLines as $fileLineNumber => $fileLine) {
             $fileLine = trim($fileLine);
             if (strpos($fileLine, $groupProviderIdentifier . '.') === 0) {
                 unset($fileLines[$fileLineNumber]);
             }
         }
         $statement = $this->_database->prepare("SELECT COUNT(*) as counted FROM group_provider WHERE identifier = ?");
         $statement->execute(array($groupProviderIdentifier));
         $row = $statement->fetch(PDO::FETCH_ASSOC);
         if ((int) $row['counted'] > 0) {
             $this->_writer->warning("GroupProvider '{$groupProviderIdentifier}' already exists? Not processing...");
             continue;
         }
         $groupProviderConfig = $configuration[$groupProviderIdentifier];
         $groupProviderId = $this->_createGroupProviderRow($groupProviderIdentifier, $groupProviderConfig);
         if (!$groupProviderId) {
             $this->_writer->error("Unable to create the group provider?!? Last database error: " . var_export($this->_database->errorCode(), true) . var_export($this->_database->errorInfo(), true));
             return;
         }
         $this->_convertGroupProviderDecorators($groupProviderId, $groupProviderConfig);
         $this->_convertGroupProviderFilters('group', $groupProviderId, $groupProviderConfig);
         $this->_convertGroupProviderFilters('groupMember', $groupProviderId, $groupProviderConfig);
         $this->_convertGroupProviderPreconditions($groupProviderId, $groupProviderConfig);
         $this->_convertGroupProviderConfigToOptions($groupProviderId, $groupProviderConfig);
     }
     // Remove groupProviders. lines from configFile
     foreach ($fileLines as $fileLineNumber => $fileLine) {
         $fileLine = trim($fileLine);
         if (strpos($fileLine, 'groupProviders.') === 0 || strpos($fileLine, 'groupProviders[]') === 0) {
             unset($fileLines[$fileLineNumber]);
         }
     }
     // Output new config file
     $wroteFile = file_put_contents(self::ENGINEBLOCK_MODIFIED_CONFIG_FILE, implode($fileLines));
     if ($wroteFile === FALSE) {
         $this->_writer->warning('Unable to write back modified local config file to ' . self::ENGINEBLOCK_MODIFIED_CONFIG_FILE . ' please remove the group providers for the local config file manually!');
         return;
     }
     // Able to read and parse new INI file?
     $newLocalFileParsable = parse_ini_file(self::ENGINEBLOCK_LOCAL_CONFIG_FILE);
     if ($newLocalFileParsable === FALSE) {
         $this->_writer->warning("Wrote changed config file to " . self::ENGINEBLOCK_MODIFIED_CONFIG_FILE . ' but unable to parse the INI file after writing? Please manually repair this file and move this file over to ' . self::ENGINEBLOCK_LOCAL_CONFIG_FILE . ' or manually remove the group provider configuration from ' . self::ENGINEBLOCK_LOCAL_CONFIG_FILE);
         return;
     }
     $this->_writer->warning("Wrote changed config file to " . self::ENGINEBLOCK_MODIFIED_CONFIG_FILE);
     $this->_writer->warning('Please verify that this configuration file is correct (backup the old config file)');
     $this->_writer->warning('and move this file over to ' . self::ENGINEBLOCK_LOCAL_CONFIG_FILE);
 }