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.
composer bootstrap-test-env
composer test
Skip the
heavy_load
tests if you don't want to wait for a long time.
- 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
- Site A with
- Add Multi Site tests
- Add Multi Localization tests
There are different kind of queries possible. The example uses ~100.000 routes and about ~40.000 need to be updated:
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
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
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
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
UPDATE route r
SET slug = CONCAT('/rezepte-neu', SUBSTRING(r.slug, LENGTH('/rezepte') + 1))
WHERE r.id IN (:childIds)
TODO benchmark
UPDATE route r
SET slug = CONCAT('/rezepte-neu', SUBSTRING(r.slug, LENGTH('/rezepte') + 1))
WHERE r.parent_id IN (:parentIds)
TODO benchmark