Skip to content

Commit 3323b45

Browse files
author
Anton
authored
Merge pull request #309 from AntonShevchuk/master
Added hooks inside application bootstrap
2 parents 308159e + 50262e3 commit 3323b45

26 files changed

Lines changed: 213 additions & 172 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
.DS_Store
12
.idea
2-
/vendor/*
3+
vendor
34
composer.lock
45
composer.phar
56
codecept.phar

LICENSE.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
MIT License
2+
13
Copyright (c) 2012-2017 by Bluz PHP Team
24

35
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -7,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
79
copies of the Software, and to permit persons to whom the Software is
810
furnished to do so, subject to the following conditions:
911

10-
The above copyright notice and this permission notice shall be included in
11-
all copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1214

1315
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1416
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1517
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1618
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1719
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19-
THE SOFTWARE.
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

application/configs/default/php.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66
* @link http://php.net/manual/en/configuration.changes.modes.php
77
* @return array
88
*/
9-
return [
10-
'session.cache_expire' => '180', // 180 is default value
11-
];
9+
return [];

application/configs/phinx.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@
1616
'environments' => [
1717
'default_migration_table' => 'migrations',
1818
'default' => (function () {
19-
$config = new \Bluz\Config\Config();
20-
21-
$config->setPath(PATH_APPLICATION);
22-
$config->setEnvironment(getenv('BLUZ_ENV') ?: 'production');
23-
$config->init();
24-
25-
$data = $config->getData('db', 'connect');
19+
$data = \Bluz\Proxy\Config::getData('db', 'connect');
2620
$data['adapter'] = $data['type'];
27-
2821
return $data;
2922
})()
3023
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* PHP configuration
4+
*
5+
* @link http://php.net/manual/en/session.configuration.php
6+
* @link http://php.net/manual/en/configuration.changes.modes.php
7+
* @return array
8+
*/
9+
return [
10+
'session.cache_expire' => '180', // 180 is default value
11+
];

application/layouts/dashboard.phtml

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,7 @@
44
<?php require __DIR__ . '/partial/nav-bar.phtml'; ?>
55
<div class="container-fluid">
66
<div class="row">
7-
<nav class="col-sm-3 col-md-2 d-none d-sm-block bg-light sidebar">
8-
<hr/>
9-
<ul class="nav nav-pills flex-column">
10-
<li class="nav-item <?= ($this->module('pages') ? 'class="active"' : '') ?>">
11-
<?= $this->ahref(
12-
'<i class="fa fa-edit fa-fw"></i> ' . __('Pages'),
13-
['pages', 'grid', [], true],
14-
['class' => 'nav-link']
15-
) ?>
16-
</li>
17-
<li class="nav-item <?= ($this->module('users') ? 'class="active"' : '') ?>">
18-
<?= $this->ahref(
19-
'<i class="fa fa-user fa-fw"></i> ' . __('Users'),
20-
['users', 'grid', [], true],
21-
['class' => 'nav-link']
22-
) ?>
23-
</li>
24-
<?php if ($this->hasModule('media')) : ?>
25-
<li class="nav-item <?= ($this->module('media') ? 'class="active"' : '') ?>">
26-
<?= $this->ahref(
27-
'<i class="fa fa-picture-o fa-fw"></i> ' . __('Media'),
28-
['media', 'grid', [], true],
29-
['class' => 'nav-link']
30-
) ?>
31-
</li>
32-
<?php endif; ?>
33-
<?php if ($this->hasModule('categories')) : ?>
34-
<li class="nav-item <?= ($this->module('categories') ? 'class="active"' : '') ?>">
35-
<?= $this->ahref(
36-
'<i class="fa fa-folder-o fa-fw"></i> ' . __('Categories'),
37-
['categories', 'tree', [], true],
38-
['class' => 'nav-link']
39-
) ?>
40-
</li>
41-
<?php endif; ?>
42-
<li class="nav-item <?= ($this->module('acl') ? 'class="active"' : '') ?>">
43-
<?= $this->ahref(
44-
'<i class="fa fa-lock fa-fw"></i> ' . __('Permissions'),
45-
['acl', 'index', [], true],
46-
['class' => 'nav-link']
47-
) ?>
48-
</li>
49-
<?php if ($this->hasModule('options')) : ?>
50-
<li class="nav-item <?= ($this->module('options') ? 'class="active"' : '') ?>">
51-
<?= $this->ahref(
52-
'<i class="fa fa-th-list fa-fw"></i> ' . __('Options'),
53-
['options', 'grid', [], true],
54-
['class' => 'nav-link']
55-
) ?>
56-
</li>
57-
<?php endif; ?>
58-
<?php if ($this->hasModule('contact-us')) : ?>
59-
<li class="nav-item <?= ($this->module('contact-us') ? 'class="active"' : '') ?>">
60-
<?= $this->ahref(
61-
'<i class="fa fa-envelope-o fa-fw"></i> ' . __('Contact Us'),
62-
['contact-us', 'grid', [], true],
63-
['class' => 'nav-link']
64-
) ?>
65-
</li>
66-
<?php endif; ?>
67-
</ul>
68-
<hr/>
69-
<ul class="nav nav-pills flex-column">
70-
<li class="nav-item <?= ($this->module('system') ? 'class="active"' : '') ?>">
71-
<?= $this->ahref(
72-
'<i class="fa fa-wrench fa-fw"></i> ' . __('System'),
73-
['system', 'index', [], true],
74-
['class' => 'nav-link']
75-
) ?>
76-
</li>
77-
</ul>
78-
</nav>
7+
<?php require __DIR__ . '/partial/nav-menu.phtml'; ?>
798
<main class="col-sm-9 ml-sm-auto col-md-10 pt-3" role="main">
809
<?php require __DIR__.'/partial/breadcrumbs.phtml'; ?>
8110
<?php

application/layouts/partial/nav-bar.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</li>
4444
<?php endif; ?>
4545
</ul>
46-
<div id="loading"></div>
46+
<div id="loading" data-ajax-loading-show="1" data-ajax-loading-hide="1"></div>
4747
<span class="navbar-text">
4848
<?php if ($identity = $this->user()) : ?>
4949
<?= __(
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
<nav class="col-sm-3 col-md-2 d-none d-sm-block bg-light sidebar">
3+
<hr/>
4+
<ul class="nav nav-pills flex-column">
5+
<li class="nav-item <?= ($this->module('pages') ? 'active' : '') ?>">
6+
<?= $this->ahref(
7+
'<i class="fa fa-edit fa-fw"></i> ' . __('Pages'),
8+
['pages', 'grid', [], true],
9+
['class' => 'nav-link']
10+
) ?>
11+
</li>
12+
<li class="nav-item <?= ($this->module('users') ? 'active' : '') ?>">
13+
<?= $this->ahref(
14+
'<i class="fa fa-user fa-fw"></i> ' . __('Users'),
15+
['users', 'grid', [], true],
16+
['class' => 'nav-link']
17+
) ?>
18+
</li>
19+
<?php if ($this->hasModule('wallet')) : ?>
20+
<li class="nav-item <?= ($this->module('wallet') ? 'active' : '') ?>">
21+
<?= $this->ahref(
22+
'<i class="fa fa-credit-card fa-fw"></i> ' . __('Wallets'),
23+
['wallet', 'grid', [], true],
24+
['class' => 'nav-link']
25+
) ?>
26+
</li>
27+
<?php endif; ?>
28+
<?php if ($this->hasModule('media')) : ?>
29+
<li class="nav-item <?= ($this->module('media') ? 'active' : '') ?>">
30+
<?= $this->ahref(
31+
'<i class="fa fa-picture-o fa-fw"></i> ' . __('Media'),
32+
['media', 'grid', [], true],
33+
['class' => 'nav-link']
34+
) ?>
35+
</li>
36+
<?php endif; ?>
37+
<?php if ($this->hasModule('categories')) : ?>
38+
<li class="nav-item <?= ($this->module('categories') ? 'active' : '') ?>">
39+
<?= $this->ahref(
40+
'<i class="fa fa-folder-o fa-fw"></i> ' . __('Categories'),
41+
['categories', 'tree', [], true],
42+
['class' => 'nav-link']
43+
) ?>
44+
</li>
45+
<?php endif; ?>
46+
<li class="nav-item <?= ($this->module('acl') ? 'active' : '') ?>">
47+
<?= $this->ahref(
48+
'<i class="fa fa-lock fa-fw"></i> ' . __('Permissions'),
49+
['acl', 'index', [], true],
50+
['class' => 'nav-link']
51+
) ?>
52+
</li>
53+
<?php if ($this->hasModule('options')) : ?>
54+
<li class="nav-item <?= ($this->module('options') ? 'active' : '') ?>">
55+
<?= $this->ahref(
56+
'<i class="fa fa-th-list fa-fw"></i> ' . __('Options'),
57+
['options', 'grid', [], true],
58+
['class' => 'nav-link']
59+
) ?>
60+
</li>
61+
<?php endif; ?>
62+
<?php if ($this->hasModule('contact-us')) : ?>
63+
<li class="nav-item <?= ($this->module('contact-us') ? 'active' : '') ?>">
64+
<?= $this->ahref(
65+
'<i class="fa fa-envelope-o fa-fw"></i> ' . __('Contact Us'),
66+
['contact-us', 'grid', [], true],
67+
['class' => 'nav-link']
68+
) ?>
69+
</li>
70+
<?php endif; ?>
71+
</ul>
72+
<hr/>
73+
<ul class="nav nav-pills flex-column">
74+
<li class="nav-item <?= ($this->module('system') ? 'active' : '') ?>">
75+
<?= $this->ahref(
76+
'<i class="fa fa-wrench fa-fw"></i> ' . __('System'),
77+
['system', 'index', [], true],
78+
['class' => 'nav-link']
79+
) ?>
80+
</li>
81+
</ul>
82+
</nav>

application/library/Application/Bootstrap.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@
3333
*/
3434
class Bootstrap extends Application
3535
{
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
protected function preProcess()
40+
{
41+
parent::preProcess();
42+
43+
$path = $this->getPath() . '/modules';
44+
foreach (glob($path .'/*/init.php') as $initial) {
45+
(include $initial)($this);
46+
}
47+
}
48+
3649
/**
3750
* {@inheritdoc}
3851
*

application/modules/acl/controllers/index.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@
7676
$meta = $controllerInstance->getMeta();
7777

7878

79-
if ($privilege = $meta->getPrivilege()) {
80-
if (!in_array($privilege, $set[$module])) {
81-
$set[$module][] = $privilege;
82-
}
79+
if (($privilege = $meta->getPrivilege()) && !in_array($privilege, $set[$module], true)) {
80+
$set[$module][] = $privilege;
8381
}
8482

8583
if ($acl = $meta->getAcl()) {

0 commit comments

Comments
 (0)