diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-07-17 18:47:06 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-07-17 18:47:06 -0400 |
commit | cbe52e57200a66522d88dfc5d5f46de8eb87ffb2 (patch) | |
tree | 5a8b37d64c0ce4142d19c50a716f1ffb9c47ee7d /app/Job/ProjectFileEventJob.php | |
parent | ec0ecc5b0387924f061865f4ec12dbfc5b7018fe (diff) |
File events refactoring
Diffstat (limited to 'app/Job/ProjectFileEventJob.php')
-rw-r--r-- | app/Job/ProjectFileEventJob.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/app/Job/ProjectFileEventJob.php b/app/Job/ProjectFileEventJob.php new file mode 100644 index 00000000..d68949c5 --- /dev/null +++ b/app/Job/ProjectFileEventJob.php @@ -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); + } + } +} |