-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pretty much all indentation related.
- Loading branch information
Patrick McLain
committed
Jan 14, 2018
1 parent
7e72c98
commit be692d0
Showing
21 changed files
with
567 additions
and
523 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
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 |
---|---|---|
@@ -1,79 +1,82 @@ | ||
<?php | ||
|
||
namespace EthanYehuda\CronjobManager\Command; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
use EthanYehuda\CronjobManager\Model\ManagerFactory; | ||
use \Magento\Framework\App\State; | ||
use \Magento\Framework\Console\Cli; | ||
use \Magento\Framework\Stdlib\DateTime\DateTimeFactory; | ||
use Magento\Framework\App\State; | ||
use Magento\Framework\Console\Cli; | ||
use Magento\Framework\Stdlib\DateTime\DateTimeFactory; | ||
|
||
class Runjob extends Command | ||
{ | ||
const INPUT_KEY_JOB_CODE = 'job_code'; | ||
|
||
/** | ||
* @var ManagerFactory $managerFactory | ||
*/ | ||
private $managerFactory; | ||
|
||
/** | ||
* @var \Magento\Framework\App\State $state | ||
*/ | ||
private $state; | ||
|
||
/** | ||
* @var DateTimeFactory $dateTimeFactory | ||
*/ | ||
private $dateTimeFactory; | ||
|
||
public function __construct( | ||
State $state, | ||
ManagerFactory $managerFactory, | ||
DateTimeFactory $dateTimeFactory | ||
) { | ||
$this->managerFactory = $managerFactory; | ||
$this->state = $state; | ||
$this->dateTimeFactory = $dateTimeFactory; | ||
parent::__construct(); | ||
} | ||
protected function configure() | ||
{ | ||
$arguments = [ | ||
new InputArgument( | ||
self::INPUT_KEY_JOB_CODE, | ||
InputArgument::REQUIRED, | ||
'Job code input (ex. \'sitemap_generate\')' | ||
) | ||
]; | ||
|
||
$this->setName("cronmanager:runjob"); | ||
$this->setDescription("Run a specific cron job by its job_code "); | ||
$this->setDefinition($arguments); | ||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$manager = $this->managerFactory->create(); | ||
$dateTime = $this->dateTimeFactory->create(); | ||
const INPUT_KEY_JOB_CODE = 'job_code'; | ||
|
||
/** | ||
* @var ManagerFactory $managerFactory | ||
*/ | ||
private $managerFactory; | ||
|
||
/** | ||
* @var \Magento\Framework\App\State $state | ||
*/ | ||
private $state; | ||
|
||
/** | ||
* @var DateTimeFactory $dateTimeFactory | ||
*/ | ||
private $dateTimeFactory; | ||
|
||
public function __construct( | ||
State $state, | ||
ManagerFactory $managerFactory, | ||
DateTimeFactory $dateTimeFactory | ||
) { | ||
$this->managerFactory = $managerFactory; | ||
$this->state = $state; | ||
$this->dateTimeFactory = $dateTimeFactory; | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$arguments = [ | ||
new InputArgument( | ||
self::INPUT_KEY_JOB_CODE, | ||
InputArgument::REQUIRED, | ||
'Job code input (ex. \'sitemap_generate\')' | ||
) | ||
]; | ||
|
||
$this->setName("cronmanager:runjob"); | ||
$this->setDescription("Run a specific cron job by its job_code "); | ||
$this->setDefinition($arguments); | ||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$manager = $this->managerFactory->create(); | ||
$dateTime = $this->dateTimeFactory->create(); | ||
|
||
try { | ||
$this->state->setAreaCode('adminhtml'); | ||
|
||
// lets create a new cron job and dispatch it | ||
$jobCode = $input->getArgument(self::INPUT_KEY_JOB_CODE); | ||
$now = strftime('%Y-%m-%dT%H:%M:%S', $dateTime->gmtTimestamp()); | ||
|
||
try { | ||
$this->state->setAreaCode('adminhtml'); | ||
|
||
// lets create a new cron job and dispatch it | ||
$jobCode = $input->getArgument(self::INPUT_KEY_JOB_CODE); | ||
$now = strftime('%Y-%m-%dT%H:%M:%S', $dateTime->gmtTimestamp()); | ||
|
||
$schedule = $manager->createCronJob($jobCode, $now); | ||
$manager->dispatchCron(null, $jobCode, $schedule); | ||
$output->writeln("$jobCode successfully ran"); | ||
return Cli::RETURN_SUCCESS; | ||
} catch (\Magento\Framework\Exception\LocalizedException $e) { | ||
$output->writeln($e->getMessage()); | ||
return Cli::RETURN_FAILURE; | ||
} | ||
} | ||
$schedule = $manager->createCronJob($jobCode, $now); | ||
$manager->dispatchCron(null, $jobCode, $schedule); | ||
$output->writeln("$jobCode successfully ran"); | ||
return Cli::RETURN_SUCCESS; | ||
} catch (\Magento\Framework\Exception\LocalizedException $e) { | ||
$output->writeln($e->getMessage()); | ||
return Cli::RETURN_FAILURE; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.