예제 #1
0
 /**
  * Check action by path.
  *
  * @param string $path
  * @return bool
  */
 public function hasAction($path)
 {
     $action = explode('/', $path);
     $action = end($action);
     $details = explode('/', $path, 3);
     if (count($details) <= 2) {
         return false;
     }
     list($type, $vendor, $ns) = $details;
     if (Plugin::loaded($vendor) === true) {
         $vendor = FS::clean($vendor, '/');
         $nsDetails = explode('/', $ns);
         $type = $this->_currentType($type);
         unset($nsDetails[count($nsDetails) - 1]);
         $namespace = implode('/', $nsDetails);
         $namespace = FS::clean(implode('\\', [$vendor, $type, $namespace . $type]), '\\');
         return method_exists($namespace, $action);
     }
     $details = explode('/', $path, 2);
     list($type, $vendor) = $details;
     $type = $this->_currentType($type);
     $nsDetails = explode('/', FS::clean($vendor, '/'));
     unset($nsDetails[count($nsDetails) - 1]);
     $defVendor = Configure::read('App.namespace');
     $namespace = implode('/', $nsDetails);
     $namespace = FS::clean(implode('\\', [$defVendor, $type, $namespace . $type]), '\\');
     return method_exists($namespace, $action);
 }
예제 #2
0
 /**
  * On setup admin application.
  *
  * @return void
  */
 protected function _onSetupAdmin()
 {
     $plugins = (array) Plugin::loaded();
     foreach ($plugins as $plugin) {
         $path = Plugin::path($plugin);
         $navConf = $path . 'config' . DS . self::ADMIN_MENU_FILE_NAME . '.php';
         if (file_exists($navConf)) {
             /** @noinspection PhpIncludeInspection */
             require_once $navConf;
         }
     }
 }
예제 #3
0
 /**
  * Simple test application.
  *
  * @return void
  */
 public function testAppController()
 {
     $controller = new AppController();
     $this->assertSame('App', $controller->name);
     $this->assertTrue(Plugin::loaded('TestPlugin'));
 }
예제 #4
0
 /**
  * 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);
 }
예제 #5
0
파일: AppView.php 프로젝트: UnionCMS/Core
 /**
  * Splits a dot syntax plugin name into its plugin and filename.
  *
  * @param string $name
  * @param bool|true $fallback
  * @return array
  */
 public function pluginSplit($name, $fallback = true)
 {
     $plugin = null;
     list($first, $second) = pluginSplit($name);
     if (Plugin::loaded($first) === true) {
         $name = $second;
         $plugin = $first;
     }
     if (isset($this->plugin) && !$plugin && $fallback) {
         $plugin = $this->plugin;
     }
     return [normalizeName($plugin), $name];
 }