/** * Returns next value for "id" column. * * @return mixed */ public function getNextId() { try { return $this->innerGateway->getNextId(); } catch (DBALException $e) { throw new \RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new \RuntimeException('Database error', 0, $e); } }
/** * Recursively copies aliases from old parent under new parent. * * @param array $actionMap * @param mixed $oldParentAliasId * @param mixed $newParentAliasId */ protected function copySubtree($actionMap, $oldParentAliasId, $newParentAliasId) { $rows = $this->gateway->loadAutogeneratedEntries($oldParentAliasId); $newIdsMap = array(); foreach ($rows as $row) { $oldParentAliasId = $row['id']; // Ensure that same action entries remain grouped by the same id if (!isset($newIdsMap[$oldParentAliasId])) { $newIdsMap[$oldParentAliasId] = $this->gateway->getNextId(); } $row['action'] = $actionMap[$row['action']]; $row['parent'] = $newParentAliasId; $row['id'] = $row['link'] = $newIdsMap[$oldParentAliasId]; $this->gateway->insertRow($row); $this->copySubtree($actionMap, $oldParentAliasId, $row['id']); } }