<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\AssetBundle\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Workflow\Event\Event;
use Pimcore\Model\Asset;
class AssetWorkflowListner implements EventSubscriberInterface {
public function onAccepted(Event $event) {
$imageObject = $event->getSubject();
if ($imageObject instanceof Asset) {
$imageObject->setProperty('active', 'select', 'Active');
$imageObject->save();
}
}
public function onRedit(Event $event) {
$imageObject = $event->getSubject();
if ($imageObject instanceof Asset) {
$imageObject->setProperty('active', 'select', 'InActive');
$imageObject->save();
}
}
public static function getSubscribedEvents() {
return array(
'workflow.simple_asset_workflow.entered.finished' => "onAccepted",
'workflow.simple_asset_workflow.entered.reedit' => "onRedit",
);
}
}