/** * @param Locale|null $language */ public function __construct(Locale $language = null) { if ($language === null) { $language = Locale::workingLocale(); } $this->language = $language; }
/** * @param Locale $toLocale * @param Locale|null $fromLocale */ public function __construct(Locale $toLocale, Locale $fromLocale = null) { if ($fromLocale === null) { $fromLocale = Locale::workingLocale(); } $this->toLocale = $toLocale; $this->fromLocale = $fromLocale; $this->extraIdMap = []; }
/** * Execute the action */ public function execute() { /** @var ContentBlockRepository $contentBlockRepository */ $contentBlockRepository = $this->get('content_blocks.repository.content_block'); $contentBlock = $contentBlockRepository->findOneByIdAndLocale($this->getParameter('id', 'int'), Locale::workingLocale()); if ($contentBlock === null) { return $this->redirect(BackendModel::createURLForAction('Index', null, null, ['error' => 'non-existing'])); } // The command bus will handle the saving of the content block in the database. $this->get('command_bus')->handle(new DeleteContentBlock($contentBlock)); $this->get('event_dispatcher')->dispatch(ContentBlockDeleted::EVENT_NAME, new ContentBlockDeleted($contentBlock)); return $this->redirect(BackendModel::createURLForAction('Index', null, null, ['report' => 'deleted', 'var' => $contentBlock->getTitle()])); }
/** * Load the datagrid */ private function loadDataGrid() { $this->dataGrid = new ContentBlockDataGrid(Locale::workingLocale()); $this->dataGrid->setSortingColumns(['title']); // show the hidden status $this->dataGrid->addColumn('isHidden', ucfirst(BL::lbl('VisibleOnSite')), '[hidden]'); $this->dataGrid->setColumnFunction([TemplateModifiers::class, 'showBool'], ['[hidden]', true], 'isHidden'); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { $editUrl = BackendModel::createURLForAction('Edit', null, null, ['id' => '[id]'], false); $this->dataGrid->setColumnURL('title', $editUrl); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), $editUrl, BL::lbl('Edit')); } }
/** * Parses a data grid with the revisions in the template */ private function parseRevisionsDataGrid() { // create datagrid $revisions = new ContentBlockRevisionDataGrid($this->contentBlock, Locale::workingLocale()); // hide columns $revisions->setColumnsHidden(['id', 'revision_id']); // disable paging $revisions->setPaging(false); // set headers $revisions->setHeaderLabels(['user_id' => SpoonFilter::ucfirst(Language::lbl('By')), 'edited_on' => SpoonFilter::ucfirst(Language::lbl('LastEditedOn'))]); // set column-functions $revisions->setColumnFunction([DataGridFunctions::class, 'getUser'], ['[user_id]'], 'user_id'); $revisions->setColumnFunction([DataGridFunctions::class, 'getTimeAgo'], ['[edited_on]'], 'edited_on'); // check if this action is allowed if (Authentication::isAllowedAction('Edit')) { $editRevisionUrl = BackendModel::createURLForAction('Edit', null, null, ['id' => '[id]', 'revision' => '[revision_id]'], false); // set column URLs $revisions->setColumnURL('title', $editRevisionUrl); // add use column $revisions->addColumn('use_revision', null, Language::lbl('UseThisVersion'), $editRevisionUrl, Language::lbl('UseThisVersion')); } $this->tpl->assign('revisions', (string) $revisions->getContent()); }