Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb2623e
commit 7e26eef
Showing
6 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\Mailmagik\Console; | ||
|
||
use Kanboard\Plugin\Mailmagik\Helper\MailHelper; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class Command extends \Kanboard\Console\BaseCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('mailmagik:fetchmail') // Name for the commandline | ||
->setDescription('Trigger Mailmagik mail fetching by automatic actions') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$command = 'projects:fetchmail'; | ||
|
||
$job = $this->getApplication()->find($command); | ||
$job->run(new ArrayInput(array('command' => $command)), new NullOutput()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\Mailmagik\Console; | ||
|
||
use Kanboard\Console\BaseCommand; | ||
use Kanboard\Event\GenericEvent; | ||
use Kanboard\Plugin\Mailmagik\Helper\MailHelper; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class FetchMail extends BaseCommand | ||
{ | ||
public const EVENT = MailHelper::EVENT_FETCHMAIL; | ||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName('projects:fetchmail') | ||
->setDescription('Trigger scheduler event for all tasks'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
foreach ($this->getProjectIds() as $project_id) { | ||
$this->dispatcher->dispatch( | ||
self::EVENT, | ||
new GenericEvent(array('project_id' => $project_id)) | ||
); | ||
} | ||
} | ||
|
||
private function getProjectIds() | ||
{ | ||
$listeners = $this->dispatcher->getListeners(self::EVENT); | ||
$project_ids = array(); | ||
|
||
foreach ($listeners as $listener) { | ||
$project_ids[] = $listener[0]->getProjectId(); | ||
} | ||
|
||
return array_unique($project_ids); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters