}); Request::addDetector('tablet', function ($request) { $detector = new \Detection\MobileDetect(); return $detector->isTablet(); }); // Load union core plugin. Plugin::load('Union/Core', ['bootstrap' => true, 'routes' => true]); Plugin::load('Migrations'); // Load DebugKit plugin. if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } $plugins = ROOT . '/config/plugins.php'; if (file_exists($plugins)) { /** @noinspection PhpIncludeInspection */ $plugins = (include $plugins); if (is_array($plugins)) { \Union\Core\Plugin::loadList($plugins); } } // Connect middleware/dispatcher filters. DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); /** * Enable default locale format parsing. * This is needed for matching the auto-localized string output of Time() class when parsing dates. */ Type::build('date')->useLocaleParser(); Type::build('datetime')->useLocaleParser(); EventManager::loadListeners();
/** * Setup test data. * * @return void */ public function setUp() { parent::setUp(); Plugin::loadList(['TestPlugin']); EventManager::loadListeners(); }
/** * Test plugin load by list. * * @return void */ public function testLoadList() { $Folder = new Folder(); $pluginsDir = APP_ROOT . 'Plugins' . DS; $TestPlgPath = $pluginsDir . 'PluginTest'; $Folder->create($TestPlgPath, 0777); new File($TestPlgPath . '/config/bootstrap.php', true); new File($TestPlgPath . '/config/routes.php', true); $NoRoutesPlgPath = $pluginsDir . 'NoRoutes'; $Folder->create($NoRoutesPlgPath, 0777); new File($NoRoutesPlgPath . '/config/bootstrap.php', true); $NoBootstrapPlgPath = $pluginsDir . 'NoBootstrap'; $Folder->create($NoBootstrapPlgPath, 0777); new File($NoBootstrapPlgPath . '/config/routes.php', true); $NoConfigPlgPath = $pluginsDir . 'NoConfig'; $Folder->create($NoConfigPlgPath, 0777); Plugin::load('Migrations'); Plugin::loadList(['NoConfig', 'NoRoutes', 'PluginTest', 'Migrations', 'NoBootstrap']); $this->assertTrue(Plugin::loaded('NoBootstrap')); $this->assertTrue(Plugin::loaded('PluginTest')); $this->assertTrue(Plugin::loaded('NoRoutes')); $this->assertTrue(Plugin::loaded('NoConfig')); // Check virtual paths. $this->assertSame(1, count(vPath()->getPaths('NoBootstrap:'))); $this->assertSame(1, count(vPath()->getPaths('PluginTest:'))); $this->assertSame(1, count(vPath()->getPaths('NoRoutes:'))); $this->assertSame(1, count(vPath()->getPaths('NoConfig:'))); $Folder->delete($TestPlgPath); $Folder->delete($NoRoutesPlgPath); $Folder->delete($NoConfigPlgPath); $Folder->delete($NoBootstrapPlgPath); }