Exemplo n.º 1
0
 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @return Phinx\Config\Config
  */
 public function getConfig()
 {
     if ($this->configuration) {
         return $this->configuration;
     }
     $folder = 'Migrations';
     if ($this->input->getOption('source')) {
         $folder = $this->input->getOption('source');
     }
     $dir = ROOT . DS . 'config' . DS . $folder;
     $plugin = null;
     if ($this->input->getOption('plugin')) {
         $plugin = $this->input->getOption('plugin');
         $dir = Plugin::path($plugin) . 'config' . DS . $folder;
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
     $plugin = str_replace(array('\\', '/', '.'), '_', $plugin);
     $connection = 'default';
     if ($this->input->getOption('connection')) {
         $connection = $this->input->getOption('connection');
     }
     $config = ConnectionManager::config($connection);
     return $this->configuration = new Config(['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $this->getAdapterName($config['driver']), 'host' => isset($config['host']) ? $config['host'] : null, 'user' => isset($config['username']) ? $config['username'] : null, 'pass' => isset($config['password']) ? $config['password'] : null, 'port' => isset($config['port']) ? $config['port'] : null, 'name' => $config['database'], 'charset' => $config['encoding']]]]);
 }
 public function callback()
 {
     if (Plugin::loaded('Passengers')) {
         $session = $this->request->session();
         $user = $session->read('Auth.User');
         if (!isset($user['id'])) {
             exit;
         }
     }
     $opts = Configure::read('Summernote.elFinder');
     foreach ($opts['roots'] as $key => $root) {
         if (isset($root['primary']) || $root['primary'] === true) {
             if (Plugin::loaded('Passengers') && $user['role_id'] != 4) {
                 $root['path'] .= DS . 'users_content' . DS . 'user_' . $user['id'];
                 $root['URL'] .= 'users_content/user_' . $user['id'] . '/';
             }
         }
         if ($dir = new Folder($root['path'], true, 0755)) {
             $opts['roots'][$key]['path'] = $root['path'];
             $opts['roots'][$key]['URL'] = $root['URL'];
         }
         unset($dir);
     }
     // run elFinder
     $connector = new elFinderConnector(new elFinder($opts));
     $connector->run();
 }
Exemplo n.º 3
0
 /**
  * Builds asset file path based off url
  *
  * @param string $url Asset URL
  * @return string Absolute path for asset file
  */
 protected function _getAssetFile($url)
 {
     //Brood unload hack cause vendor plugin loaded for some reason
     Plugin::unload('Garderobe');
     $parts = explode('/', $url);
     $fileType = array_shift($parts);
     $fileFragment = implode(DS, $parts);
     $allowedExtensions = ComponentInstallerConfigureTrait::getSupportedExtensions();
     $registeredComponents = (require ROOT . DS . 'vendor' . DS . 'cakephp-components.php');
     foreach ($registeredComponents as $component) {
         $extensions = implode('|', $allowedExtensions);
         if (preg_match("/({$extensions})\$/i", $fileFragment)) {
             foreach ($component as $type => $chunk) {
                 if ($fileType != $type) {
                     continue;
                 }
                 $path = ROOT . DS . Configure::read('App.webroot') . DS . $chunk . DS;
                 if (Configure::read('debug') == false && !strpos($fileFragment, 'min')) {
                     $fileFragment = preg_replace("/(css|js)\$/i", "min.\$1", $fileFragment);
                 }
                 if (file_exists($path . $fileFragment)) {
                     return $path . $fileFragment;
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Tear down method.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('Union/Core');
     Plugin::unload('TestPlugin');
     unset($this->ToolBar, $this->View);
 }
Exemplo n.º 5
0
 public function onControllerInit(Event $event)
 {
     $controller = $event->subject();
     //Skip Auth for non app controllers. DebugKit For example
     //possible injection hole, but needed.
     if (!in_array('App\\Controller\\AppController', class_parents($controller))) {
         return;
     }
     $controller->loadComponent('Cookie');
     $loginRedirect = '/';
     if (isset($controller->request->params['prefix'])) {
         $loginRedirect .= $controller->request->params['prefix'];
     }
     $controller->loadComponent('Auth', ['loginAction' => ['plugin' => 'Passengers', 'controller' => 'Users', 'action' => 'signin'], 'loginRedirect' => $loginRedirect, 'logoutRedirect' => ['plugin' => 'Passengers', 'controller' => 'Users', 'action' => 'signin'], 'unauthorizedRedirect' => ['plugin' => 'Passengers', 'controller' => 'Users', 'action' => 'signin'], 'authenticate' => [AuthComponent::ALL => ['fields' => ['username' => 'username', 'password' => 'password'], 'userModel' => 'Passengers.Users', 'finder' => 'active'], 'Form', 'Passengers.Cookie']]);
     $authorizeConfig = [];
     if ($authorizers = Configure::read('Passengers.authorizers')) {
         foreach ($authorizers as $key => $authorizer) {
             if (isset($authorizer['className']) && ($plugin = pluginSplit($authorizer['className'])[0])) {
                 if (!Plugin::loaded($plugin)) {
                     continue;
                 }
             }
             $authorizeConfig[$key] = $authorizer;
         }
     }
     $forceAuth = Configure::read('App.force_user_auth');
     if ($forceAuth && empty($authorizeConfig)) {
         $authorizeConfig[] = 'Controller';
     }
     $controller->Auth->config('authorize', array(AuthComponent::ALL => ['actionPath' => 'controllers/']) + $authorizeConfig);
     $this->_setUser($controller);
     $controller->loadComponent('Passengers.AuthUser');
     $controller->viewBuilder()->helpers(['Passengers.AuthUser']);
 }
Exemplo n.º 6
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Shell);
     Configure::write('App.namespace', 'App');
     Plugin::unload();
 }
 public function injectEditor(Event $event, $layoutFile)
 {
     $_view = $event->subject();
     $content = $_view->fetch('content');
     if (Configure::read('Editorial.autoload')) {
         $searchClass = Configure::read('Editorial.autoload');
         if (empty($searchClass)) {
             $searchClass = 'editor';
         }
         $plugin = Configure::read('Editorial.editor');
         list($vendor, $class) = $this->vendorSplit($plugin);
         $searchRegex = '/(<textarea.*class\\=\\".*' . Configure::read('Editorial.class') . '.*\\"[^>]*>.*<\\/textarea>)/isU';
         //preg_match_all($searchRegex, $content, $matches);
         //debug($matches);
         if (Plugin::loaded($plugin) !== false && preg_match_all($searchRegex, $content, $matches)) {
             if (!$_view->helpers()->has('Editor')) {
                 $options['className'] = $class . '.' . $class;
                 if ($vendor) {
                     $options['className'] = $vendor . '/' . $options['className'];
                 }
                 $options['options'] = $plugin . '.defaults';
                 if ($editorDefaults = Configure::read('Editorial.' . $class . '.defaults')) {
                     $options['options'] = $editorDefaults;
                 }
                 $_view->loadHelper('Editor', $options);
                 $_view->Editor->initialize();
             }
             $_view->Editor->connect($content);
         }
     }
 }
 /**
  * @return void
  */
 public function setUp()
 {
     Configure::write('Roles', ['user' => 1, 'moderator' => 2, 'admin' => 3]);
     $this->config = ['filePath' => Plugin::path('TinyAuth') . 'tests' . DS . 'test_files' . DS, 'autoClearCache' => true];
     $this->View = new View();
     $this->AuthUserHelper = new AuthUserHelper($this->View, $this->config);
 }
Exemplo n.º 9
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     $_SESSION = [];
     unset($this->View, $this->Session);
     Plugin::unload();
     parent::tearDown();
 }
Exemplo n.º 10
0
 /**
  * @param $plugins
  * @param $options
  *
  * @throws \makallio85\YamlRoute\Exception\PluginException
  */
 public function load($plugins, $options)
 {
     $routes = isset($options['routes']) && $options['routes'] === true ? true : false;
     $options['routes'] = false;
     CakePlugin::load($plugins, $options);
     if ($routes) {
         if (!is_array($plugins)) {
             $plugins = [$plugins];
         }
         foreach ($plugins as $plugin) {
             if ($this->isLoaded($plugin)) {
                 throw new Exception\PluginException("Plugin {$plugin} is loaded already and should not be loaded twice.");
             }
             $path = Configure::read('plugins')[$plugin] . DS . 'config' . DS . 'routes.yml';
             if (!file_exists($path)) {
                 throw new Exception\PluginException("Yaml route configuration file not found in path {$path}.");
             }
             $route = Yaml::parse(file_get_contents($path));
             $data = ['name' => $plugin, 'route' => $route, 'file' => $path];
             $this->_addLoaded($plugin, $data);
             $data['route'] = $this->_loadRouteConfigs($route);
             Validator::run($data);
             $this->_updateLoaded($plugin, $data);
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @param bool $forceRefresh
  * @return \Phinx\Config\Config
  */
 public function getConfig($forceRefresh = false)
 {
     if ($this->configuration && $forceRefresh === false) {
         return $this->configuration;
     }
     $folder = 'Migrations';
     if ($this->input->getOption('source')) {
         $folder = $this->input->getOption('source');
     }
     $dir = ROOT . DS . 'config' . DS . $folder;
     $plugin = null;
     if ($this->input->getOption('plugin')) {
         $plugin = $this->input->getOption('plugin');
         $dir = Plugin::path($plugin) . 'config' . DS . $folder;
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
     $plugin = str_replace(['\\', '/', '.'], '_', $plugin);
     $connection = $this->getConnectionName($this->input);
     $connectionConfig = ConnectionManager::config($connection);
     $adapterName = $this->getAdapterName($connectionConfig['driver']);
     $config = ['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $adapterName, 'host' => isset($connectionConfig['host']) ? $connectionConfig['host'] : null, 'user' => isset($connectionConfig['username']) ? $connectionConfig['username'] : null, 'pass' => isset($connectionConfig['password']) ? $connectionConfig['password'] : null, 'port' => isset($connectionConfig['port']) ? $connectionConfig['port'] : null, 'name' => $connectionConfig['database'], 'charset' => isset($connectionConfig['encoding']) ? $connectionConfig['encoding'] : null, 'unix_socket' => isset($connectionConfig['unix_socket']) ? $connectionConfig['unix_socket'] : null]]];
     if ($adapterName === 'mysql') {
         if (!empty($connectionConfig['ssl_key']) && !empty($connectionConfig['ssl_cert'])) {
             $config['environments']['default']['mysql_attr_ssl_key'] = $connectionConfig['ssl_key'];
             $config['environments']['default']['mysql_attr_ssl_cert'] = $connectionConfig['ssl_cert'];
         }
         if (!empty($connectionConfig['ssl_ca'])) {
             $config['environments']['default']['mysql_attr_ssl_ca'] = $connectionConfig['ssl_ca'];
         }
     }
     return $this->configuration = new Config($config);
 }
Exemplo n.º 12
0
 public static function load($name)
 {
     $path = THREEPLUGINS . $name;
     if (file_exists($path . DS . 'plugin.ini')) {
         $basename = basename($path);
         $config = (new IniReader())->readFile($path . DS . 'plugin.ini')->toArray();
         if (array_key_exists('enabled', $config) && $config['enabled'] === true) {
             if (\Cake\Core\Plugin::loaded('ThreePlugins/' . $basename) === true) {
                 return true;
             }
             if (array_key_exists('depend', $config)) {
                 if (is_array($config['depend'])) {
                     foreach ($config['depend'] as $v) {
                         if (!\Cake\Core\Plugin::loaded($v) && self::load($v) !== true) {
                             throw new MissingDependencyException('Missing dependency ' . $v . ' for plugin ' . $name);
                         }
                     }
                 } else {
                     if (!\Cake\Core\Plugin::loaded($config['depend']) && self::load($config['depend']) !== true) {
                         throw new MissingDependencyException('Missing dependency ' . $config['depend'] . ' for plugin ' . $name);
                     }
                 }
             }
             \Cake\Core\Plugin::load('ThreePlugins/' . $basename, ['autoload' => true, 'bootstrap' => array_key_exists('bootstrap', $config) ? $config['bootstrap'] : false, 'routes' => array_key_exists('routes', $config) ? $config['routes'] : false]);
             $class = '\\ThreePlugins\\' . $basename . '\\' . $basename . 'Plugin';
             if (!class_exists($class)) {
                 throw new FileNotFoundException('Missing class ' . $class . ' into the plugin ' . $name);
             }
             (new $class())->initialize();
             return true;
         }
     }
     return false;
 }
Exemplo n.º 13
0
 /**
  * Return the webroot path to the image generated variant if this exist or to the controller if not.
  *
  * @param string $imagePath         Path to the original image file from webroot if absolute, or relative to img/
  * @param string|array $variantName Name of the variant configuration key or options array
  * @param array $options            options
  * @return string
  */
 public function variant($imagePath, $variantName, array $options = [])
 {
     if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
         list($plugin, $imagePath) = $this->_View->pluginSplit($imagePath, false);
     }
     $url = false;
     $imagePath = $imagePath[0] === '/' ? substr($imagePath, 1) : $imagePath;
     if (!isset($plugin)) {
         $originalFile = WWW_ROOT . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         }
     } else {
         $originalFile = WWW_ROOT . Inflector::underscore($plugin) . DS . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         } else {
             $originalFile = Plugin::path($plugin) . 'webroot' . DS . $imagePath;
             $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
             if (is_file($variantFile)) {
                 $url = str_replace(Plugin::path($plugin) . 'webroot' . DS, '/' . Inflector::underscore($plugin) . '/', $variantFile);
                 $url = str_replace(DS, '/', $url);
             }
         }
     }
     if ($url === false) {
         $url = ['controller' => 'Presenter', 'action' => 'variant', 'plugin' => 'ImagePresenter', 'prefix' => false, '?' => ['image' => isset($plugin) ? "{$plugin}.{$imagePath}" : $imagePath, 'variant' => $variantName]];
     }
     return Router::url($url);
 }
Exemplo n.º 14
0
 /**
  * @return void
  */
 public function testBuildResetWithPlugin()
 {
     Router::connect('/:controller/:action/*');
     $result = $this->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
     $expected = '/foobar/test';
     $this->assertSame($expected, $result);
     $this->Url->request->here = '/admin/foo/bar/baz/test';
     $this->Url->request->params['prefix'] = 'admin';
     $this->Url->request->params['plugin'] = 'Foo';
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::plugin('Foo', function ($routes) {
         $routes->fallbacks();
     });
     Router::prefix('admin', function ($routes) {
         $routes->plugin('Foo', function ($routes) {
             $routes->fallbacks();
         });
     });
     Plugin::routes();
     Router::pushRequest($this->Url->request);
     $result = $this->Url->build(['controller' => 'bar', 'action' => 'baz', 'x']);
     $expected = '/admin/foo/bar/baz/x';
     $this->assertSame($expected, $result);
     $result = $this->Url->buildReset(['controller' => 'bar', 'action' => 'baz', 'x']);
     $expected = '/bar/baz/x';
     $this->assertSame($expected, $result);
 }
 /**
  * Wrap Moxiemanager's api.php in a controller action.
  *
  * @return void
  */
 public function api()
 {
     try {
         $pluginPath = Plugin::path('CkTools');
         define('MOXMAN_CLASSES', $pluginPath . 'src/Lib/moxiemanager/classes');
         define('MOXMAN_PLUGINS', $pluginPath . 'src/Lib/moxiemanager/plugins');
         define('MOXMAN_ROOT', $pluginPath . 'src/Lib/moxiemanager');
         define('MOXMAN_API_FILE', __FILE__);
         $appConfig = Configure::read('CkTools.moxiemanager');
         Configure::load('CkTools.moxiemanager');
         $moxieManagerConfig = Configure::read('moxiemanager');
         if (is_array($appConfig)) {
             $moxieManagerConfig = Hash::merge($moxieManagerConfig, $appConfig);
         }
         $GLOBALS['moxieManagerConfig'] = $moxieManagerConfig;
         require_once MOXMAN_CLASSES . '/MOXMAN.php';
         $context = \MOXMAN_Http_Context::getCurrent();
         $pluginManager = \MOXMAN::getPluginManager();
         foreach ($pluginManager->getAll() as $plugin) {
             if ($plugin instanceof \MOXMAN_Http_IHandler) {
                 $plugin->processRequest($context);
             }
         }
     } catch (Exception $e) {
         \MOXMAN_Exception::printException($e);
     }
     return $this->render(false, false);
 }
Exemplo n.º 16
0
 /**
  * Find the paths to all the installed shell templates in the app.
  *
  * Bake templates are directories under `Template/Bake` path.
  * They are listed in this order: app -> plugin -> default
  *
  * @return array Array of bake templates that are installed.
  */
 protected function _findTemplates()
 {
     $paths = App::path('Template');
     $plugins = Plugin::loaded();
     foreach ($plugins as $plugin) {
         $paths[] = Plugin::classPath($plugin) . 'Template' . DS;
     }
     $core = current(App::core('Template'));
     $Folder = new Folder($core . 'Bake' . DS . 'default');
     $contents = $Folder->read();
     $templateFolders = $contents[0];
     $paths[] = $core;
     foreach ($paths as $i => $path) {
         $paths[$i] = rtrim($path, DS) . DS;
     }
     $this->_io->verbose('Found the following bake templates:');
     $templates = [];
     foreach ($paths as $path) {
         $Folder = new Folder($path . 'Bake', false);
         $contents = $Folder->read();
         $subDirs = $contents[0];
         foreach ($subDirs as $dir) {
             $Folder = new Folder($path . 'Bake' . DS . $dir);
             $contents = $Folder->read();
             $subDirs = $contents[0];
             if (array_intersect($contents[0], $templateFolders)) {
                 $templateDir = $path . 'Bake' . DS . $dir . DS;
                 $templates[$dir] = $templateDir;
                 $this->_io->verbose(sprintf("- %s -> %s", $dir, $templateDir));
             }
         }
     }
     return $templates;
 }
Exemplo n.º 17
0
 public function onControllerInit($event)
 {
     $controller = $event->subject();
     if (($theme = Configure::read('App.theme')) && Plugin::loaded($theme)) {
         $controller->viewBuilder()->theme($theme);
     }
 }
Exemplo n.º 18
0
 /**
  * HtmlHelperTest::testImageFromBlob()
  *
  * @return void
  */
 public function testImageFromBlob()
 {
     $folder = Plugin::path('Tools') . 'tests' . DS . 'test_files' . DS . 'img' . DS;
     $content = file_get_contents($folder . 'hotel.png');
     $is = $this->Html->imageFromBlob($content);
     $this->assertTrue(!empty($is));
 }
 /**
  * Constructor
  *
  * @param string $message
  * @param int $code Status code, defaults to 500
  */
 public function __construct($message = null, $code = 500)
 {
     if (empty($message)) {
         $message = 'Please copy "' . Plugin::configPath('FrankFoerster/Bitly') . 'bitly.example.php" to "' . CONFIG . 'bitly.php".';
     }
     parent::__construct($message, $code);
 }
Exemplo n.º 20
0
 /**
  * Test loading templates files from a plugin
  *
  * @return void
  */
 public function testAddPluginWidgetsFromConfigInConstuctor()
 {
     Plugin::load('TestPlugin');
     $widgets = ['text' => ['Cake\\View\\Widget\\BasicWidget'], 'TestPlugin.test_widgets'];
     $inputs = new WidgetRegistry($this->templates, $this->view, $widgets);
     $this->assertInstanceOf('Cake\\View\\Widget\\LabelWidget', $inputs->get('text'));
 }
Exemplo n.º 21
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload();
     DispatcherFactory::clear();
     $this->Case->controller = null;
 }
 public function index()
 {
     if (Plugin::loaded('Search')) {
         $this->Currencies->addBehavior('Search.Searchable');
         $this->Common->loadComponent('Search.Prg');
         $this->Prg->commonProcess();
         $currencies = $this->paginate($this->Currencies->find('searchable', $this->Prg->parsedParams()));
     } else {
         $currencies = $this->paginate();
     }
     $baseCurrency = [];
     foreach ($currencies as $currency) {
         if ($currency['Currency']['base']) {
             $baseCurrency = $currency;
             break;
         }
     }
     if (empty($baseCurrency)) {
         $baseCurrency = $this->Currencies->find('first', ['conditions' => ['base' => true]]);
         if (!$baseCurrency) {
             $this->Flash->warning(__('noBaseCurrency'));
         }
     }
     $this->set(compact('baseCurrency', 'currencies'));
 }
 /**
  * Test config() method with plugin syntax aliases
  *
  * @return void
  */
 public function testConfigPlugin()
 {
     Plugin::load('TestPlugin');
     $data = ['connection' => 'testing', 'entityClass' => 'TestPlugin\\Model\\Entity\\Comment'];
     $result = $this->_locator->config('TestPlugin.TestPluginComments', $data);
     $this->assertEquals($data, $result, 'Returns config data.');
 }
Exemplo n.º 24
0
 /**
  * Inits PO file from POT file.
  *
  * @param string|null $language Language code to use.
  * @return int|null
  */
 public function init($language = null)
 {
     if (!$language) {
         $language = $this->in('Please specify language code, e.g. `en`, `eng`, `en_US` etc.');
     }
     if (strlen($language) < 2) {
         return $this->error('Invalid language code. Valid is `en`, `eng`, `en_US` etc.');
     }
     $this->_paths = [APP];
     if ($this->param('plugin')) {
         $plugin = Inflector::camelize($this->param('plugin'));
         $this->_paths = [Plugin::classPath($plugin)];
     }
     $response = $this->in('What folder?', null, rtrim($this->_paths[0], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'Locale');
     $sourceFolder = rtrim($response, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $targetFolder = $sourceFolder . $language . DIRECTORY_SEPARATOR;
     if (!is_dir($targetFolder)) {
         mkdir($targetFolder, 0775, true);
     }
     $count = 0;
     $iterator = new DirectoryIterator($sourceFolder);
     foreach ($iterator as $fileinfo) {
         if (!$fileinfo->isFile()) {
             continue;
         }
         $filename = $fileinfo->getFilename();
         $newFilename = $fileinfo->getBasename('.pot');
         $newFilename = $newFilename . '.po';
         $this->createFile($targetFolder . $newFilename, file_get_contents($sourceFolder . $filename));
         $count++;
     }
     $this->out('Generated ' . $count . ' PO files in ' . $targetFolder);
 }
Exemplo n.º 25
0
 /**
  * Tear down method.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('Union/Core');
     Plugin::unload('TestPlugin');
     unset($this->Controller, $this->App);
 }
Exemplo n.º 26
0
 /**
  * Overwrite shell initialize to dynamically load all Queue Related Tasks.
  *
  * @return void
  */
 public function initialize()
 {
     $plugins = Plugin::loaded();
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Shell/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.+Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     $paths = App::path('Shell/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.+\\.php'));
         foreach ($res as &$r) {
             $r = basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     parent::initialize();
     $this->QueuedTasks->initConfig();
 }
Exemplo n.º 27
0
 public function onControllerInit($event)
 {
     $controller = $event->subject();
     if (isset($controller->request->params['prefix'])) {
         $menuFile = $controller->request->params['prefix'] . '_menus';
         if ($theme = Configure::read('App.admin.theme')) {
             if ($theme != '' && $theme != 'RearEngine' && Plugin::loaded($theme)) {
                 $controller->viewBuilder()->theme($theme);
             }
         }
         foreach (Plugin::loaded() as $plugin) {
             try {
                 Configure::load($plugin . '.' . $menuFile, 'default', true);
             } catch (\Exception $e) {
                 if (Configure::read('debug')) {
                     Log::warning('Unable to load app ' . $plugin . '/Config/' . $menuFile . ' config file', ['scope' => 'RearEngine plugin']);
                 }
             }
         }
         try {
             Configure::load($menuFile, 'default', true);
         } catch (\Exception $e) {
             if (Configure::read('debug')) {
                 Log::warning('Unable to load App/Config/' . $menuFile . ' config file.', ['scope' => 'RearEngine plugin']);
             }
         }
     }
 }
Exemplo n.º 28
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('TestPlugin');
     Configure::write('App.namespace', 'TestApp');
     $this->dispatcher = $this->getMockBuilder('Cake\\Console\\ShellDispatcher')->setMethods(['_stop'])->getMock();
 }
Exemplo n.º 29
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('TestPlugin');
     Plugin::unload('TestTheme');
     unset($this->View);
 }
Exemplo n.º 30
0
 /**
  * Get template data.
  *
  * @return array
  */
 public function templateData()
 {
     $namespace = Configure::read('App.namespace');
     if ($this->plugin) {
         $namespace = Plugin::getNamespace($this->plugin);
     }
     return ['namespace' => $namespace];
 }