Hi Pavel, yes it can be done in Router Group, However in multi module it needs to have group routes class every module i create.. so this is what I've done in router annotations:
// $this->getDI( )->get( 'config' )->urls->prefixes->toArray( ); // contains
'prefixes' => array(
':admin' => 'admin',
':frontend' => 'any/valid/url'
),
class Annotations extends \Phalcon\Mvc\Router\Annotations {
public function processControllerAnnotation ( $handler, $annotation ) {
$expr_arguments = $annotation->getExprArguments( );
$url_prefixes = $this->getDI( )->get( 'config' )->urls->prefixes->toArray( );
$url_searchs = array( );
$url_values = array( );
foreach ( $url_prefixes as $url_search => $url_value ) {
$url_searchs[] = $url_search;
$url_values[] = $url_value;
}
foreach ( $expr_arguments as $key => $expr_argument ) {
if ( isset( $expr_argument['expr']['value'] ) ) {
$expr_arguments[$key]['expr']['value'] = str_replace( $url_searchs, $url_values, $expr_argument['expr']['value'] );
}
}
$annotation = new \Phalcon\Annotations\Annotation( array(
'name' => $annotation->getName( ),
'arguments' => $expr_arguments
));
return parent::processControllerAnnotation ( $handler, $annotation );
}
}
then in my controller i indicate
/**
* Router Prefix
* @RoutePrefix( "/:admin/setting" )
*
*/
class SettingController extends \Phalcon\Mvc\Controller {
then i test it with
https://localhost/admin/setting
https://localhost/admin/any/valid/url/setting (Note: change the :admin to frontend)
and it works... i don't know if this is the best idea but it solveds my problem and this is the simplest idea i up come with... thanks..
if you have any/better idea plss comment it out below...