Skip to content

Commit c3a253b

Browse files
RuslanRuslan
Ruslan
authored and
Ruslan
committed
Update composer json
- Update repo file structure
1 parent 88a5ed5 commit c3a253b

File tree

14 files changed

+911
-0
lines changed

14 files changed

+911
-0
lines changed

Console/CommandList.php

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Enqueue\Enqueue\Console;
7+
8+
use Enqueue\Symfony\Client\ConsumeMessagesCommand;
9+
use Enqueue\Symfony\Client\Meta\QueuesCommand;
10+
use Enqueue\Symfony\Client\Meta\TopicsCommand;
11+
use Enqueue\Symfony\Client\ProduceMessageCommand;
12+
use Enqueue\Symfony\Client\SetupBrokerCommand;
13+
/**
14+
* Provides list of commands to be available for uninstalled application
15+
*/
16+
class CommandList implements \Magento\Framework\Console\CommandListInterface
17+
{
18+
/**
19+
* @var \Enqueue\Symfony\Client\SetupBrokerCommandFactory
20+
*/
21+
private $setupBrokerCommandFactory;
22+
23+
/**
24+
* @var \Enqueue\Symfony\Client\ConsumeMessagesCommandFactory
25+
*/
26+
private $consumeMessagesCommandFactory;
27+
28+
/**
29+
* @var \Enqueue\Symfony\Client\Meta\TopicsCommandFactory
30+
*/
31+
private $topicsCommandFactory;
32+
33+
/**
34+
* @var \Enqueue\Symfony\Client\ProduceMessageCommandFactory
35+
*/
36+
private $produceMessageCommandFactory;
37+
38+
/**
39+
* @var \Enqueue\Symfony\Client\Meta\QueuesCommandFactory
40+
*/
41+
private $queuesCommandFactory;
42+
/**
43+
* @var \Enqueue\Enqueue\Model\EnqueueManager
44+
*/
45+
private $enqueueManager;
46+
47+
/**
48+
* CommandList constructor.
49+
*
50+
* @param \Enqueue\Enqueue\Model\EnqueueManager $enqueueManager
51+
* @param \Enqueue\Symfony\Client\SetupBrokerCommandFactory $setupBrokerCommandFactory
52+
* @param \Enqueue\Symfony\Client\Meta\QueuesCommandFactory $queuesCommandFactory
53+
* @param \Enqueue\Symfony\Client\Meta\TopicsCommandFactory $topicsCommandFactory
54+
* @param \Enqueue\Symfony\Client\ProduceMessageCommandFactory $produceMessageCommandFactory
55+
* @param \Enqueue\Symfony\Client\ConsumeMessagesCommandFactory $consumeMessagesCommand
56+
*/
57+
public function __construct(
58+
\Enqueue\Enqueue\Model\EnqueueManager $enqueueManager,
59+
\Enqueue\Symfony\Client\SetupBrokerCommandFactory $setupBrokerCommandFactory,
60+
\Enqueue\Symfony\Client\Meta\QueuesCommandFactory $queuesCommandFactory,
61+
\Enqueue\Symfony\Client\Meta\TopicsCommandFactory $topicsCommandFactory,
62+
\Enqueue\Symfony\Client\ProduceMessageCommandFactory $produceMessageCommandFactory,
63+
\Enqueue\Symfony\Client\ConsumeMessagesCommandFactory $consumeMessagesCommand
64+
) {
65+
$this->enqueueManager = $enqueueManager;
66+
$this->setupBrokerCommandFactory = $setupBrokerCommandFactory;
67+
$this->queuesCommandFactory = $queuesCommandFactory;
68+
$this->topicsCommandFactory = $topicsCommandFactory;
69+
$this->produceMessageCommandFactory = $produceMessageCommandFactory;
70+
$this->consumeMessagesCommandFactory = $consumeMessagesCommand;
71+
}
72+
73+
/**
74+
* Gets list of command classes
75+
*
76+
* @return string[]
77+
*/
78+
private function getCommandsClasses()
79+
{
80+
return [
81+
SetupBrokerCommand::class,
82+
ProduceMessageCommand::class,
83+
TopicsCommand::class,
84+
ConsumeMessagesCommand::class,
85+
QueuesCommand::class,
86+
];
87+
}
88+
89+
/**
90+
* @inheritdoc
91+
*/
92+
public function getCommands()
93+
{
94+
$commands = [];
95+
96+
$this->enqueueManager->bindProcessors();
97+
$client = $this->enqueueManager->getClient();
98+
99+
foreach ($this->getCommandsClasses() as $class) {
100+
if (class_exists($class)) {
101+
$commands[] = $this->setupBrokerCommandFactory->create(['driver' => $client->getDriver()]);
102+
$commands[] = $this->produceMessageCommandFactory->create(['producer' => $client->getProducer()]);
103+
$commands[] = $this->queuesCommandFactory->create(['queueRegistry' => $client->getQueueMetaRegistry()]);
104+
$commands[] = $this->topicsCommandFactory->create(['topicRegistry' => $client->getTopicMetaRegistry()]);
105+
$commands[] = $this->consumeMessagesCommandFactory->create(
106+
[
107+
'consumer' => $client->getQueueConsumer(),
108+
'processor' => $client->getDelegateProcessor(),
109+
'queueMetaRegistry' => $client->getQueueMetaRegistry(),
110+
'driver' => $client->getDriver()
111+
]
112+
);
113+
} else {
114+
throw new \Exception('Class ' . $class . ' does not exist');
115+
}
116+
}
117+
118+
return $commands;
119+
}
120+
}

Model/Config/Source/Redis/Vendor.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Enqueue\Enqueue\Model\Config\Source\Redis;
4+
5+
class Vendor
6+
{
7+
/**
8+
* Options getter
9+
*
10+
* @return array
11+
*/
12+
public function toOptionArray()
13+
{
14+
return [
15+
['value' => 'phpredis', 'label' => __('phpredis')],
16+
['value' => 'predis', 'label' => __('predis')],
17+
];
18+
}
19+
}

Model/Config/Source/Transport.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Enqueue\Enqueue\Model\Config\Source;
4+
5+
class Transport
6+
{
7+
/**
8+
* Options getter
9+
*
10+
* @return array
11+
*/
12+
public function toOptionArray()
13+
{
14+
return [
15+
['value' => 'rabbitmq_amqp', 'label' => __('RabbitMQ AMQP')],
16+
['value' => 'amqp', 'label' => __('AMQP')],
17+
['value' => 'rabbitmq_stomp', 'label' => __('RabbitMQ STOMP')],
18+
['value' => 'stomp', 'label' => __('STOMP')],
19+
['value' => 'fs', 'label' => __('Filesystem')],
20+
['value' => 'sqs', 'label' => __('Amazon AWS SQS')],
21+
['value' => 'redis', 'label' => __('Redis')],
22+
['value' => 'dbal', 'label' => __('Doctrine DBAL')],
23+
];
24+
}
25+
}

0 commit comments

Comments
 (0)