here is situation: I got a website by access diffrently level 3 domain name will response diffently html.
it's will support \Phalcon\Mvc\View setViewsDir can add more directories ?
or
can I overrides the \Phalcon\Mvc\View load file method ?
(I find the document about \Phalcon\Mvc\View , there is not support this. or maybe I just "blind" miss it. )
(if like to normal php framerwork use file then I can edit the source php files. but I want use Phalcon.)
I use dispatcher make transfer to other controller as default namespace.
here is my web directories:
webroot
|
|--...
|--controller
|--IndexController(Controller\)
|--private
|--10000
|--control
|--IndexController(Controller\Privater)
|--view(I want some diffent level 3 domain name got there own view html files if it's not exeists in the webroot\view directory )
|--public
|--view
example:
<?php
use
...
,\Phalcon\Loader
...
,\Phalcon\Mvc\Dispatcher
...
;
class Application extends Phalcon\Mvc\Application
{
public function main()
{
(new Loader())->registerNamespaces(
[
'Controller' => '../controller/',
'Model' => '../model/'
]
)->register();
...
$di->set('dispatcher', function () {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('Controller\\');
return $dispatcher;
},true);
...
$serverNameArray = explode(".",$this->request->getServerName());
if (file_exists("../private/{$serverNameArray[0]}/")){
(new Loader())->registerNamespaces(
[
"Controller\\Privater" => "../private/{$serverNameArray[0]}/controller",
]
)->register();
$this->dispatcher->setDefaultNamespace("Controller\\Privater");
}
...
}
}
try {
$application = new Application();
$application->main();
} catch (\Exception $e) {
echo $e->getMessage();
}