Skip to content

Commit 275246a

Browse files
committed
[docs] add docs.
1 parent 6bed658 commit 275246a

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

docs/bundle/consumption_extension.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Consumption extension
2+
3+
Here, I show how you can crate a custom extension and register it.
4+
Let's first create an extension itself:
5+
6+
```php
7+
<?php
8+
// src/AppBundle/Enqueue;
9+
namespace AppBundle\Enqueue;
10+
11+
use Enqueue\Consumption\ExtensionInterface;
12+
use Enqueue\Consumption\EmptyExtensionTrait;
13+
use Enqueue\Consumption\Context;
14+
15+
class CountProcessedMessagesExtension implements ExtensionInterface
16+
{
17+
use EmptyExtensionTrait;
18+
19+
private $processedMessages = 0;
20+
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function onPostReceived(Context $context)
25+
{
26+
$this->processedMessages += 1;
27+
}
28+
}
29+
```
30+
31+
Now we have to register as a Symfony service with special tag:
32+
33+
```yaml
34+
services:
35+
app.enqueue.count_processed_messages_extension:
36+
class: 'AppBundle\Enqueue\CountProcessedMessagesExtension'
37+
tags:
38+
- { name: 'enqueue.consumption.extension', priority: 10 }
39+
```
40+
41+
[back to index](../index.md)

docs/consumption/extensions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Consumption extensions.
22

3-
3+
You can learn how to register extensions in [quick tour](../quick_tour.md#consumption).
4+
There's dedicated [chapter](../bundle/consumption_extension.md) for how to add extension in Symfony app.
45

56
## [LoggerExtension](https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/enqueue/Consumption/Extension/LoggerExtension.php)
67

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Config reference](bundle/config_reference.md)
1313
- [Cli commands](bundle/cli_commands.md)
1414
- [Job queue](bundle/job_queue.md)
15+
- [Consumption extension](bundle/consumption_extension.md)
1516
- [Production settings](bundle/production_settings.md)
1617
- [Debuging](bundle/debuging.md)
1718
- [Functional testing](bundle/functional_testing.md)

0 commit comments

Comments
 (0)