/** * @param string $patchDirectory * @return int */ protected function getPatchNumberSize($patchDirectory) { try { $iterator = new DirectoryIterator($patchDirectory); } catch (Exception $e) { $this->writer->error($e->getMessage()); return 4; } $filename = ''; foreach ($iterator as $fileinfo) { if ($fileinfo->isDot() || substr($fileinfo->getFilename(), 0, 1) == '.') { continue; } $filename = $fileinfo->getFilename(); break; } $pattern = '/(\d{3,4})./'; if (preg_match($pattern, $filename, $matches)) { return strlen($matches[1]); } return 4; }
protected function _createGroupProviderRow($groupProviderIdentifier, &$groupProviderConfig) { // Create base group provider record $statement = $this->_database->prepare("INSERT INTO group_provider (identifier, name, classname)\n VALUES (?,?,?)"); $params = array($groupProviderIdentifier, $groupProviderConfig['name'], $groupProviderConfig['className']); $result = $statement->execute($params); if ($result === false) { $this->_writer->error("Error occurred inserting the group provider, error code: " . var_export($statement->errorCode())); $this->_writer->error("Error info: " . print_r($statement->errorInfo(), true)); } unset($groupProviderConfig['name'], $groupProviderConfig['className']); return $this->_database->lastInsertId(); }
/** * Dump database * * @param string $filename * @return bool */ protected function dumpDatabase($filename) { try { $db = $this->getDb(); $db->dump($filename); } catch (Exception $e) { $this->writer->error($e->getMessage()); return false; } return true; }