fix Определение пути к модулю
This commit is contained in:
parent
73112f5bf0
commit
ab13ebd289
2 changed files with 15 additions and 12 deletions
|
|
@ -44,23 +44,31 @@ class Front extends Action
|
|||
* @param Request $request Имя модуля
|
||||
* @return string
|
||||
*/
|
||||
public function loadModule($name, Collection $request, $controller = null)
|
||||
public function loadModule($name, Collection $request)
|
||||
{
|
||||
if ($this->isLoaded($name)) {
|
||||
$module = $this->modules[$name];
|
||||
return $module->access->execute($request);
|
||||
}
|
||||
|
||||
$parts = explode('\\', $name);
|
||||
|
||||
$config = $this->config;
|
||||
|
||||
$moulesPath = Path::join($config->get('system', 'path'), 'modules');
|
||||
$logPath = Path::join($config->get('site', 'path'), $config->get('system', 'access.log'));
|
||||
|
||||
$ucname = ucfirst($name);
|
||||
$moduleClass = "Modules\\$ucname\\$ucname";
|
||||
$first = $parts[0];
|
||||
$second = (count($parts) >= 2) ? $parts[1] : $parts[0];
|
||||
|
||||
$ucname = ucfirst($first);
|
||||
$ucpart = ucfirst($second);
|
||||
|
||||
$moduleClass = "Modules\\$ucname\\$ucpart";
|
||||
$module = new $moduleClass();
|
||||
if ($module) {
|
||||
// Инициализация модуля
|
||||
$modPath = Path::join($moulesPath, $name);
|
||||
$modPath = Path::join($moulesPath, $first);
|
||||
$module->modulePath = $modPath;
|
||||
$module->name = $name;
|
||||
//
|
||||
|
|
@ -87,14 +95,9 @@ class Front extends Action
|
|||
|
||||
public function execute(HttpRequest $request)
|
||||
{
|
||||
$name = explode("\\", $request->get('module', $this->default));
|
||||
if (count($name) >= 2) {
|
||||
$controller = $name[1];
|
||||
} else {
|
||||
$controller = null;
|
||||
}
|
||||
$name = $request->get('module', $this->default);
|
||||
try {
|
||||
return $this->loadModule($name[0], $request, $controller);
|
||||
return $this->loadModule($name, $request);
|
||||
} catch (UserMessageException $ex) { //Исключение с понятным пользователю сообщением
|
||||
$mode = $request->get('mode');
|
||||
if ($mode == 'ajax' || $mode == 'json') {
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class Form extends View {
|
|||
{
|
||||
foreach ($schema as $key => $conv) {
|
||||
list($value, $type) = $conv;
|
||||
$this->field [$key]->setValue(call_user_func(array('Primitive', 'from_' . $type), $data->$value));
|
||||
$this->field [$key]->setValue(call_user_func(array('ctiso\\Primitive', 'from_' . $type), $data->$value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue