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


PHP Plugin::classPath方法代码示例

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


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

示例1: init

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

示例2: _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

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

示例4: main

 /**
  * Execution method always used for tasks.
  *
  * @return void
  */
 public function main()
 {
     if (!empty($this->params['exclude'])) {
         $this->_exclude = explode(',', $this->params['exclude']);
     }
     if (isset($this->params['files']) && !is_array($this->params['files'])) {
         $this->_files = explode(',', $this->params['files']);
     }
     if (isset($this->params['paths'])) {
         $this->_paths = explode(',', $this->params['paths']);
     } elseif (isset($this->params['plugin'])) {
         $plugin = Inflector::camelize($this->params['plugin']);
         if (!Plugin::loaded($plugin)) {
             Plugin::load($plugin);
         }
         $this->_paths = [Plugin::classPath($plugin)];
         $this->params['plugin'] = $plugin;
     } else {
         $this->_getPaths();
     }
     if (isset($this->params['extract-core'])) {
         $this->_extractCore = !(strtolower($this->params['extract-core']) === 'no');
     } else {
         $response = $this->in('Would you like to extract the messages from the CakePHP core?', ['y', 'n'], 'n');
         $this->_extractCore = strtolower($response) === 'y';
     }
     if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {
         $this->_exclude = array_merge($this->_exclude, App::path('Plugin'));
     }
     if (!empty($this->params['validation-domain'])) {
         $this->_validationDomain = $this->params['validation-domain'];
     }
     if ($this->_extractCore) {
         $this->_paths[] = CAKE;
     }
     if (isset($this->params['merge'])) {
         $this->_merge = !(strtolower($this->params['merge']) === 'no');
     } else {
         $this->out();
         $response = $this->in('Would you like to merge all domain strings into the default.pot file?', ['y', 'n'], 'n');
         $this->_merge = strtolower($response) === 'y';
     }
     if (empty($this->_files)) {
         $this->_searchFiles();
     }
     $this->_extract();
 }
开发者ID:admad,项目名称:cakephp-i18n,代码行数:52,代码来源:ExtractTask.php

示例5: getShellList

 /**
  * Gets the shell command listing.
  *
  * @return array
  */
 public function getShellList()
 {
     $skipFiles = ['AppShell'];
     $hiddenCommands = ['CommandListShell', 'CompletionShell'];
     $plugins = Plugin::loaded();
     $shellList = array_fill_keys($plugins, null) + ['CORE' => null, 'app' => null];
     $appPath = App::path('Shell');
     $appShells = $this->_scanDir($appPath[0]);
     $appShells = array_diff($appShells, $skipFiles);
     $shellList = $this->_appendShells('app', $appShells, $shellList);
     $shells = $this->_scanDir(dirname(__DIR__));
     $shells = array_diff($shells, $appShells, $skipFiles, $hiddenCommands);
     $shellList = $this->_appendShells('CORE', $shells, $shellList);
     foreach ($plugins as $plugin) {
         $pluginPath = Plugin::classPath($plugin) . 'Shell';
         $pluginShells = $this->_scanDir($pluginPath);
         $shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
     }
     return array_filter($shellList);
 }
开发者ID:fabioalvaro,项目名称:cakexuxu,代码行数:25,代码来源:CommandTask.php

示例6: getAvailableWidgets

 /**
  * Returns an array with avilable widget identifiers
  *
  * @return array
  */
 public static function getAvailableWidgets()
 {
     $widgets = [];
     $config = Configure::read('Cms.Widgets.availableWidgets');
     if (is_array($config)) {
         return $config;
     }
     $namespace = Configure::read('App.namespace');
     $widgetPaths = App::path('Widget');
     foreach ($widgetPaths as $widgetPath) {
         $appWidgetsFolder = new Folder($widgetPath);
         $contents = $appWidgetsFolder->read(true);
         foreach ($contents[0] as $folderName) {
             $widgetIdentifier = "{$namespace}.{$folderName}";
             if (self::widgetExists($widgetIdentifier)) {
                 $widgets[] = $widgetIdentifier;
             }
         }
     }
     $plugins = Plugin::loaded();
     foreach ($plugins as $plugin) {
         $widgetsPath = Plugin::classPath($plugin) . 'Widget/';
         if (!is_dir($widgetsPath)) {
             continue;
         }
         $pluginWidgetsFolder = new Folder($widgetsPath);
         $contents = $pluginWidgetsFolder->read(true);
         foreach ($contents[0] as $folderName) {
             $widgetIdentifier = "{$plugin}.{$folderName}";
             if (self::widgetExists($widgetIdentifier)) {
                 $widgets[] = $widgetIdentifier;
             }
         }
     }
     $excludedWidgets = Configure::read('Cms.Widgets.excludedWidgets');
     $widgets = array_filter($widgets, function ($widgetIdentifier) use($excludedWidgets) {
         return !in_array($widgetIdentifier, $excludedWidgets);
     });
     return $widgets;
 }
开发者ID:scherersoftware,项目名称:cake-cms,代码行数:45,代码来源:WidgetManager.php

示例7: thumbnail

 /**
  * Creates a thumbnail for the given image.
  *
  * @param string $filePath Full path to original image file
  * @param string $previewSize A valid preview preset
  * @return false|string Full path to thumbnail file on success, false otherwise
  */
 public static function thumbnail($filePath, $previewSize)
 {
     $filePath = normalizePath($filePath);
     if (!is_readable($filePath)) {
         return false;
     }
     $srcFileName = basename($filePath);
     $srcPath = dirname($filePath) . DS;
     $dstPath = normalizePath("{$srcPath}/.tmb/");
     $previewInfo = static::getPreviews($previewSize);
     require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
     $handle = new \upload($srcPath . $srcFileName);
     if (empty($previewInfo)) {
         $previews = static::getPreviews();
         $previewInfo = reset($previews);
     }
     $dstFileNameBody = static::removeExt("{$previewInfo['width']}x{$previewInfo['height']}_{$srcFileName}");
     $dstFilePath = normalizePath("{$dstPath}/{$dstFileNameBody}.jpg");
     if (is_readable($dstFilePath)) {
         return $dstFilePath;
     }
     $handle->image_x = $previewInfo['width'];
     $handle->image_y = $previewInfo['height'];
     $handle->image_resize = true;
     $handle->image_ratio = false;
     $handle->image_ratio_crop = true;
     $handle->image_convert = 'jpg';
     $handle->file_new_name_body = $dstFileNameBody;
     $handle->process($dstPath);
     if (empty($handle->error)) {
         return $handle->file_dst_pathname;
     }
     return false;
 }
开发者ID:quickapps-plugins,项目名称:field,代码行数:41,代码来源:ImageToolbox.php

示例8: translationsFolders

 /**
  * Returns the folders where the file should be looked for according to the locale
  * and package name.
  *
  * @return array The list of folders where the translation file should be looked for
  */
 public function translationsFolders()
 {
     $locale = Locale::parseLocale($this->_locale) + ['region' => null];
     $folders = [implode('_', [$locale['language'], $locale['region']]), $locale['language']];
     // If space is not added after slash, the character after it remains lowercased
     $pluginName = Inflector::camelize(str_replace('/', '/ ', $this->_name));
     $basePath = APP . 'Locale' . DS;
     $searchPath = [];
     foreach ($folders as $folder) {
         $searchPath[] = $basePath . $folder . DS;
     }
     if (Plugin::loaded($pluginName)) {
         $basePath = Plugin::classPath($pluginName) . 'Locale' . DS;
         foreach ($folders as $folder) {
             $searchPath[] = $basePath . $folder . DS;
         }
     }
     return $searchPath;
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:25,代码来源:MessagesFileLoader.php

示例9:

<?php

/**
 * Source code for the Database.FormattableBehavior unit test class.
 *
 */
namespace Database\Test\TestCase\Model\Behavior;

use Cake\Core\Plugin;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
require_once Plugin::classPath('Database') . DS . '..' . DS . 'tests' . DS . 'Fixture' . DS . 'items_table.php';
/**
 * The class Database.FormattableBehaviorTest is responsible for testing the
 * Database.FormattableBehavior class.
 *
 * @fixme: be sure to remove App global config for the tests
 */
class FormattableBehaviorTest extends TestCase
{
    /**
     * fixtures
     *
     * @var array
     */
    public $fixtures = ['plugin.Database.Items'];
    /**
     * Original intl.default_locale.
     *
     * @var string
     */
开发者ID:jmjjg,项目名称:cakephp-database,代码行数:31,代码来源:FormattableBehaviorTest.php

示例10: getOptionParser

 /**
  * Gets the option parser instance and configures it.
  *
  * @return \Cake\Console\ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = parent::getOptionParser();
     $bakeThemes = [];
     foreach (Plugin::loaded() as $plugin) {
         $path = Plugin::classPath($plugin);
         if (is_dir($path . 'Template' . DS . 'Bake')) {
             $bakeThemes[] = $plugin;
         }
     }
     $parser->description('The Bake script generates controllers, views and models for your application.' . ' If run with no command line arguments, Bake guides the user through the class creation process.' . ' You can customize the generation process by telling Bake where different parts of your application' . ' are using command line arguments.')->addSubcommand('all', ['help' => 'Bake a complete MVC skeleton.'])->addOption('connection', ['help' => 'Database connection to use in conjunction with `bake all`.', 'short' => 'c', 'default' => 'default'])->addOption('theme', ['short' => 't', 'help' => 'The theme to use when baking code.', 'choices' => $bakeThemes]);
     foreach ($this->_taskMap as $task => $config) {
         $taskParser = $this->{$task}->getOptionParser();
         $parser->addSubcommand(Inflector::underscore($task), ['help' => $taskParser->description(), 'parser' => $taskParser]);
     }
     return $parser;
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:22,代码来源:BakeShell.php

示例11: getOptionParser

 /**
  * Gets the option parser instance and configures it.
  *
  * @return \Cake\Console\ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = parent::getOptionParser();
     $bakeThemes = [];
     foreach (Plugin::loaded() as $plugin) {
         $path = Plugin::classPath($plugin);
         if (is_dir($path . 'Template' . DS . 'Bake')) {
             $bakeThemes[] = $plugin;
         }
     }
     $parser->description('The Bake script generates controllers, models and template files for your application.' . ' If run with no command line arguments, Bake guides the user through the class creation process.' . ' You can customize the generation process by telling Bake where different parts of your application' . ' are using command line arguments.')->addSubcommand('all', ['help' => 'Bake a complete MVC skeleton.'])->addOption('everything', ['help' => 'Bake a complete MVC skeleton, using all the available tables. ' . 'Usage: "bake all --everything"', 'default' => false, 'boolean' => true])->addOption('connection', ['help' => 'Database connection to use in conjunction with `bake all`.', 'short' => 'c', 'default' => 'default'])->addOption('force', ['short' => 'f', 'boolean' => true, 'help' => 'Force overwriting existing files without prompting.'])->addOption('plugin', ['short' => 'p', 'help' => 'Plugin to bake into.'])->addOption('prefix', ['help' => 'Prefix to bake controllers and templates into.'])->addOption('theme', ['short' => 't', 'help' => 'The theme to use when baking code.', 'choices' => $bakeThemes]);
     foreach ($this->_taskMap as $task => $config) {
         $taskParser = $this->{$task}->getOptionParser();
         $parser->addSubcommand(Inflector::underscore($task), ['help' => $taskParser->description(), 'parser' => $taskParser]);
     }
     return $parser;
 }
开发者ID:webroup17,项目名称:social_networking,代码行数:22,代码来源:BakeShell.php

示例12: _getLib

 /**
  * Gets an instance of AYAH library.
  *
  * @return object
  */
 protected function _getLib()
 {
     require_once Plugin::classPath('Captcha') . 'Lib/ayah.php';
     return new \AYAH(['publisher_key' => $this->config('publisherKey'), 'scoring_key' => $this->config('scoringKey'), 'web_service_host' => 'ws.areyouahuman.com', 'use_curl' => true, 'debug_mode' => Configure::read('debug')]);
 }
开发者ID:quickapps-plugins,项目名称:captcha,代码行数:10,代码来源:AyahAdapter.php

示例13: getOptionParser

 /**
  * Get the option parser for this task.
  *
  * This base class method sets up some commonly used options.
  *
  * @return \Cake\Console\ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = parent::getOptionParser();
     $bakeThemes = [];
     foreach (Plugin::loaded() as $plugin) {
         $path = Plugin::classPath($plugin);
         if (is_dir($path . 'Template' . DS . 'Bake')) {
             $bakeThemes[] = $plugin;
         }
     }
     $parser->addOption('plugin', ['short' => 'p', 'help' => 'Plugin to bake into.'])->addOption('force', ['short' => 'f', 'boolean' => true, 'help' => 'Force overwriting existing files without prompting.'])->addOption('connection', ['short' => 'c', 'default' => 'default', 'help' => 'The datasource connection to get data from.'])->addOption('theme', ['short' => 't', 'help' => 'The theme to use when baking code.', 'choices' => $bakeThemes]);
     return $parser;
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:20,代码来源:BakeTask.php

示例14: _setupPaths

 /**
  * Initializes the crud-view template paths
  *
  * @return void
  */
 protected function _setupPaths()
 {
     $paths = Configure::read('App.paths.templates');
     $extraPaths = Configure::read('CrudView.templatePaths');
     if (!empty($extraPaths)) {
         $paths = array_merge($paths, (array) $extraPaths);
     }
     $paths[] = Plugin::classPath('CrudView') . 'Template' . DS;
     Configure::write('App.paths.templates', $paths);
 }
开发者ID:friendsofcake,项目名称:crud-view,代码行数:15,代码来源:CrudView.php

示例15: getWidgetPath

 /**
  * Returns the absolute path to the Widget's base folder.
  *
  * @return string
  */
 public function getWidgetPath()
 {
     if ($this->_plugin) {
         $widgetPath = Plugin::classPath($this->_plugin) . 'Widget/';
     } else {
         $widgetPath = current(App::path('Widget'));
     }
     return $widgetPath . $this->_identifier . '/';
 }
开发者ID:scherersoftware,项目名称:cake-cms,代码行数:14,代码来源:AbstractWidget.php


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