File events refactoring

This commit is contained in:
Frederic Guillot
2016-07-17 18:47:06 -04:00
parent ec0ecc5b03
commit cbe52e5720
21 changed files with 398 additions and 74 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace Kanboard\Job;
use Kanboard\EventBuilder\ProjectFileEventBuilder;
/**
* Class ProjectFileEventJob
*
* @package Kanboard\Job
* @author Frederic Guillot
*/
class ProjectFileEventJob extends BaseJob
{
/**
* Set job params
*
* @param int $fileId
* @param string $eventName
* @return $this
*/
public function withParams($fileId, $eventName)
{
$this->jobParams = array($fileId, $eventName);
return $this;
}
/**
* Execute job
*
* @param int $fileId
* @param string $eventName
* @return $this
*/
public function execute($fileId, $eventName)
{
$event = ProjectFileEventBuilder::getInstance($this->container)
->withFileId($fileId)
->build();
if ($event !== null) {
$this->dispatcher->dispatch($eventName, $event);
}
}
}