示例#1
0
 public function setUp()
 {
     parent::setUp();
     CroogoPlugin::unload('Example');
     CroogoPlugin::load('Shops');
     CroogoEventManager::loadListeners();
     $request = $this->getMock('CakeRequest');
     $response = $this->getMock('CakeResponse');
     $this->Users = new TestUsersEventController($request, $response);
     $this->Nodes = new TestNodesEventController($request, $response);
 }
示例#2
0
 /**
  * Activate plugin
  *
  * @param string $plugin Plugin name
  * @return boolean true when successful, false or error message when failed
  */
 public function activate($plugin)
 {
     if (CakePlugin::loaded($plugin)) {
         return __d('croogo', 'Plugin "%s" is already active.', $plugin);
     }
     $pluginActivation = $this->getActivator($plugin);
     if (!isset($pluginActivation) || isset($pluginActivation) && method_exists($pluginActivation, 'beforeActivation') && $pluginActivation->beforeActivation($this->_Controller)) {
         $pluginData = $this->getData($plugin);
         $dependencies = true;
         if (!empty($pluginData['dependencies']['plugins'])) {
             foreach ($pluginData['dependencies']['plugins'] as $requiredPlugin) {
                 $requiredPlugin = ucfirst($requiredPlugin);
                 if (!CakePlugin::loaded($requiredPlugin)) {
                     $dependencies = false;
                     $missingPlugin = $requiredPlugin;
                     break;
                 }
             }
         }
         if ($dependencies) {
             $this->addBootstrap($plugin);
             CroogoPlugin::load($plugin);
             if (isset($pluginActivation) && method_exists($pluginActivation, 'onActivation')) {
                 $pluginActivation->onActivation($this->_Controller);
             }
             Cache::delete('file_map', '_cake_core_');
             return true;
         } else {
             return __d('croogo', 'Plugin "%s" depends on "%s" plugin.', $plugin, $missingPlugin);
         }
         return __d('croogo', 'Plugin "%s" could not be activated. Please, try again.', $plugin);
     }
 }
示例#3
0
 */
if ($theme = Configure::read('Site.theme')) {
    App::build(array('View/Helper' => array(App::themePath($theme) . 'Helper' . DS)));
}
/**
 * List of core plugins
 */
Configure::write('Core.corePlugins', array('Settings', 'Acl', 'Blocks', 'Comments', 'Contacts', 'Menus', 'Meta', 'Nodes', 'Taxonomy', 'Users'));
/**
 * Plugins
 */
$aclPlugin = Configure::read('Site.acl_plugin');
$pluginBootstraps = Configure::read('Hook.bootstraps');
$plugins = array_filter(explode(',', $pluginBootstraps));
if (!in_array($aclPlugin, $plugins)) {
    $plugins = Hash::merge((array) $aclPlugin, $plugins);
}
foreach ($plugins as $plugin) {
    $pluginName = Inflector::camelize($plugin);
    if (!file_exists(APP . 'Plugin' . DS . $pluginName)) {
        CakeLog::write(LOG_ERR, 'Plugin not found during bootstrap: ' . $pluginName);
        continue;
    }
    $bootstrapFile = APP . 'Plugin' . DS . $pluginName . DS . 'Config' . DS . 'bootstrap.php';
    $bootstrap = file_exists($bootstrapFile);
    $routesFile = APP . 'Plugin' . DS . $pluginName . DS . 'Config' . DS . 'routes.php';
    $routes = file_exists($routesFile);
    $option = array($pluginName => array('bootstrap' => $bootstrap, 'routes' => $routes));
    CroogoPlugin::load($option);
}
CroogoEventManager::loadListeners();
示例#4
0
 /**
  * testUsedBy
  */
 public function testUsedBy()
 {
     Cache::delete('pluginDeps', 'cached_settings');
     CroogoPlugin::load('Widgets');
     CroogoPlugin::load('Editors');
     CroogoPlugin::load('Articles');
     CroogoPlugin::cacheDependencies();
     $usedBy = $this->CroogoPlugin->usedBy('Widgets');
     $this->assertTrue(in_array('Articles', $usedBy));
     $this->assertTrue(in_array('Editors', $usedBy));
     CroogoPlugin::unload('Articles');
     CroogoPlugin::unload('Editors');
     CroogoPlugin::unload('Widgets');
 }