本文整理汇总了PHP中Minion_CLI类的典型用法代码示例。如果您正苦于以下问题:PHP Minion_CLI类的具体用法?PHP Minion_CLI怎么用?PHP Minion_CLI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Minion_CLI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _execute
protected function _execute(array $params)
{
$model = $params['model'];
$orm = ORM::factory($model);
$orm->send_search_mapping();
Minion_CLI::write('Search mapping for model ' . Minion_CLI::color($model, 'blue') . ' updated!');
}
示例2: modify_file
public static function modify_file($file, $content, $force = FALSE, $unlink = FALSE)
{
if ($unlink) {
$file_already_exists = is_file($file);
if ($file_already_exists) {
unlink($file);
Minion_CLI::write(Minion_CLI::color('Removed file ' . Debug::path($file), 'light_green'));
} else {
Minion_CLI::write(Minion_CLI::color('File does not exist ' . Debug::path($file), 'brown'));
}
} elseif ($force) {
$file_already_exists = is_file($file);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, TRUE);
}
file_put_contents($file, $content);
if ($file_already_exists) {
Minion_CLI::write(Minion_CLI::color('Overwritten file ' . Debug::path($file), 'brown'));
} else {
Minion_CLI::write(Minion_CLI::color('Generated file ' . Debug::path($file), 'light_green'));
}
} else {
if (is_file($file)) {
Minion_CLI::write(Minion_CLI::color('File already exists ' . Debug::path($file), 'brown'));
} else {
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0777, TRUE);
}
file_put_contents($file, $content);
Minion_CLI::write(Minion_CLI::color('Generated file ' . Debug::path($file), 'light_green'));
}
}
}
示例3: _execute
protected function _execute(array $params)
{
$vk = Vk::instance();
$user_ids = array();
$message = 'У вашего объявления обновился статус!';
$result = NULL;
try {
$user_ids = Utils::getNotifyUserIDs();
} catch (Database_Exception $e) {
Minion_CLI::write($e->getMessage());
return;
}
if (count($user_ids) == 0) {
Minion_CLI::write('no users');
return;
}
try {
$vk->login();
$result = $vk->api('secure.sendNotification', array('user_ids' => implode($user_ids, ','), 'message' => urlencode($message), 'client_secret' => $vk->config['VK_APP_SECRET']));
} catch (Kohana_Exception $e) {
Minion_CLI::write($e->getMessage());
return;
}
if (is_null($result)) {
Minion_CLI::write('wtf?');
return;
}
try {
Utils::uncheckUsersNotifyByIDs($user_ids);
} catch (Database_Exception $e) {
Minion_CLI::write($e->getMessage());
return;
}
Minion_CLI::write('done!');
}
示例4: _execute
protected function _execute(array $params)
{
$db = Database::instance(Database::$default);
Minion_CLI::write('Exporting table structure to structure.sql');
try {
$rows = $db->query(Database::SELECT, 'show tables', FALSE);
$tables = [];
$views = [];
foreach ($rows as $row) {
$table = reset($row);
$res = $db->query(Database::SELECT, 'show create table `' . $table . '`', FALSE);
$res = $res[0];
$schema = Arr::get($res, 'Create Table', NULL);
if ($schema === NULL) {
$schema = Arr::get($res, 'Create View', NULL);
$schema = preg_replace('#^CREATE.*VIEW `#U', 'CREATE VIEW `', $schema);
if ($schema === NULL) {
continue;
}
$views[] = $schema . ';';
continue;
}
$tables[] = $schema . ';';
}
file_put_contents(Migration::config('dump') . 'structure.sql', implode("\n\n", $tables) . "\n\n" . implode("\n\n", $views));
Minion_CLI::write('OK');
} catch (Exception $ex) {
Minion_CLI::write('ERROR: ' . $ex->getMessage());
}
}
示例5: _execute
/**
* Task to run pending migrations
*
* @return null
*/
protected function _execute(array $params)
{
$migrations = new MigrationManager();
Database::$default = $params['db'];
$this->db = Database::instance();
$db_config = Kohana::$config->load('database')->{$params['db']};
if (!ORM::factory('Migration')->is_installed()) {
/**
* Get platform from database config
*/
$platform = strtolower($db_config['type']);
if ('mysqli' == $platform) {
$platform = 'mysql';
}
/**
* Get SQL from file for selected platform
*/
$file = realpath(substr(__DIR__, 0, strlen(__DIR__) - strlen('classes/Task/Db')) . 'sql/' . $platform . '.sql');
$handle = fopen($file, 'rb');
$sql_create = fread($handle, filesize($file));
$this->db->query(0, $sql_create);
$msg = Minion_CLI::color("-----------------------------\n", 'green');
$msg .= Minion_CLI::color("| Migration table create!!! |\n", 'green');
$msg .= Minion_CLI::color("-----------------------------\n", 'green');
Minion_CLI::write($msg);
}
$migrations->migrate($params['db'], $params['step']);
}
示例6: execute
public function execute(array $options)
{
$db = $this->db_params($options['database']);
$file = $options['file'] ? $options['file'] : Kohana::$config->load("migrations.path") . DIRECTORY_SEPARATOR . 'schema.sql';
$command = strtr("mysqldump -u:username -p:password --skip-comments --add-drop-database --add-drop-table --no-data :database | sed 's/AUTO_INCREMENT=[0-9]*\\b//' > :file ", array(':username' => $db['username'], ':password' => $db['password'], ':database' => $db['database'], ':file' => $file));
Minion_CLI::write('Saving structure of database "' . $db['database'] . '" to ' . Debug::path($file), 'green');
system($command);
}
示例7: execute
/**
* Execute the task
*
* @param array Configuration
*/
public function execute(array $config)
{
try {
$file = $this->generate($config);
Minion_CLI::write('Migration generated: ' . $file);
} catch (ErrorException $e) {
Minion_CLI::write($e->getMessage());
}
}
示例8: _execute
/**
* Execute the task
*
* @param array $options Configuration
*/
protected function _execute(array $options)
{
try {
$file = $this->generate($options);
Minion_CLI::write('Migration generated: ' . $file);
} catch (ErrorException $e) {
Minion_CLI::write($e->getMessage());
}
}
示例9: _execute
/**
* Task to rollback last executed migration
*
* @return null
*/
protected function _execute(array $params)
{
$migrations = new MigrationManager();
Database::$default = $params['db'];
if (!ORM::factory('Migration')->is_installed()) {
Minion_CLI::write('Migrations is not installed. Please Run the migrations.sql script in your mysql server');
exit;
}
$migrations->rollback($params['db'], $params['step']);
}
示例10: _execute
protected function _execute(array $params)
{
if (!Migration::is_installed()) {
Migration::install();
}
if (Migration::generate($params['name'], $params['columns']) === TRUE) {
Minion_CLI::write('Migration \'' . $params['name'] . '\' was succefully created');
} else {
Minion_CLI::write('An error occured while creating migration \'' . $params['name'] . '\'');
}
}
示例11: execute
public function execute(array $options)
{
if ($options['force'] === NULL or 'yes' === Minion_CLI::read('This will destroy all data in the current database. Are you sure? [yes/NO]')) {
Minion_CLI::write('Dropping Tables', 'green');
$migrations = new Migrations(array('log' => 'Minion_CLI::write'));
$migrations->clear_all();
Minion_Task::factory('db:migrate')->execute($options);
} else {
Minion_CLI::write('Nothing done', 'brown');
}
}
示例12: increase_message_field_size
public function increase_message_field_size()
{
$db = Database::instance();
$cols = $db->list_columns($this->tbl);
if ($cols['message']['data_type'] != 'longtext') {
Minion_CLI::write("Increasing length of message field to LONGTEXT");
$msgcol = $db->quote_column('message');
$sql = "ALTER TABLE " . $db->quote_table($this->tbl) . " CHANGE {$msgcol} {$msgcol} LONGTEXT NOT NULL";
$db->query(NULL, $sql);
}
}
示例13: _execute
/**
* Task to build a new migration file
*
* @return null
*/
protected function _execute(array $params)
{
$migrations = new MigrationManager();
$status = $migrations->generate_migration($params['name']);
if ($status == 0) {
Minion_CLI::write('Migration ' . $params['name'] . ' was succefully created');
Minion_CLI::write('Please check migrations folder');
} else {
Minion_CLI::write('There was an error while creating migration ' . $params['name']);
}
}
示例14: _execute
/**
* Execute the task and copy the required files
*
* @param array $params the command options
*
* @return void
*/
protected function _execute(array $params)
{
// Identify the vendor and destination path
$vendor_path = $params['vendor-path'];
$public_path = $params['public-path'];
// Publish the twitter bootstrap js at DOCROOT/assets/js/twbs
$this->copy_files($vendor_path . '/twbs/bootstrap/js', '/\\.js$/', $public_path . '/js/twbs');
Minion_CLI::write(Minion_CLI::color('Published bootstrap javascripts to ' . $public_path . '/js/twbs', 'green'));
// Publish the font-awesome font files as DOCROOT/assets/font
$this->copy_files($vendor_path . '/fortawesome/font-awesome/font', '/^fontawesome/i', $public_path . '/font');
Minion_CLI::write(Minion_CLI::color('Published font-awesome font to ' . $public_path . '/font', 'green'));
}
示例15: _execute
protected function _execute(array $params)
{
if ($params['database'] > 0) {
Model_Backup::factory($params['folder'] . 'db-' . date('YmdHis') . '.sql')->create()->save();
Minion_CLI::write(__('Database backup created successfully'));
}
if ($params['filesystem'] > 0) {
if (Model_Backup::factory($params['folder'] . 'filesystem-' . date('YmdHis') . '.zip')->create()) {
Minion_CLI::write(__('Filesystem backup created successfully'));
}
}
}