geniv / nette-alias-router
Database alias router extension for Nette Framework
v3.1.7
2019-05-11 16:31 UTC
Requires
- php: >=7.0
- dibi/dibi: >=3.0
- geniv/nette-locale: >=2.0
- latte/latte: >=2.4
- nette/application: >=2.4
- nette/caching: >=2.5
- nette/di: >=2.4
- nette/http: >=2.4
- nette/neon: >=2.4
- nette/utils: >=2.4
- tracy/tracy: >=2.4
- dev-master
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.2
- v3.0.1
- v3.0.0
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.2.1
- v1.2.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- dev-develop
This package is auto-updated.
Last update: 2024-12-12 05:10:15 UTC
README
Installation
$ composer require geniv/nette-alias-router
or
"geniv/nette-alias-router": "^3.1"
require:
"php": ">=7.0", "nette/application": ">=2.4", "nette/caching": ">=2.5", "nette/di": ">=2.4", "nette/http": ">=2.4", "nette/neon": ">=2.4", "nette/utils": ">=2.4", "latte/latte": ">=2.4", "tracy/tracy": ">=2.4", "dibi/dibi": ">=3.0", "geniv/nette-locale": ">=2.0"
Include in application
available source drivers:
- ArrayDriver (array)
- NeonDriver ()
- DibiDriver (dibi + cache
_AliasRouter-DibiDriver
)
In router alias is not good idea change last alias, but insert new alias with new datetime stamp.
neon configure:
route: cs: "staticky-slug": "Homepage:pokus" "staticky-slug1": "Homepage:pokus2" en: "static-slu": "Homepage:pokus" "static-slug1": "Homepage:pokus2" # alias router aliasRouter: # debugger: true # autowired: true # driver: AliasRouter\Drivers\ArrayDriver(%route%) # driver: AliasRouter\Drivers\NeonDriver(%appDir%/router.neon) driver: AliasRouter\Drivers\DibiDriver(%tablePrefix%) # enabled: true # domainAlias: # example.cz: cs # example.com: en # example.de: de
neon configure extension:
extensions: aliasRouter: AliasRouter\Bridges\Nette\Extension
Available interface: IAliasRouter
RouterFactory.php:
public static function createRouter(ILocale $locale, IAliasRouter $aliasRouter): IRouter ... if ($aliasRouter->isEnabled()) { $aliasRouter->setDefaultParameters('Homepage', 'default', 'cs'); $aliasRouter->setPaginatorVariable('visualPaginator-page'); //$aliasRouter->setSecure(true); //$aliasRouter->setOneWay(true); $router[] = $aliasRouter->getRouter(); }
usage @layout.latte:
{if $presenter->context->hasService('aliasRouter.default')} {ifset slug} {include slug|addSlug} {/ifset} {/if}
manual create or delete:
use AliasRouter\Drivers\IDriver; $this->context->getByType(IDriver::class)->deleteRouter('Homepage', 'default'); $this->context->getByType(IDriver::class)->createRouter('Homepage', 'default', 'muj alias'); $this->context->getByType(IDriver::class)->createRouter('Homepage', 'default', 'muj alias XX', ['locale' => 'en']);