/** * Redirect to edit mask. * * @param EnvironmentInterface $environment The environment. * @param ModelIdInterface $copiedModelId The model id. * * @return void */ protected function redirect($environment, $copiedModelId) { // Build a clean url to remove the copy related arguments instad of using the AddToUrlEvent. $url = new BackendUrlBuilder(); $url->setPath('contao/main.php')->setQueryParameter('do', $environment->getInputProvider()->getParameter('do'))->setQueryParameter('table', $copiedModelId->getDataProviderName())->setQueryParameter('act', 'edit')->setQueryParameter('id', $copiedModelId->getSerialized()); $redirectEvent = new RedirectEvent($url->getUrl()); $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $redirectEvent); }
/** * Redirect to the child table. * * @param EnvironmentInterface $environment The environment. * @param boolean $doNotCopy The boolean do not copy. * * @return void */ protected function redirectToChildTable(EnvironmentInterface $environment, $doNotCopy = false) { $redirectUrl = new BackendUrlBuilder(); $redirectUrl->setPath('contao/main.php')->setQueryParameter('do', $environment->getInputProvider()->getParameter('do')); if ($doNotCopy === false) { $redirectUrl->setQueryParameter('act', $environment->getInputProvider()->getParameter('act'))->setQueryParameter('ctable', $environment->getInputProvider()->getParameter('ctable'))->setQueryParameter('table', $environment->getInputProvider()->getParameter('ctable'))->setQueryParameter('id', $environment->getInputProvider()->getParameter('id'))->setQueryParameter('pid', $environment->getInputProvider()->getParameter('id')); } if ($doNotCopy) { // TODO go to the right table /*$redirectUrl ->setQueryParameter('act', 'edit') ->setQueryParameter('table', $environment->getInputProvider()->getParameter('table')) ->setQueryParameter('pid', $environment->getInputProvider()->getParameter('id'));*/ } $redirectEvent = new RedirectEvent($redirectUrl->getUrl()); $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $redirectEvent); }