/** * Given a record driver, get a URL for that record. * * @param \VuFind\RecordDriver\AbstractBase|string $driver Record driver * representing record to link to, or source|id pipe-delimited string * @param string $action Record * action to access * * @return string */ public function getActionUrl($driver, $action) { // Build the URL: $urlHelper = $this->getView()->plugin('url'); $details = RecordRouter::getActionRouteDetails($driver, $action); return $urlHelper($details['route'], $details['params']); }
/** * Process the "edit list" submission. * * @param \VuFind\Db\Row\User $user Logged in user * @param \VuFind\Db\Row\UserList $list List being created/edited * * @return object|bool Response object if redirect is * needed, false if form needs to be redisplayed. */ protected function processEditList($user, $list) { // Process form within a try..catch so we can handle errors appropriately: try { $finalId = $list->updateFromRequest($user, $this->getRequest()->getPost()); // If the user is in the process of saving a record, send them back // to the save screen; otherwise, send them back to the list they // just edited. $recordId = $this->params()->fromQuery('recordId'); $recordSource = $this->params()->fromQuery('recordSource', 'VuFind'); if (!empty($recordId)) { $details = RecordRouter::getActionRouteDetails($recordSource . '|' . $recordId, 'Save'); return $this->redirect()->toRoute($details['route'], $details['params']); } // Similarly, if the user is in the process of bulk-saving records, // send them back to the appropriate place in the cart. $bulkIds = $this->params()->fromPost('ids', array()); if (!empty($bulkIds)) { $params = array(); foreach ($bulkIds as $id) { $params[] = urlencode('ids[]') . '=' . urlencode($id); } $saveUrl = $this->url()->forRoute('cart-save'); return $this->redirect()->toUrl($saveUrl . '?' . implode('&', $params)); } return $this->redirect()->toRoute('userList', array('id' => $finalId)); } catch (\Exception $e) { switch (get_class($e)) { case 'VuFind\\Exception\\ListPermission': case 'VuFind\\Exception\\MissingField': $this->flashMessenger()->setNamespace('error')->addMessage($e->getMessage()); return false; case 'VuFind\\Exception\\LoginRequired': return $this->forceLogin(); default: throw $e; } } }