Example #1
0
 /**
  * Initialization hook method.
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     Configure::write('Routing.prefix', $this->request->param('prefix'));
     $this->_setTheme();
     $this->_loadCoreComponents();
     Hook::applyComponents($this);
     $this->paginate['order'] = [$this->name . '.id' => 'DESC'];
 }
Example #2
0
 /**
  * Initialization hook method.
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     Hook::applyHelpers($this);
 }
Example #3
0
 /**
  * Test hook helpers configure.
  *
  * @return void
  */
 public function testHookConfigureHelpers()
 {
     $configKey = Hook::HOOK_CONFIG_KEY . '.' . Hook::HOOK_CONFIG_HELPER_KEY;
     //  Clear hook configure helper.
     Configure::write($configKey, []);
     Hook::helper('Simple', ['Pages']);
     $expected = ['Simple' => ['controllers' => ['Pages']]];
     $this->assertSame($expected, Configure::read($configKey));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     Hook::helper('Test', '*');
     $expected = ['Simple' => ['controllers' => ['Pages']], 'Test' => ['controllers' => '*']];
     $this->assertSame($expected, Configure::read($configKey));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     Hook::helper('Test', '*');
     $expected = ['Simple' => ['controllers' => ['Pages']], 'Test' => ['controllers' => '*']];
     $this->assertSame($expected, Configure::read($configKey));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     Hook::helper('Test', ['Users', 'Items']);
     $expected = ['Simple' => ['controllers' => ['Pages']], 'Test' => ['controllers' => '*']];
     $this->assertSame($expected, Configure::read($configKey));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     Hook::helper('Time', '*', ['param-1' => 'value-1', 'param-2' => 'value-2']);
     $expected = ['Simple' => ['controllers' => ['Pages']], 'Test' => ['controllers' => '*'], 'Time' => ['controllers' => '*', 'config' => ['param-1' => 'value-1', 'param-2' => 'value-2']]];
     $this->assertSame($expected, Configure::read($configKey));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     Hook::helper('Html', ['Users', 'Favorites', 'Pages'], ['param-1' => 'value-1', 'param-2' => 'value-2', 'param-3' => 'value-3']);
     $expected = ['Simple' => ['controllers' => ['Pages']], 'Test' => ['controllers' => '*'], 'Time' => ['controllers' => '*', 'config' => ['param-1' => 'value-1', 'param-2' => 'value-2']], 'Html' => ['controllers' => ['Users', 'Favorites', 'Pages'], 'config' => ['param-1' => 'value-1', 'param-2' => 'value-2', 'param-3' => 'value-3']]];
     $this->assertSame($expected, Configure::read($configKey));
 }
Example #4
0
/**
 * Union CMS configuration.
 *
 * - docDir     - html document dir
 * - iconPrefix - icon class prefix (Default is "Awesome Font")
 * - btnPrefix  - button prefix (Default is "Bootstrap Framework)
 */
Configure::write('Union', ['docDir' => 'ltr', 'iconPref' => 'fa', 'btnPref' => 'btn', 'lineTab' => '    ']);
Configure::write('Cache.defaultConfig', ['className' => 'File', 'duration' => '+1 hour', 'path' => CACHE . 'queries' . DS, 'prefix' => 'un_']);
/** @noinspection PhpIncludeInspection */
require_once dirname(__DIR__) . DS . 'src' . DS . 'functions.php';
/** @noinspection PhpIncludeInspection */
require_once __DIR__ . DS . 'defines.php';
//  Load union core events configure.
Configure::load('Union/Core.events');
//  Load helpers.
Hook::helper('Url', '*', ['className' => 'Union/Core.Url']);
Hook::helper('Html', '*', ['className' => 'Union/Core.Html']);
Hook::helper('Paginator', '*', ['className' => 'Union/Core.Paginator']);
Hook::helper('Form', '*', ['className' => 'Union/Core.Form', 'templates' => 'Union/Core.templates/form', 'widgets' => ['_default' => 'Union\\Core\\View\\Widget\\BasicWidget', 'button' => 'Union\\Core\\View\\Widget\\ButtonWidget', 'textarea' => 'Union\\Core\\View\\Widget\\TextAreaWidget']]);
Hook::helper('Union/Core.Js');
Hook::helper('Union/Core.Nav');
Hook::helper('Union/Core.Less');
Hook::helper('Union/Core.Union');
Hook::helper('Union/Core.Filter');
Hook::helper('Union/Core.Button');
Hook::helper('Union/Core.Layout');
Hook::helper('Union/Core.Assets');
Hook::helper('Union/Core.ToolBar');
Hook::helper('Union/Core.Document');
//  End load helpers
Example #5
0
<?php

/**
 * UnionCMS Community
 *
 * This file is part of the of the simple cms based on CakePHP 3.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   Community
 * @license   MIT
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
 * @link      https://github.com/UnionCMS/Community
 * @author    Sergey Kalistratov <*****@*****.**>
 */
use Cake\Cache\Cache;
use Cake\Core\Configure;
use Union\Core\Utility\Hook;
Hook::helper('Union/Community.Acl', ['Permissions']);
Hook::component('Auth', '*', ['className' => 'Union/Community.Auth', 'loginAction' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'login'], 'unauthorizedRedirect' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'login'], 'logoutRedirect' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'login'], 'authenticate' => ['Form' => ['contain' => 'Roles', 'userModel' => 'Union/Community.Users', 'scope' => ['Users.status' => PUBLISH_STATUS]]], 'authorize' => ['Union/Community.Base'], 'authError' => __d('community', 'You are not authorized to access that location.')]);
Hook::component('Acl.Acl', '*');
Hook::component('Union/Community.Community', '*');
Configure::write('Auth', ['loginBackendRedirect' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'index'], 'loginFrontendRedirect' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'edit']]);
//  Setup cache configuration for permissions.
Cache::config('permissions', array_merge(Configure::read('Cache.defaultConfig'), ['groups' => ['acl'], 'duration' => '+2 hour']));
//  Setup cache configuration for role from aro.
Cache::config('permission_roles', array_merge(Configure::read('Cache.defaultConfig'), ['groups' => ['roles'], 'duration' => '+1 week']));
Example #6
0
 /**
  * Initialization hook method.
  *
  * @return void
  */
 public function initialize()
 {
     $this->_path = vPath();
     Hook::applyHelpers($this);
 }