Skip to content

Commit

Permalink
Update plugin. Stop recursion when using sendErrorPage method
Browse files Browse the repository at this point in the history
  • Loading branch information
vanchelo committed Dec 21, 2014
1 parent eed4fbb commit 8c1de72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

Если запрошенному URL не соответствует ни один объявленный маршрут, будет сгенерированна 404 ошибка.

Чтобы запрос не вошел в рекурсию при использовании в своих сниппетах и компонентах метода `sendErrorPage`, необходимо передать в метод `array('stop' => true)`. Должно получится вот так:

```php
$modx->sendErrorPage(array('stop' => true));
```

Все именнованные параметры попадут в массив `fastrouter` в глобальном массиве `$_REQUEST`. В нашем случае по первому маршруту, например `http://site.com/fastrouter/vanchelo/10` получим вот такие данные:
```php
var_dump($_REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

$router = new FastRouter($modx);

if ($modx->event->name == 'OnPageNotFound') {
if ($modx->event->name == 'OnPageNotFound' && !isset($modx->event->params['stop'])) {
$router->dispatch();
} else if ($modx->event->name == 'OnChunkSave' && $chunk->name == 'fastrouter') {
$router->clearCache();
Expand Down

0 comments on commit 8c1de72

Please sign in to comment.