Skip to content

alexander-schranz/route-prototype

Repository files navigation

README

This package include a prototype for a new Route entity for Sulu CMS. The route entity supports multi-site, multi localization and a parent child relation.

The goal is to simplify existing route handling which requires calling a Manager service. Instead, in future following should be enough to create a new route:

$route = new Route('page', 1, 'en', '/test', 'intranet');
$routeRepository->add($route);
$entityManager->flush();

Update a route is just a call to setSlug:

$route->setSlug('/new-slug');
$entityManager->flush();

All updating of child routes is done automatically via doctrine listeners as postFlush listener, no need to call a Manager service or other services.

Running Tests

composer bootstrap-test-env

composer test

Skip the heavy_load tests if you don't want to wait for a long time.

TODO

  • Childs are update
  • Grand childs are update
  • Multi Localization support
  • Multi Site support
  • Support for non Site connected routes (article)
    • Site A with /test and Site B /test and article parent Site A /test/article should not be updated when Site B /test was changed
  • Add Multi Site tests
  • Add Multi Localization tests

Benchmark Select queries

There are different kind of queries possible. The example uses ~100.000 routes and about ~40.000 need to be updated:

Child Ids

SELECT child.id FROM route parent
INNER JOIN route child ON child.parent_id = parent.id
WHERE parent.site = 'website'
AND parent.locale = 'en'
AND (parent.slug = '/rezepte-neu' OR parent.slug LIKE '/rezepte/%')

Time: 70 - 110ms
Total Ids: 41406

Parent Ids (👈 Looks like the best one)

SELECT parent.id FROM route parent
INNER JOIN route child ON child.parent_id = parent.id
WHERE parent.site = 'website'
AND parent.locale = 'en'
AND (parent.slug = '/rezepte-neu' OR parent.slug LIKE '/rezepte/%')

Time: 60 - 110ms
Total Ids: 41406 (with duplicates array_unique in PHP to ~8124 parentIds)
Total Time include Update: 1.85 seconds

Distinct Parents

SELECT DISTINCT parent.id FROM route parent
INNER JOIN route child ON child.parent_id = parent.id
WHERE parent.site = 'website'
AND parent.locale = 'en'
AND (parent.slug = '/rezepte-neu' OR parent.slug LIKE '/rezepte/%')

Time: 115 - 160ms
Total Ids: 8282

Group By Parents

SELECT parent.id FROM route parent
INNER JOIN route child ON child.parent_id = parent.id
WHERE parent.site = 'website'
AND parent.locale = 'en'
AND (parent.slug = '/rezepte-neu' OR parent.slug LIKE '/rezepte/%')
GROUP BY parent.id

Time: 115 - 160ms
Total Ids: 8282

Benchmark Update queries

Update by Child Ids

UPDATE route r
SET slug = CONCAT('/rezepte-neu', SUBSTRING(r.slug, LENGTH('/rezepte') + 1))
WHERE r.id IN (:childIds)

TODO benchmark

Update by Parent Ids

UPDATE route r
SET slug = CONCAT('/rezepte-neu', SUBSTRING(r.slug, LENGTH('/rezepte') + 1))
WHERE r.parent_id IN (:parentIds)

TODO benchmark

About

Create a prototype for multi site, multi localization routing with history

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages