. */ namespace App\DataTables\Column; use App\Entity\LogSystem\AbstractLogEntry; 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\Contracts\Translation\TranslatorInterface; class RevertLogColumn extends AbstractColumn { protected $translator; public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } /** * @inheritDoc */ public function normalize($value) { return $value; } public function render($value, $context) { if ($context instanceof ElementDeletedLogEntry || $context instanceof CollectionElementDeleted) { $icon = 'fa-trash-restore'; $title = $this->translator->trans('log.undo.undelete'); } elseif ($context instanceof ElementEditedLogEntry || $context instanceof ElementCreatedLogEntry) { $icon = 'fa-undo'; $title = $this->translator->trans('log.undo.undo'); } else { return ''; } return sprintf( '', $context->getID(), $icon, $title ); } }