diff options
Diffstat (limited to 'app/Console')
-rw-r--r-- | app/Console/BaseCommand.php | 37 | ||||
-rw-r--r-- | app/Console/PluginInstallCommand.php | 3 | ||||
-rw-r--r-- | app/Console/PluginUninstallCommand.php | 3 | ||||
-rw-r--r-- | app/Console/PluginUpgradeCommand.php | 3 | ||||
-rw-r--r-- | app/Console/ProjectDailyColumnStatsExportCommand.php | 2 | ||||
-rw-r--r-- | app/Console/ProjectDailyStatsCalculationCommand.php | 8 | ||||
-rw-r--r-- | app/Console/ResetPasswordCommand.php | 4 | ||||
-rw-r--r-- | app/Console/ResetTwoFactorCommand.php | 4 | ||||
-rw-r--r-- | app/Console/TaskOverdueNotificationCommand.php | 26 | ||||
-rw-r--r-- | app/Console/TaskTriggerCommand.php | 8 |
10 files changed, 51 insertions, 47 deletions
diff --git a/app/Console/BaseCommand.php b/app/Console/BaseCommand.php index ca566266..50417071 100644 --- a/app/Console/BaseCommand.php +++ b/app/Console/BaseCommand.php @@ -11,24 +11,25 @@ use Symfony\Component\Console\Command\Command; * @package console * @author Frederic Guillot * - * @property \Kanboard\Validator\PasswordResetValidator $passwordResetValidator - * @property \Kanboard\Export\SubtaskExport $subtaskExport - * @property \Kanboard\Export\TaskExport $taskExport - * @property \Kanboard\Export\TransitionExport $transitionExport - * @property \Kanboard\Model\Notification $notification - * @property \Kanboard\Model\Project $project - * @property \Kanboard\Model\ProjectPermission $projectPermission - * @property \Kanboard\Model\ProjectDailyColumnStats $projectDailyColumnStats - * @property \Kanboard\Model\ProjectDailyStats $projectDailyStats - * @property \Kanboard\Model\Task $task - * @property \Kanboard\Model\TaskFinder $taskFinder - * @property \Kanboard\Model\User $user - * @property \Kanboard\Model\UserNotification $userNotification - * @property \Kanboard\Model\UserNotificationFilter $userNotificationFilter - * @property \Kanboard\Model\ProjectUserRole $projectUserRole - * @property \Kanboard\Core\Plugin\Loader $pluginLoader - * @property \Kanboard\Core\Http\Client $httpClient - * @property \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher + * @property \Kanboard\Validator\PasswordResetValidator $passwordResetValidator + * @property \Kanboard\Export\SubtaskExport $subtaskExport + * @property \Kanboard\Export\TaskExport $taskExport + * @property \Kanboard\Export\TransitionExport $transitionExport + * @property \Kanboard\Model\NotificationModel $notificationModel + * @property \Kanboard\Model\ProjectModel $projectModel + * @property \Kanboard\Model\ProjectPermissionModel $projectPermissionModel + * @property \Kanboard\Model\ProjectDailyColumnStatsModel $projectDailyColumnStatsModel + * @property \Kanboard\Model\ProjectDailyStatsModel $projectDailyStatsModel + * @property \Kanboard\Model\TaskModel $taskModel + * @property \Kanboard\Model\TaskFinderModel $taskFinderModel + * @property \Kanboard\Model\UserModel $userModel + * @property \Kanboard\Model\UserNotificationModel $userNotificationModel + * @property \Kanboard\Model\UserNotificationFilterModel $userNotificationFilterModel + * @property \Kanboard\Model\ProjectUserRoleModel $projectUserRoleModel + * @property \Kanboard\Core\Plugin\Loader $pluginLoader + * @property \Kanboard\Core\Http\Client $httpClient + * @property \Kanboard\Core\Queue\QueueManager $queueManager + * @property \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher */ abstract class BaseCommand extends Command { diff --git a/app/Console/PluginInstallCommand.php b/app/Console/PluginInstallCommand.php index 1c6e14b3..a82f0069 100644 --- a/app/Console/PluginInstallCommand.php +++ b/app/Console/PluginInstallCommand.php @@ -4,6 +4,7 @@ namespace Kanboard\Console; use Kanboard\Core\Plugin\Installer; use Kanboard\Core\Plugin\PluginInstallerException; +use LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +22,7 @@ class PluginInstallCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { if (!Installer::isConfigured()) { - $output->writeln('<error>Kanboard is not configured to install plugins itself</error>'); + throw new LogicException('Kanboard is not configured to install plugins itself'); } try { diff --git a/app/Console/PluginUninstallCommand.php b/app/Console/PluginUninstallCommand.php index c645e03f..48722130 100644 --- a/app/Console/PluginUninstallCommand.php +++ b/app/Console/PluginUninstallCommand.php @@ -4,6 +4,7 @@ namespace Kanboard\Console; use Kanboard\Core\Plugin\Installer; use Kanboard\Core\Plugin\PluginInstallerException; +use LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +22,7 @@ class PluginUninstallCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { if (!Installer::isConfigured()) { - $output->writeln('<error>Kanboard is not configured to remove plugins itself</error>'); + throw new LogicException('Kanboard is not configured to install plugins itself'); } try { diff --git a/app/Console/PluginUpgradeCommand.php b/app/Console/PluginUpgradeCommand.php index 839124b1..6c66e917 100644 --- a/app/Console/PluginUpgradeCommand.php +++ b/app/Console/PluginUpgradeCommand.php @@ -5,6 +5,7 @@ namespace Kanboard\Console; use Kanboard\Core\Plugin\Base as BasePlugin; use Kanboard\Core\Plugin\Directory; use Kanboard\Core\Plugin\Installer; +use LogicException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +22,7 @@ class PluginUpgradeCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { if (!Installer::isConfigured()) { - $output->writeln('<error>Kanboard is not configured to upgrade plugins itself</error>'); + throw new LogicException('Kanboard is not configured to install plugins itself'); } $installer = new Installer($this->container); diff --git a/app/Console/ProjectDailyColumnStatsExportCommand.php b/app/Console/ProjectDailyColumnStatsExportCommand.php index ced1a374..1e8af727 100644 --- a/app/Console/ProjectDailyColumnStatsExportCommand.php +++ b/app/Console/ProjectDailyColumnStatsExportCommand.php @@ -21,7 +21,7 @@ class ProjectDailyColumnStatsExportCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { - $data = $this->projectDailyColumnStats->getAggregatedMetrics( + $data = $this->projectDailyColumnStatsModel->getAggregatedMetrics( $input->getArgument('project_id'), $input->getArgument('start_date'), $input->getArgument('end_date') diff --git a/app/Console/ProjectDailyStatsCalculationCommand.php b/app/Console/ProjectDailyStatsCalculationCommand.php index 5b898f02..8dde8a79 100644 --- a/app/Console/ProjectDailyStatsCalculationCommand.php +++ b/app/Console/ProjectDailyStatsCalculationCommand.php @@ -2,7 +2,7 @@ namespace Kanboard\Console; -use Kanboard\Model\Project; +use Kanboard\Model\ProjectModel; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -17,12 +17,12 @@ class ProjectDailyStatsCalculationCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { - $projects = $this->project->getAllByStatus(Project::ACTIVE); + $projects = $this->projectModel->getAllByStatus(ProjectModel::ACTIVE); foreach ($projects as $project) { $output->writeln('Run calculation for '.$project['name']); - $this->projectDailyColumnStats->updateTotals($project['id'], date('Y-m-d')); - $this->projectDailyStats->updateTotals($project['id'], date('Y-m-d')); + $this->projectDailyColumnStatsModel->updateTotals($project['id'], date('Y-m-d')); + $this->projectDailyStatsModel->updateTotals($project['id'], date('Y-m-d')); } } } diff --git a/app/Console/ResetPasswordCommand.php b/app/Console/ResetPasswordCommand.php index 93dc3761..b483f902 100644 --- a/app/Console/ResetPasswordCommand.php +++ b/app/Console/ResetPasswordCommand.php @@ -60,14 +60,14 @@ class ResetPasswordCommand extends BaseCommand private function resetPassword(OutputInterface $output, $username, $password) { - $userId = $this->user->getIdByUsername($username); + $userId = $this->userModel->getIdByUsername($username); if (empty($userId)) { $output->writeln('<error>User not found</error>'); return false; } - if (!$this->user->update(array('id' => $userId, 'password' => $password))) { + if (!$this->userModel->update(array('id' => $userId, 'password' => $password))) { $output->writeln('<error>Unable to update password</error>'); return false; } diff --git a/app/Console/ResetTwoFactorCommand.php b/app/Console/ResetTwoFactorCommand.php index 3bf01e81..a64206b6 100644 --- a/app/Console/ResetTwoFactorCommand.php +++ b/app/Console/ResetTwoFactorCommand.php @@ -19,14 +19,14 @@ class ResetTwoFactorCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { $username = $input->getArgument('username'); - $userId = $this->user->getIdByUsername($username); + $userId = $this->userModel->getIdByUsername($username); if (empty($userId)) { $output->writeln('<error>User not found</error>'); return false; } - if (!$this->user->update(array('id' => $userId, 'twofactor_activated' => 0, 'twofactor_secret' => ''))) { + if (!$this->userModel->update(array('id' => $userId, 'twofactor_activated' => 0, 'twofactor_secret' => ''))) { $output->writeln('<error>Unable to update user profile</error>'); return false; } diff --git a/app/Console/TaskOverdueNotificationCommand.php b/app/Console/TaskOverdueNotificationCommand.php index 7e8484c8..225a6a1a 100644 --- a/app/Console/TaskOverdueNotificationCommand.php +++ b/app/Console/TaskOverdueNotificationCommand.php @@ -2,7 +2,7 @@ namespace Kanboard\Console; -use Kanboard\Model\Task; +use Kanboard\Model\TaskModel; use Kanboard\Core\Security\Role; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; @@ -65,10 +65,10 @@ class TaskOverdueNotificationCommand extends BaseCommand */ public function sendGroupOverdueTaskNotifications() { - $tasks = $this->taskFinder->getOverdueTasks(); + $tasks = $this->taskFinderModel->getOverdueTasks(); foreach ($this->groupByColumn($tasks, 'owner_id') as $user_tasks) { - $users = $this->userNotification->getUsersWithNotificationEnabled($user_tasks[0]['project_id']); + $users = $this->userNotificationModel->getUsersWithNotificationEnabled($user_tasks[0]['project_id']); foreach ($users as $user) { $this->sendUserOverdueTaskNotifications($user, $user_tasks); @@ -85,14 +85,14 @@ class TaskOverdueNotificationCommand extends BaseCommand */ public function sendOverdueTaskNotificationsToManagers() { - $tasks = $this->taskFinder->getOverdueTasks(); + $tasks = $this->taskFinderModel->getOverdueTasks(); foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) { - $users = $this->userNotification->getUsersWithNotificationEnabled($project_id); + $users = $this->userNotificationModel->getUsersWithNotificationEnabled($project_id); $managers = array(); foreach ($users as $user) { - $role = $this->projectUserRole->getUserRole($project_id, $user['id']); + $role = $this->projectUserRoleModel->getUserRole($project_id, $user['id']); if($role == Role::PROJECT_MANAGER) { $managers[] = $user; } @@ -113,10 +113,10 @@ class TaskOverdueNotificationCommand extends BaseCommand */ public function sendOverdueTaskNotifications() { - $tasks = $this->taskFinder->getOverdueTasks(); + $tasks = $this->taskFinderModel->getOverdueTasks(); foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) { - $users = $this->userNotification->getUsersWithNotificationEnabled($project_id); + $users = $this->userNotificationModel->getUsersWithNotificationEnabled($project_id); foreach ($users as $user) { $this->sendUserOverdueTaskNotifications($user, $project_tasks); @@ -139,16 +139,16 @@ class TaskOverdueNotificationCommand extends BaseCommand $project_names = array(); foreach ($tasks as $task) { - if ($this->userNotificationFilter->shouldReceiveNotification($user, array('task' => $task))) { + if ($this->userNotificationFilterModel->shouldReceiveNotification($user, array('task' => $task))) { $user_tasks[] = $task; $project_names[$task['project_id']] = $task['project_name']; } } if (! empty($user_tasks)) { - $this->userNotification->sendUserNotification( + $this->userNotificationModel->sendUserNotification( $user, - Task::EVENT_OVERDUE, + TaskModel::EVENT_OVERDUE, array('tasks' => $user_tasks, 'project_name' => implode(", ", $project_names)) ); } @@ -163,9 +163,9 @@ class TaskOverdueNotificationCommand extends BaseCommand */ public function sendUserOverdueTaskNotificationsToManagers(array $manager, array $tasks) { - $this->userNotification->sendUserNotification( + $this->userNotificationModel->sendUserNotification( $manager, - Task::EVENT_OVERDUE, + TaskModel::EVENT_OVERDUE, array('tasks' => $tasks, 'project_name' => $tasks[0]['project_name']) ); } diff --git a/app/Console/TaskTriggerCommand.php b/app/Console/TaskTriggerCommand.php index 9e9554f9..a1f4dccf 100644 --- a/app/Console/TaskTriggerCommand.php +++ b/app/Console/TaskTriggerCommand.php @@ -4,7 +4,7 @@ namespace Kanboard\Console; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Kanboard\Model\Task; +use Kanboard\Model\TaskModel; use Kanboard\Event\TaskListEvent; class TaskTriggerCommand extends BaseCommand @@ -19,7 +19,7 @@ class TaskTriggerCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { foreach ($this->getProjectIds() as $project_id) { - $tasks = $this->taskFinder->getAll($project_id); + $tasks = $this->taskFinderModel->getAll($project_id); $nb_tasks = count($tasks); if ($nb_tasks > 0) { @@ -31,7 +31,7 @@ class TaskTriggerCommand extends BaseCommand private function getProjectIds() { - $listeners = $this->dispatcher->getListeners(Task::EVENT_DAILY_CRONJOB); + $listeners = $this->dispatcher->getListeners(TaskModel::EVENT_DAILY_CRONJOB); $project_ids = array(); foreach ($listeners as $listener) { @@ -46,6 +46,6 @@ class TaskTriggerCommand extends BaseCommand $event = new TaskListEvent(array('project_id' => $project_id)); $event->setTasks($tasks); - $this->dispatcher->dispatch(Task::EVENT_DAILY_CRONJOB, $event); + $this->dispatcher->dispatch(TaskModel::EVENT_DAILY_CRONJOB, $event); } } |