Skip to content

Commit

Permalink
Register the maintenance job for update queue processing in Pimcore 6 (
Browse files Browse the repository at this point in the history
…#86)

* Add new maintenance task for Pimcore v6 support

* Move legacy job registration logic to new class
  • Loading branch information
jdreesen authored Apr 28, 2020
1 parent b539b05 commit 32133b5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/EventListener/IndexUpdateListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
use AdvancedObjectSearchBundle\Service;
use Pimcore\Event\Model\DataObject\ClassDefinitionEvent;
use Pimcore\Event\Model\DataObjectEvent;
use Pimcore\Event\System\MaintenanceEvent;
use Pimcore\Logger;
use Pimcore\Model\DataObject\AbstractObject;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\Schedule\Maintenance\Job;

class IndexUpdateListener
{
Expand Down Expand Up @@ -71,13 +69,4 @@ public function deleteIndex(ClassDefinitionEvent $event) {
Logger::err($e);
}
}

public function registerMaintenanceJob(MaintenanceEvent $maintenanceEvent) {
$maintenanceEvent->getManager()->registerJob(new Job(get_class($this), [$this, "maintenance"]));
}

public function maintenance() {
$this->service->processUpdateQueue(500);
}

}
48 changes: 48 additions & 0 deletions src/Maintenance/UpdateQueueProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/


namespace AdvancedObjectSearchBundle\Maintenance;


use AdvancedObjectSearchBundle\Service;
use Pimcore\Event\System\MaintenanceEvent;
use Pimcore\Maintenance\TaskInterface;
use Pimcore\Model\Schedule\Maintenance\Job;

class UpdateQueueProcessor implements TaskInterface
{
/**
* @var Service
*/
protected $service;

public function __construct(Service $service)
{
$this->service = $service;
}

/**
* Note: When Pimcore v5 support is dropped, this can be removed.
*/
public function registerMaintenanceJob(MaintenanceEvent $maintenanceEvent)
{
$maintenanceEvent->getManager()->registerJob(new Job(get_class($this), [$this, "execute"]));
}

public function execute()
{
$this->service->processUpdateQueue(500);
}
}
5 changes: 5 additions & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ services:
- { name: kernel.event_listener, event: pimcore.dataobject.preDelete, method: deleteObject }
- { name: kernel.event_listener, event: pimcore.class.postUpdate, method: updateMapping }
- { name: kernel.event_listener, event: pimcore.class.postDelete, method: deleteIndex }

AdvancedObjectSearchBundle\Maintenance\UpdateQueueProcessor:
tags:
- { name: pimcore.maintenance.task, type: advancedobjectsearch_update_queue }
# Note: When Pimcore v5 support is dropped, this can be removed.
- { name: kernel.event_listener, event: pimcore.system.maintenance, method: registerMaintenanceJob }

bundle.advanced_object_search.filter_locator:
Expand Down

0 comments on commit 32133b5

Please sign in to comment.