<?php
namespace App\EventListener;
use Pimcore\Event\Model\DataObjectEvent;
use Pimcore\Model\DataObject\Solution;
class SolutionEventListener
{
public function postAdd(DataObjectEvent $e)
{
$object = $e->getObject();
if($object instanceof Solution){
if ($object->getProvider()) {
$systemKey = $object->getProvider()->getNameCompany('vi') . ' - ' . $object->getName('vi');
} else {
$systemKey = $object->getName('vi');
}
$object->setSystemKey($systemKey);
$object->save();
}
}
public function postUpdate(DataObjectEvent $e)
{
$object = $e->getObject();
if($object instanceof Solution){
if ($object->getProvider()) {
$systemKey = $object->getProvider()->getNameCompany('vi') . ' - ' . $object->getName('vi');
} else {
$systemKey = $object->getName('vi');
}
$object->setSystemKey($systemKey);
$object->save();
}
}
}