src/AssetBundle/EventListener/AssetWorkflowListner.php line 17

Open in your IDE?
  1. <?php
  2. /*
  3.  * To change this license header, choose License Headers in Project Properties.
  4.  * To change this template file, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7. namespace App\AssetBundle\EventListener;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. use Symfony\Component\Workflow\Event\Event;
  10. use Pimcore\Model\Asset;
  11. class AssetWorkflowListner implements EventSubscriberInterface {
  12.     public function onAccepted(Event $event) {
  13.         $imageObject $event->getSubject();
  14.         if ($imageObject instanceof Asset) {
  15.             $imageObject->setProperty('active''select''Active');
  16.             $imageObject->save();
  17.         }
  18.     }
  19.     public function onRedit(Event $event) {
  20.         $imageObject $event->getSubject();
  21.         if ($imageObject instanceof Asset) {
  22.             $imageObject->setProperty('active''select''InActive');
  23.             $imageObject->save();
  24.         }
  25.     }
  26.     public static function getSubscribedEvents() {
  27.         return array(
  28.             'workflow.simple_asset_workflow.entered.finished' => "onAccepted",
  29.             'workflow.simple_asset_workflow.entered.new' => "onRedit",
  30.         );
  31.     }
  32. }