Skip to content

Commit 13d3888

Browse files
authored
Merge pull request #1601 from magento-engcom/2.1-develop-prs
[EngCom] Public Pull Requests - 2.1-develop
2 parents ced998f + eff2592 commit 13d3888

File tree

15 files changed

+890
-6
lines changed

15 files changed

+890
-6
lines changed

app/code/Magento/Cron/Console/Command/CronCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Cron\Console\Command;
87

98
use Symfony\Component\Console\Command\Command;
@@ -94,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9493
}
9594
}
9695
/** @var \Magento\Framework\App\Cron $cronObserver */
97-
$cronObserver = $objectManager->create('Magento\Framework\App\Cron', ['parameters' => $params]);
96+
$cronObserver = $objectManager->create(\Magento\Framework\App\Cron::class, ['parameters' => $params]);
9897
$cronObserver->launch();
9998
$output->writeln('<info>' . 'Ran jobs by schedule.' . '</info>');
10099
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cron\Console\Command;
7+
8+
use Magento\Framework\Crontab\CrontabManagerInterface;
9+
use Magento\Framework\Crontab\TasksProviderInterface;
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Symfony\Component\Console\Command\Command;
12+
use Symfony\Component\Console\Input\InputInterface;
13+
use Symfony\Component\Console\Output\OutputInterface;
14+
use Magento\Framework\Console\Cli;
15+
use Symfony\Component\Console\Input\InputOption;
16+
17+
/**
18+
* CronInstallCommand installs Magento cron tasks
19+
*/
20+
class CronInstallCommand extends Command
21+
{
22+
/**
23+
* @var CrontabManagerInterface
24+
*/
25+
private $crontabManager;
26+
27+
/**
28+
* @var TasksProviderInterface
29+
*/
30+
private $tasksProvider;
31+
32+
/**
33+
* @param CrontabManagerInterface $crontabManager
34+
* @param TasksProviderInterface $tasksProvider
35+
*/
36+
public function __construct(
37+
CrontabManagerInterface $crontabManager,
38+
TasksProviderInterface $tasksProvider
39+
) {
40+
$this->crontabManager = $crontabManager;
41+
$this->tasksProvider = $tasksProvider;
42+
43+
parent::__construct();
44+
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
protected function configure()
50+
{
51+
$this->setName('cron:install')
52+
->setDescription('Generates and installs crontab for current user')
53+
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install tasks');
54+
55+
parent::configure();
56+
}
57+
58+
/**
59+
* {@inheritdoc}
60+
*/
61+
protected function execute(InputInterface $input, OutputInterface $output)
62+
{
63+
if ($this->crontabManager->getTasks() && !$input->getOption('force')) {
64+
$output->writeln('<error>Crontab has already been generated and saved</error>');
65+
return Cli::RETURN_FAILURE;
66+
}
67+
68+
try {
69+
$this->crontabManager->saveTasks($this->tasksProvider->getTasks());
70+
} catch (LocalizedException $e) {
71+
$output->writeln('<error>' . $e->getMessage() . '</error>');
72+
return Cli::RETURN_FAILURE;
73+
}
74+
75+
$output->writeln('<info>Crontab has been generated and saved</info>');
76+
77+
return Cli::RETURN_SUCCESS;
78+
}
79+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cron\Console\Command;
7+
8+
use Magento\Framework\Crontab\CrontabManagerInterface;
9+
use Symfony\Component\Console\Command\Command;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
use Magento\Framework\Console\Cli;
13+
use Magento\Framework\Exception\LocalizedException;
14+
15+
/**
16+
* CronRemoveCommand removes Magento cron tasks
17+
*/
18+
class CronRemoveCommand extends Command
19+
{
20+
/**
21+
* @var CrontabManagerInterface
22+
*/
23+
private $crontabManager;
24+
25+
/**
26+
* @param CrontabManagerInterface $crontabManager
27+
*/
28+
public function __construct(CrontabManagerInterface $crontabManager)
29+
{
30+
$this->crontabManager = $crontabManager;
31+
32+
parent::__construct();
33+
}
34+
35+
/**
36+
* {@inheritdoc}
37+
*/
38+
protected function configure()
39+
{
40+
$this->setName('cron:remove')
41+
->setDescription('Removes tasks from crontab');
42+
43+
parent::configure();
44+
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
protected function execute(InputInterface $input, OutputInterface $output)
50+
{
51+
try {
52+
$this->crontabManager->removeTasks();
53+
} catch (LocalizedException $e) {
54+
$output->writeln('<error>' . $e->getMessage() . '</error>');
55+
return Cli::RETURN_FAILURE;
56+
}
57+
58+
$output->writeln('<info>Magento cron tasks have been removed</info>');
59+
60+
return Cli::RETURN_SUCCESS;
61+
}
62+
}

app/code/Magento/Cron/etc/di.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<preference for="Magento\Cron\Model\ConfigInterface" type="Magento\Cron\Model\Config" />
1010
<preference for="Magento\Framework\Shell\CommandRendererInterface" type="Magento\Framework\Shell\CommandRenderer" />
11+
<preference for="Magento\Framework\Crontab\CrontabManagerInterface" type="Magento\Framework\Crontab\CrontabManager" />
12+
<preference for="Magento\Framework\Crontab\TasksProviderInterface" type="Magento\Framework\Crontab\TasksProvider" />
1113
<type name="Magento\Cron\Model\Config\Reader\Db">
1214
<arguments>
1315
<argument name="defaultReader" xsi:type="object">DefaultScopeReader</argument>
@@ -33,6 +35,8 @@
3335
<arguments>
3436
<argument name="commands" xsi:type="array">
3537
<item name="cronCommand" xsi:type="object">Magento\Cron\Console\Command\CronCommand</item>
38+
<item name="cronInstall" xsi:type="object">Magento\Cron\Console\Command\CronInstallCommand</item>
39+
<item name="cronRemove" xsi:type="object">Magento\Cron\Console\Command\CronRemoveCommand</item>
3640
</argument>
3741
</arguments>
3842
</type>
@@ -43,4 +47,24 @@
4347
</argument>
4448
</arguments>
4549
</type>
50+
<type name="Magento\Framework\Crontab\CrontabManagerInterface">
51+
<arguments>
52+
<argument name="shell" xsi:type="object">Magento\Framework\App\Shell</argument>
53+
</arguments>
54+
</type>
55+
<type name="Magento\Framework\Crontab\TasksProviderInterface">
56+
<arguments>
57+
<argument name="tasks" xsi:type="array">
58+
<item name="cronMagento" xsi:type="array">
59+
<item name="command" xsi:type="string">{magentoRoot}bin/magento cron:run | grep -v "Ran jobs by schedule" >> {magentoLog}magento.cron.log</item>
60+
</item>
61+
<item name="cronUpdate" xsi:type="array">
62+
<item name="command" xsi:type="string">{magentoRoot}update/cron.php >> {magentoLog}update.cron.log</item>
63+
</item>
64+
<item name="cronSetup" xsi:type="array">
65+
<item name="command" xsi:type="string">{magentoRoot}bin/magento setup:cron:run >> {magentoLog}setup.cron.log</item>
66+
</item>
67+
</argument>
68+
</arguments>
69+
</type>
4670
</config>

app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ public function create(
8888
$appendComment,
8989
$comment->getIsVisibleOnFront()
9090
);
91+
92+
if ($appendComment) {
93+
$shipment->setCustomerNote($comment->getComment());
94+
$shipment->setCustomerNoteNotify($appendComment);
95+
}
9196
}
9297

9398
return $shipment;

app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function setUp()
9292

9393
$this->shipmentMock = $this->getMockBuilder(ShipmentInterface::class)
9494
->disableOriginalConstructor()
95-
->setMethods(['addComment', 'addTrack'])
95+
->setMethods(['addComment', 'addTrack', 'setCustomerNote', 'setCustomerNoteNotify'])
9696
->getMockForAbstractClass();
9797

9898
$this->hydratorPoolMock = $this->getMockBuilder(HydratorPool::class)
@@ -166,7 +166,7 @@ public function testCreate()
166166
if ($appendComment) {
167167
$comment = "New comment!";
168168
$visibleOnFront = true;
169-
$this->commentMock->expects($this->once())
169+
$this->commentMock->expects($this->exactly(2))
170170
->method('getComment')
171171
->willReturn($comment);
172172

@@ -178,6 +178,10 @@ public function testCreate()
178178
->method('addComment')
179179
->with($comment, $appendComment, $visibleOnFront)
180180
->willReturnSelf();
181+
182+
$this->shipmentMock->expects($this->once())
183+
->method('setCustomerNoteNotify')
184+
->with(true);
181185
}
182186

183187
$this->assertEquals(

app/code/Magento/Store/etc/frontend/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<item name="standard" xsi:type="array">
1919
<item name="class" xsi:type="string">Magento\Framework\App\Router\Base</item>
2020
<item name="disable" xsi:type="boolean">false</item>
21-
<item name="sortOrder" xsi:type="string">20</item>
21+
<item name="sortOrder" xsi:type="string">30</item>
2222
</item>
2323
<item name="default" xsi:type="array">
2424
<item name="class" xsi:type="string">Magento\Framework\App\Router\DefaultRouter</item>

app/code/Magento/UrlRewrite/etc/frontend/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<item name="urlrewrite" xsi:type="array">
1313
<item name="class" xsi:type="string">Magento\UrlRewrite\Controller\Router</item>
1414
<item name="disable" xsi:type="boolean">false</item>
15-
<item name="sortOrder" xsi:type="string">40</item>
15+
<item name="sortOrder" xsi:type="string">20</item>
1616
</item>
1717
</argument>
1818
</arguments>

0 commit comments

Comments
 (0)