-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1601 from magento-engcom/2.1-develop-prs
[EngCom] Public Pull Requests - 2.1-develop
- Loading branch information
Showing
15 changed files
with
890 additions
and
6 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
79 changes: 79 additions & 0 deletions
79
app/code/Magento/Cron/Console/Command/CronInstallCommand.php
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,79 @@ | ||
<?php | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Cron\Console\Command; | ||
|
||
use Magento\Framework\Crontab\CrontabManagerInterface; | ||
use Magento\Framework\Crontab\TasksProviderInterface; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Magento\Framework\Console\Cli; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
/** | ||
* CronInstallCommand installs Magento cron tasks | ||
*/ | ||
class CronInstallCommand extends Command | ||
{ | ||
/** | ||
* @var CrontabManagerInterface | ||
*/ | ||
private $crontabManager; | ||
|
||
/** | ||
* @var TasksProviderInterface | ||
*/ | ||
private $tasksProvider; | ||
|
||
/** | ||
* @param CrontabManagerInterface $crontabManager | ||
* @param TasksProviderInterface $tasksProvider | ||
*/ | ||
public function __construct( | ||
CrontabManagerInterface $crontabManager, | ||
TasksProviderInterface $tasksProvider | ||
) { | ||
$this->crontabManager = $crontabManager; | ||
$this->tasksProvider = $tasksProvider; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->setName('cron:install') | ||
->setDescription('Generates and installs crontab for current user') | ||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install tasks'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
if ($this->crontabManager->getTasks() && !$input->getOption('force')) { | ||
$output->writeln('<error>Crontab has already been generated and saved</error>'); | ||
return Cli::RETURN_FAILURE; | ||
} | ||
|
||
try { | ||
$this->crontabManager->saveTasks($this->tasksProvider->getTasks()); | ||
} catch (LocalizedException $e) { | ||
$output->writeln('<error>' . $e->getMessage() . '</error>'); | ||
return Cli::RETURN_FAILURE; | ||
} | ||
|
||
$output->writeln('<info>Crontab has been generated and saved</info>'); | ||
|
||
return Cli::RETURN_SUCCESS; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
app/code/Magento/Cron/Console/Command/CronRemoveCommand.php
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,62 @@ | ||
<?php | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Cron\Console\Command; | ||
|
||
use Magento\Framework\Crontab\CrontabManagerInterface; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Magento\Framework\Console\Cli; | ||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
/** | ||
* CronRemoveCommand removes Magento cron tasks | ||
*/ | ||
class CronRemoveCommand extends Command | ||
{ | ||
/** | ||
* @var CrontabManagerInterface | ||
*/ | ||
private $crontabManager; | ||
|
||
/** | ||
* @param CrontabManagerInterface $crontabManager | ||
*/ | ||
public function __construct(CrontabManagerInterface $crontabManager) | ||
{ | ||
$this->crontabManager = $crontabManager; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->setName('cron:remove') | ||
->setDescription('Removes tasks from crontab'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
try { | ||
$this->crontabManager->removeTasks(); | ||
} catch (LocalizedException $e) { | ||
$output->writeln('<error>' . $e->getMessage() . '</error>'); | ||
return Cli::RETURN_FAILURE; | ||
} | ||
|
||
$output->writeln('<info>Magento cron tasks have been removed</info>'); | ||
|
||
return Cli::RETURN_SUCCESS; | ||
} | ||
} |
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
Oops, something went wrong.