当前位置: 首页>>代码示例>>PHP>>正文


PHP Core\Plugin类代码示例

本文整理汇总了PHP中Cake\Core\Plugin的典型用法代码示例。如果您正苦于以下问题:PHP Plugin类的具体用法?PHP Plugin怎么用?PHP Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getConfig

 /**
  * 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']]]]);
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:33,代码来源:ConfigurationTrait.php

示例2: callback

 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();
 }
开发者ID:mindforce,项目名称:cakephp-editorial-summernote,代码行数:27,代码来源:FilesystemController.php

示例3: _getAssetFile

 /**
  * 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;
                 }
             }
         }
     }
 }
开发者ID:mindforce,项目名称:cakephp-garderobe,代码行数:33,代码来源:AssetFilter.php

示例4: tearDown

 /**
  * Tear down method.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('Union/Core');
     Plugin::unload('TestPlugin');
     unset($this->ToolBar, $this->View);
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:12,代码来源:ToolBarHelperTest.php

示例5: onControllerInit

 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']);
 }
开发者ID:mindforce,项目名称:cakephp-passengers,代码行数:34,代码来源:CoreEvent.php

示例6: tearDown

 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Shell);
     Configure::write('App.namespace', 'App');
     Plugin::unload();
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:12,代码来源:CompletionShellTest.php

示例7: injectEditor

 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);
         }
     }
 }
开发者ID:mindforce,项目名称:cakephp-editorial,代码行数:31,代码来源:EditorialEvent.php

示例8: setUp

 /**
  * @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);
 }
开发者ID:dereuromark,项目名称:cakephp-tinyauth,代码行数:10,代码来源:AuthUserHelperTest.php

示例9: tearDown

 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     $_SESSION = [];
     unset($this->View, $this->Session);
     Plugin::unload();
     parent::tearDown();
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:12,代码来源:SessionHelperTest.php

示例10: load

 /**
  * @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);
         }
     }
 }
开发者ID:makallio85,项目名称:yaml-route,代码行数:32,代码来源:Plugin.php

示例11: getConfig

 /**
  * 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);
 }
开发者ID:JoHein,项目名称:LeBonCoup,代码行数:42,代码来源:ConfigurationTrait.php

示例12: load

 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;
 }
开发者ID:ThreeCMS,项目名称:ThreeCMS,代码行数:34,代码来源:Plugin.php

示例13: variant

 /**
  * 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);
 }
开发者ID:xavier83ar,项目名称:image-presenter,代码行数:40,代码来源:ImageHelper.php

示例14: testBuildResetWithPlugin

 /**
  * @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);
 }
开发者ID:dereuromark,项目名称:cakephp-tools,代码行数:31,代码来源:UrlHelperTest.php

示例15: api

 /**
  * 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);
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:33,代码来源:MoxiemanagerController.php


注:本文中的Cake\Core\Plugin类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。