Skip to content

Commit 189c2b1

Browse files
committed
added ControllerMap for Elfinder
1 parent f2100b0 commit 189c2b1

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

src/Bootstrap.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,47 @@ public function bootstrap($app)
1818
$app->urlManager->addRules([
1919
$prefix.'/<route:[a-zA-Z0-9-/]+>' => '/cms/page/view'
2020
]);
21+
22+
<?php
23+
24+
namespace nullref\cms;
25+
26+
27+
use yii\base\ActionEvent;
28+
use yii\base\Application;
29+
use yii\base\BootstrapInterface;
30+
use yii\base\Controller;
31+
use yii\base\Event;
32+
use yii\web\ErrorAction;
33+
use yii\web\Application as WebApplication;
34+
35+
class Bootstrap implements BootstrapInterface
36+
{
37+
public function bootstrap($app)
38+
{
39+
$prefix = $app->getModule('cms')->urlPrefix;
40+
$app->urlManager->addRules([
41+
$prefix . '/<route:[a-zA-Z0-9-/]+>' => '/cms/page/view'
42+
]);
43+
44+
if ($app instanceof WebApplication) {
45+
$app->controllerMap['elfinder-backend'] = [
46+
'class' => 'mihaildev\elfinder\Controller',
47+
'user' => 'admin',
48+
'access' => ['@'],
49+
'disabledCommands' => ['netmount'],
50+
'roots' => [
51+
[
52+
'path' => 'uploads',
53+
'name' => 'Uploads'
54+
],
55+
],
56+
];
57+
}
58+
}
59+
60+
}
61+
2162
}
2263

2364
}

src/Installer.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace nullref\cms;
77

8-
98
use nullref\core\components\ModuleInstaller;
109
use Yii;
10+
use yii\helpers\Console;
1111

1212
class Installer extends ModuleInstaller
1313
{
@@ -16,4 +16,18 @@ public function getModuleId()
1616
return 'cms';
1717
}
1818

19+
public function install()
20+
{
21+
parent::install();
22+
if (Console::confirm('Create upload folder?')) {
23+
try {
24+
$this->createFolder('@webroot/uploads');
25+
echo 'Folder @webroot/uploads was created' . PHP_EOL;
26+
} catch (\Exception $e) {
27+
echo $e->getMessage() . PHP_EOL;
28+
}
29+
}
30+
}
31+
32+
1933
}

0 commit comments

Comments
 (0)