. */ namespace App\DataTables\Column; use App\Entity\LogSystem\CollectionElementDeleted; use App\Entity\LogSystem\ElementCreatedLogEntry; use App\Entity\LogSystem\ElementDeletedLogEntry; use App\Entity\LogSystem\ElementEditedLogEntry; use Omines\DataTablesBundle\Column\AbstractColumn; use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; class RevertLogColumn extends AbstractColumn { protected $translator; protected $security; public function __construct(TranslatorInterface $translator, Security $security) { $this->translator = $translator; $this->security = $security; } /** * @param $value * @return mixed */ public function normalize($value) { return $value; } public function render($value, $context): string { if ( $context instanceof CollectionElementDeleted || ($context instanceof ElementDeletedLogEntry && $context->hasOldDataInformations()) ) { $icon = 'fa-trash-restore'; $title = $this->translator->trans('log.undo.undelete'); } elseif ( $context instanceof ElementCreatedLogEntry || ($context instanceof ElementEditedLogEntry && $context->hasOldDataInformations()) ) { $icon = 'fa-undo'; $title = $this->translator->trans('log.undo.undo'); } else { return ''; } $disabled = !$this->security->isGranted('revert_element', $context->getTargetClass()); $tmp = '