/** * Loads all autogenerated entries with given $parentId with optionally included history entries. * * @param mixed $parentId * @param bool $includeHistory * * @return array */ public function loadAutogeneratedEntries($parentId, $includeHistory = false) { try { return $this->innerGateway->loadAutogeneratedEntries($parentId, $includeHistory); } catch (DBALException $e) { throw new \RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new \RuntimeException('Database error', 0, $e); } }
/** * Recursively removes aliases by given $id and $action. * * $original parameter is used to limit removal of moved Location aliases to history entries only. * * @param mixed $id * @param string $action * @param mixed $original */ protected function removeSubtree($id, $action, $original) { // Remove first to avoid unnecessary recursion. if ($original) { // If entry is original remove all for action (history and custom entries included). $this->gateway->remove($action); } else { // Else entry is history, so remove only for action with the id. // This means $id grouped history entries are removed, other history, active autogenerated // and custom are left alone. $this->gateway->remove($action, $id); } // Load all autogenerated for parent $id, including history. $entries = $this->gateway->loadAutogeneratedEntries($id, true); foreach ($entries as $entry) { $this->removeSubtree($entry['id'], $entry['action'], $entry['is_original']); } }