Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Controller extends Package
{
protected $pkgHandle = 'url_aliases';

protected $pkgVersion = '0.0.2';
protected $pkgVersion = '0.0.3';

/**
* {@inheritdoc}
Expand Down
16 changes: 14 additions & 2 deletions src/Concrete/Entity/UrlAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
* @Doctrine\ORM\Mapping\Table(
* name="UrlAliases",
* indexes={
* @Doctrine\ORM\Mapping\Index(name="mlUrlAliasPath", columns={"path"}, options={"lengths":{255}})
* @Doctrine\ORM\Mapping\Index(columns={"pathIndexed"})
* }
* )
*/
class UrlAlias implements Target
{
public const PATH_INDEXED_MAX_LENGTH = 255;

/**
* The record ID (null if not persisted).
*
Expand Down Expand Up @@ -53,6 +55,15 @@ class UrlAlias implements Target
*/
protected $path;

/**
* The normalized path alias (indexed).
*
* @Doctrine\ORM\Mapping\Column(type="string", length=255, nullable=false, options={"comment":"Normalized path alias (indexed)"})
*
* @var string
*/
protected $pathIndexed;

/**
* The querystring (without leading question mark).
*
Expand Down Expand Up @@ -144,7 +155,7 @@ public function __construct()
{
$this->id = null;
$this->createdOn = new DateTime();
$this->path = '';
$this->setPath('');
$this->querystring = '';
$this->acceptAdditionalQuerystringParams = true;
$this->enabled = true;
Expand Down Expand Up @@ -189,6 +200,7 @@ public function getPath(): string
public function setPath(string $value): self
{
$this->path = $value;
$this->pathIndexed = mb_substr($value, 0, self::PATH_INDEXED_MAX_LENGTH);

return $this;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Concrete/Entity/UrlAliasRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function findByRequest(Request $request, ?bool $enabled = true, ?int $max
public function findByPathAndQuerysring(string $path, string $querystring, ?bool $enabled = true, ?int $maxResults = null): array
{
$qb = $this->createQueryBuilder('ua')
->setParameter('pathIndexed', mb_substr($path, 0, UrlAlias::PATH_INDEXED_MAX_LENGTH))
->andWhere('ua.pathIndexed = :pathIndexed')
->setParameter('path', $path)
->andWhere('ua.path = :path')
;
Expand Down