. */ 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) { $revertable = true; 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 ''; } $tmp = '
'; $tmp .= sprintf( '', $context->getID(), $icon, $title ); $tmp .= sprintf( '', $context->getID(), $this->translator->trans('log.undo.revert') ); $tmp .= '
'; return $tmp; } }