Permalink
Browse files

Merge branch 'master' of git://github.com/trevormorse/frapi into console

  • Loading branch information...
2 parents 7b0e215 + 2ac3ca9 commit d6c832bc5de3754d85903592c67d6d191904814a David Coallier committed Jul 30, 2010
@@ -190,7 +190,35 @@ public function editAction()
*/
public function deleteAction()
{
- fwrite(STDOUT, 'deleteAction has not been implemented yet.' . PHP_EOL);
+ fwrite(STDOUT, 'Which action would you like to delete? ' . PHP_EOL);
+
+ $model = new Default_Model_Action();
+ $actions = $model->getAll();
+
+ $max_action = 0;
+ $action_to_delete = null;
+ while (!in_array($action_to_delete, array_keys($actions), true)) {
+ foreach ($actions as $key => $action) {
+ fwrite(STDOUT, $key . ' - ' . $action['name'] . PHP_EOL);
+ $max_action = $key;
+ }
+ fwrite(STDOUT, '(0 - ' . $max_action . '): ');
+ $action_to_delete = (int)trim(fgets(STDIN));
+ }
+
+ $confirm = '';
+ while (!in_array($confirm, $this->yes_no_values)) {
+ fwrite(STDOUT, 'Are you sure you want to delete ' . $actions[$action_to_delete]['name'] . '(y/n):');
+ $confirm = trim(strtolower(fgets(STDIN)));
+ }
+
+ if ($confirm == 'y') {
+ $hash = $actions[$action_to_delete]['hash'];
+ if ($hash) {
+ $model->delete($hash);
+ fwrite(STDOUT, $actions[$action_to_delete]['name'] . ' was deleted successfully.' . PHP_EOL);
+ }
+ }
}
/**
@@ -202,7 +230,20 @@ public function deleteAction()
*/
public function syncAction()
{
- fwrite(STDOUT, 'syncAction has not been implemented yet.' . PHP_EOL);
+ $dir = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'Action';
+
+ if (!is_writable($dir)) {
+ fwrite(STDOUT, 'The path : "' . $dir .
+ '" is not currently writeable by this user, ' .
+ 'therefore we cannot synchronize the codebase' . PHP_EOL
+ );
+ return;
+ }
+
+ $model = new Default_Model_Action();
+ $model->sync();
+
+ fwrite(STDOUT, 'All actions have been synced successfully.' . PHP_EOL);
}
/**
@@ -52,7 +52,7 @@
'delete-action' => 'ActionController::deleteAction',
'edit-action' => 'ActionController::editAction',
'test-action' => 'ActionController::testAction',
- 'sync-action' => 'ActionController::syncAction',
+ 'sync-actions' => 'ActionController::syncAction',
'exit' => '',
);
ini_set('display_errors', 'On');

0 comments on commit d6c832b

Please sign in to comment.