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


PHP Plugin::loaded方法代码示例

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


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

示例1: initialize

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

示例2: onControllerInit

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

示例3: _list

 /**
  * Get list of plugins to process. Plugins without a webroot directory are skipped.
  *
  * @param string|null $name Name of plugin for which to symlink assets.
  *   If null all plugins will be processed.
  * @return array List of plugins with meta data.
  */
 protected function _list($name = null)
 {
     if ($name === null) {
         $pluginsList = Plugin::loaded();
     } else {
         if (!Plugin::loaded($name)) {
             $this->err(sprintf('Plugin %s is not loaded.', $name));
             return [];
         }
         $pluginsList = [$name];
     }
     $plugins = [];
     foreach ($pluginsList as $plugin) {
         $path = Plugin::path($plugin) . 'webroot';
         if (!is_dir($path)) {
             $this->out('', 1, Shell::VERBOSE);
             $this->out(sprintf('Skipping plugin %s. It does not have webroot folder.', $plugin), 2, Shell::VERBOSE);
             continue;
         }
         $link = Inflector::underscore($plugin);
         $dir = WWW_ROOT;
         $namespaced = false;
         if (strpos($link, '/') !== false) {
             $namespaced = true;
             $parts = explode('/', $link);
             $link = array_pop($parts);
             $dir = WWW_ROOT . implode(DIRECTORY_SEPARATOR, $parts) . DIRECTORY_SEPARATOR;
         }
         $plugins[$plugin] = ['srcPath' => Plugin::path($plugin) . 'webroot', 'destDir' => $dir, 'link' => $link, 'namespaced' => $namespaced];
     }
     return $plugins;
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:39,代码来源:AssetsTask.php

示例4: _resolvePath

 /**
  * Internal method to resolve partial paths, returning full paths
  * @param string|array $paths Partial paths
  * @return array
  * @throws InternalErrorException
  * @use $type
  */
 protected function _resolvePath($paths)
 {
     $loadedPlugins = Plugin::loaded();
     return array_map(function ($path) use($loadedPlugins) {
         $pluginSplit = pluginSplit($path);
         //Note that using `pluginSplit()` is not sufficient, because
         //  `$path` may still contain a dot
         if (!empty($pluginSplit[0]) && in_array($pluginSplit[0], $loadedPlugins)) {
             list($plugin, $path) = $pluginSplit;
         }
         if (substr($path, 0, 1) === '/') {
             $path = substr($path, 1);
         } else {
             $path = $this->type . DS . $path;
         }
         if (!empty($plugin)) {
             $path = Plugin::path($plugin) . 'webroot' . DS . $path;
         } else {
             $path = WWW_ROOT . $path;
         }
         //Appends the file extension, if not already present
         if (pathinfo($path, PATHINFO_EXTENSION) !== $this->type) {
             $path = sprintf('%s.%s', $path, $this->type);
         }
         if (!file_exists($path)) {
             throw new InternalErrorException(__d('assets', 'File `{0}` doesn\'t exist', str_replace(APP, null, $path)));
         }
         return $path;
     }, (array) $paths);
 }
开发者ID:mirko-pagliai,项目名称:assets,代码行数:37,代码来源:AssetsCreator.php

示例5: _findTemplates

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

示例6: _getAssetFile

 /**
  * Builds asset file path based on the provided $url.
  *
  * @param string $url Asset URL
  * @return string|void Absolute path for asset file
  */
 protected function _getAssetFile($url)
 {
     $parts = explode('/', $url);
     $pluginPart = [];
     $plugin = false;
     for ($i = 0; $i < 2; $i++) {
         if (!isset($parts[$i])) {
             break;
         }
         $pluginPart[] = Inflector::camelize($parts[$i]);
         $possiblePlugin = implode('/', $pluginPart);
         if ($possiblePlugin && Plugin::loaded($possiblePlugin)) {
             $plugin = $possiblePlugin;
             $parts = array_slice($parts, $i + 1);
             break;
         }
     }
     $isAssetRequest = isset($parts[0]) && $parts[0] === 'ASSETS';
     if ($isAssetRequest && Configure::read('debug')) {
         $parts = array_slice($parts, 1);
     } else {
         $isAssetRequest = false;
     }
     if ($plugin && Plugin::loaded($plugin)) {
         return $this->_getPluginAsset($plugin, $parts, $isAssetRequest);
     } else {
         return $this->_getAppAsset($parts, $isAssetRequest);
     }
 }
开发者ID:frankfoerster,项目名称:cakephp-asset,代码行数:35,代码来源:AssetFilter.php

示例7: index

 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'));
 }
开发者ID:dereuromark,项目名称:cakephp-data,代码行数:25,代码来源:CurrenciesController.php

示例8: onControllerInit

 public function onControllerInit($event)
 {
     $controller = $event->subject();
     if (($theme = Configure::read('App.theme')) && Plugin::loaded($theme)) {
         $controller->viewBuilder()->theme($theme);
     }
 }
开发者ID:mindforce,项目名称:cakephp-front-engine,代码行数:7,代码来源:CoreEvent.php

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: initialize

 /**
  * Initialize table config.
  *
  * @param array $config Config options
  * @return void
  */
 public function initialize(array $config)
 {
     $this->table('tags_tags');
     $this->displayField('label');
     if (Plugin::loaded('Muffin/Slug')) {
         $this->addBehavior('Muffin/Slug.Slug');
     }
 }
开发者ID:Phillaf,项目名称:Tags,代码行数:14,代码来源:TagsTable.php

示例14: loadTasks

 /**
  * Locate the tasks bake will use.
  *
  * Scans the following paths for tasks that are subclasses of
  * Cake\Shell\Task\BakeTask:
  *
  * - Cake/Shell/Task/
  * - App/Shell/Task/
  * - Shell/Task for each loaded plugin
  *
  * @return void
  */
 public function loadTasks()
 {
     $tasks = [];
     $tasks = $this->_findTasks($tasks, APP, Configure::read('App.namespace'));
     foreach (Plugin::loaded() as $plugin) {
         $tasks = $this->_findTasks($tasks, Plugin::classPath($plugin), $plugin, $plugin);
     }
     $this->tasks = array_values($tasks);
     parent::loadTasks();
 }
开发者ID:hasegawa-tomoki,项目名称:tsvio,代码行数:22,代码来源:TsvioShell.php

示例15: getPath

 /**
  * @param string|null $path
  * @return string
  */
 protected function getPath($path = null)
 {
     if ($path === null) {
         $path = ROOT . DS;
     } elseif ($path === 'core') {
         $path = CORE_PATH;
     } elseif (Plugin::loaded($path)) {
         $path = Plugin::path($path);
     }
     return $path;
 }
开发者ID:dereuromark,项目名称:cakephp-setup,代码行数:15,代码来源:MailmapShell.php


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