public function parseUrl($internalUrl)
{
$internalUrl = trim($internalUrl);
$list = false;
$catch = 'object://';
if (substr(strtolower($internalUrl), 0, strlen($catch)) == $catch) {
$internalUrl = substr($internalUrl, strlen($catch));
}
$catch = 'objects://';
if (substr(strtolower($internalUrl), 0, strlen($catch)) == $catch) {
$list = true;
$internalUrl = substr($internalUrl, strlen($catch));
}
$firstSlashPos = strpos($internalUrl, '/');
$questionPos = strpos($internalUrl, '?');
if ($firstSlashPos === false && $questionPos === false) {
return array($internalUrl, false, array(), $list);
}
if ($firstSlashPos === false && $questionPos != false) {
$objectKey = substr($internalUrl, 0, $questionPos);
} else {
$objectKey = $this->getObjectKey($internalUrl);
}
if (strpos($objectKey, '%')) {
$objectKey = Tools::urlDecode($objectKey);
}
if (!$objectKey) {
throw new \LogicException(sprintf('The url `%s` does not contain a object key.', $internalUrl));
}
$params = array();
$objectIds = null;
if ($questionPos !== false) {
parse_str(substr($internalUrl, $questionPos + 1), $params);
if ($firstSlashPos !== false) {
$objectIds = substr($internalUrl, $firstSlashPos + 1, $questionPos - ($firstSlashPos + 1));
}
} else {
$objectIds = substr($internalUrl, strlen($objectKey) + 1);
}
$objectIds = $this->parsePk($objectKey, $objectIds);
if ($params && isset($params['condition'])) {
$params['condition'] = json_decode($params['condition'], true);
}
return array($objectKey, !$objectIds ? false : $objectIds, $params, $list);
}