Перейти к основному содержимому

Задачи на техническое обслуживание

Pimcore предлагает вам выполнять запланированные задачи по техническому обслуживанию. Это позволяет периодически делать такие вещи, как очистки. Очень важно, чтобы задание Cron обслуживаемого подготовки была самолета, см.: Установка.

Зарегистрируйте новую задачу обслуживания

Чтобы зарегистрировать новую задачу обслуживания, создайте новый класс и реализуйте интерфейс {c1}. Зарегистрируйте свой класс в контейнер Symfony с помощью TAG pimcore.maintenance.task и type атрибут:

App\Maintenance\MyMaintenanceTask:  
tags:
- { name: pimcore.maintenance.task, type: my_maintenance_task }

Pimcore will then call your maintenance task on the maintenance cron job you have to configure. You will have to take care about timing operations inside the Task yourself.

Register a new Maintenance Task using a separate messenger transport

First follow the steps mentioned above, then add the messengerMessageClass property to your tag, as shown in the example below. Pimcore then will make sure to add this specific message to the messenger bus.

App\Maintenance\MyMaintenanceTask:  
tags:
- { name: pimcore.maintenance.task, type: my_maintenance_task, messengerMessageClass: '\App\Messenger\MyMaintenanceMessage' }

Please be aware: You need to implemented both, the message and the handler class. After that you can route your message to the corresponding transport.

For a full example you can have a look at the \Pimcore\Messenger\ScheduledTaskMessage class and its usage.


Вы можете предложить улучшение документации или задать вопрос в комментариях.
Если вам нужна полноценная консультация — вы можете заказать её на нашем сайте.