diff --git a/src/ProcessManagerBundle/EventListener/ArtifactListener.php b/src/ProcessManagerBundle/EventListener/ArtifactListener.php new file mode 100644 index 0000000..9546d3f --- /dev/null +++ b/src/ProcessManagerBundle/EventListener/ArtifactListener.php @@ -0,0 +1,38 @@ +getRecord(); + + if (false === array_key_exists('artifact', $record['context'])) { + return; + } + + /** @var ProcessInterface $process */ + $process = $record['extra']['process']; + + $artifactPath = $record['context']['artifact']; + + // TODO: copy $artifactPath in place of this asset + $artifact = new Asset(); + + $process->setArtifact($artifact); + $process->save(); + } +} diff --git a/src/ProcessManagerBundle/Model/Process.php b/src/ProcessManagerBundle/Model/Process.php index e1f9f2e..5c75f44 100644 --- a/src/ProcessManagerBundle/Model/Process.php +++ b/src/ProcessManagerBundle/Model/Process.php @@ -16,6 +16,7 @@ use Pimcore\Logger; use Pimcore\Model\AbstractModel; +use Pimcore\Model\Asset; class Process extends AbstractModel implements ProcessInterface { @@ -273,4 +274,18 @@ public function getPercentage() { return ((100 / $this->getTotal()) * $this->getProgress()) / 100; } + + /** + * @param Asset $artifact + */ + public function setArtifact(Asset $artifact) + { + } + + /** + * @return null|Asset + */ + public function getArtifact() + { + } } diff --git a/src/ProcessManagerBundle/Model/ProcessInterface.php b/src/ProcessManagerBundle/Model/ProcessInterface.php index cb64b21..6d7041f 100644 --- a/src/ProcessManagerBundle/Model/ProcessInterface.php +++ b/src/ProcessManagerBundle/Model/ProcessInterface.php @@ -15,6 +15,7 @@ namespace ProcessManagerBundle\Model; use CoreShop\Component\Resource\Model\ResourceInterface; +use Pimcore\Model\Asset; interface ProcessInterface extends ResourceInterface { @@ -90,4 +91,14 @@ public function setTotal($total); * @return float */ public function getPercentage(); -} \ No newline at end of file + + /** + * @param Asset $artifact + */ + public function setArtifact(Asset $artifact); + + /** + * @return null|Asset + */ + public function getArtifact(); +} diff --git a/src/ProcessManagerBundle/Resources/config/services.yml b/src/ProcessManagerBundle/Resources/config/services.yml index 41fb756..bc71cf0 100644 --- a/src/ProcessManagerBundle/Resources/config/services.yml +++ b/src/ProcessManagerBundle/Resources/config/services.yml @@ -40,6 +40,12 @@ services: - { name: process_manager.process, type: pimcore, form-type: ProcessManagerBundle\Form\Type\Processes\PimcoreType } ### Event listeners + process_manager.event_listener.artifact: + class: ProcessManagerBundle\EventListener\ArtifactListener + tags: + - { name: kernel.event_listener, event: process_manager.process.log_event, method: onProcessLogEvent } + arguments: + - '@process_manager.registry.processes' process_manager.event_listener.cron: class: ProcessManagerBundle\EventListener\CronListener tags: