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


PHP App::path方法代码示例

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


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

示例1: initialize

 /**
  * Initialize method
  */
 public function initialize()
 {
     $paths = App::path('Shell/Task', 'CodeBlastrQueue');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.+\\.php'));
         foreach ($res as &$r) {
             $r = 'CodeBlastrQueue.' . basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     parent::initialize();
 }
开发者ID:codeblastr,项目名称:queue,代码行数:16,代码来源:QueueShell.php

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

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

示例4: install

 /**
  * Installing plugin
  * @param null $zipPath
  * @return array|bool
  * @throws CakeException
  */
 public function install($zipPath = null)
 {
     if (!file_exists($zipPath)) {
         throw new Exception(__d('spider', 'Invalid plugin file path'));
     }
     $pluginInfo = $this->getPluginMeta($zipPath);
     $pluginHomeDir = App::path('Plugin');
     $pluginHomeDir = reset($pluginHomeDir);
     $pluginPath = $pluginHomeDir . $pluginInfo->name . DS;
     if (is_dir($pluginPath)) {
         throw new Exception(__d('spider', 'Plugin already exists'));
     }
     $Zip = new \ZipArchive();
     if ($Zip->open($zipPath) === true) {
         new Folder($pluginPath, true);
         $Zip->extractTo($pluginPath);
         if (!empty($pluginInfo->rootPath)) {
             $old = $pluginPath . $pluginInfo->rootPath;
             $new = $pluginPath;
             $Folder = new Folder($old);
             $Folder->move($new);
         }
         $Zip->close();
         return (array) $pluginInfo;
     } else {
         throw new CakeException(__d('spider', 'Failed to extract plugin'));
     }
     return false;
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:35,代码来源:PluginInstaller.php

示例5: plugin

 /**
  * Return all templates for a given plugin.
  *
  * @param string $plugin The plugin to find all templates for.
  *
  * @return mixed
  */
 public static function plugin($plugin)
 {
     $templates = [];
     foreach (App::path('Template', $plugin) as $path) {
         $templates = array_merge($templates, static::iteratePath($path));
     }
     return $templates;
 }
开发者ID:luisfredgs,项目名称:TwigView,代码行数:15,代码来源:Scanner.php

示例6: stripAbsolutePath

 /**
  * Strip the absolute path of template's paths.
  *
  * @param array       $paths  Paths to strip.
  * @param string|null $plugin Hold plugin name or null for App.
  *
  * @return array
  */
 protected static function stripAbsolutePath(array $paths, $plugin = null)
 {
     foreach (App::path('Template', $plugin) as $templatesPath) {
         array_walk($paths, function (&$path) use($templatesPath) {
             if (substr($path, 0, strlen($templatesPath)) == $templatesPath) {
                 $path = substr($path, strlen($templatesPath));
             }
         });
     }
     return $paths;
 }
开发者ID:luisfredgs,项目名称:TwigView,代码行数:19,代码来源:RelativeScanner.php

示例7: render

 /**
  * Renders view for given template file and layout.
  *
  * @param null $view
  * @param null $layout
  * @return string|void
  */
 public function render($view = null, $layout = null)
 {
     if (is_null($view) && in_array($this->request->param('action'), ['edit', 'add'])) {
         $searchPaths = App::path('Template', $this->plugin);
         $formViewFile = $this->__findViewByRequest($searchPaths);
         if (!$formViewFile) {
             $view = 'form';
         }
     }
     if ($this->Union->isAdmin()) {
         $this->Assets->widget('.jsToggle', 'UnionFieldToggle', ['csrfToken' => $this->request->cookie('csrfToken')]);
     }
     return parent::render($view, $layout);
 }
开发者ID:Cheren,项目名称:union,代码行数:21,代码来源:UnionView.php

示例8: bake

 /**
  * Bake the plugin, create directories and files
  *
  * @param string $plugin Name of the plugin in CamelCased format
  * @return bool
  */
 public function bake($plugin)
 {
     $pathOptions = App::path('Plugin');
     if (count($pathOptions) > 1) {
         $this->findPath($pathOptions);
     }
     $this->hr();
     $this->out(sprintf("<info>Plugin Name:</info> %s", $plugin));
     $this->out(sprintf("<info>Plugin Directory:</info> %s", $this->path . $plugin));
     $this->hr();
     $classBase = 'src';
     $looksGood = $this->in('Look okay?', ['y', 'n', 'q'], 'y');
     if (strtolower($looksGood) === 'y') {
         $Folder = new Folder($this->path . $plugin);
         $directories = ['config', $classBase . DS . 'Model' . DS . 'Behavior', $classBase . DS . 'Model' . DS . 'Table', $classBase . DS . 'Model' . DS . 'Entity', $classBase . DS . 'Shell' . DS . 'Task', $classBase . DS . 'Controller' . DS . 'Component', $classBase . DS . 'View' . DS . 'Helper', $classBase . DS . 'Template', 'tests' . DS . 'TestCase' . DS . 'Controller' . DS . 'Component', 'tests' . DS . 'TestCase' . DS . 'View' . DS . 'Helper', 'tests' . DS . 'TestCase' . DS . 'Model' . DS . 'Behavior', 'tests' . DS . 'Fixture', 'webroot'];
         foreach ($directories as $directory) {
             $dirPath = $this->path . $plugin . DS . $directory;
             $Folder->create($dirPath);
             new File($dirPath . DS . 'empty', true);
         }
         foreach ($Folder->messages() as $message) {
             $this->out($message, 1, Shell::VERBOSE);
         }
         $errors = $Folder->errors();
         if (!empty($errors)) {
             foreach ($errors as $message) {
                 $this->error($message);
             }
             return false;
         }
         $controllerFileName = 'AppController.php';
         $out = "<?php\n\n";
         $out .= "namespace {$plugin}\\Controller;\n\n";
         $out .= "use App\\Controller\\AppController as BaseController;\n\n";
         $out .= "class AppController extends BaseController {\n\n";
         $out .= "}\n";
         $this->createFile($this->path . $plugin . DS . $classBase . DS . 'Controller' . DS . $controllerFileName, $out);
         $emptyFile = $this->path . 'empty';
         $this->_deleteEmptyFile($emptyFile);
         $hasAutoloader = $this->_modifyAutoloader($plugin, $this->path);
         $this->_generateRoutes($plugin, $this->path);
         $this->_modifyBootstrap($plugin, $hasAutoloader);
         $this->_generatePhpunitXml($plugin, $this->path);
         $this->_generateTestBootstrap($plugin, $this->path);
         $this->hr();
         $this->out(sprintf('<success>Created:</success> %s in %s', $plugin, $this->path . $plugin), 2);
     }
     return true;
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:55,代码来源:PluginTask.php

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

示例10: _paths

 /**
  * Return all possible paths to find view files in order
  *
  * This method overrides cakephp's default method because it doesn't allow
  * to override themes by default
  *
  * @param string|null $plugin Optional plugin name to scan for view files.
  * @param bool $cached Set to false to force a refresh of view paths. Default true.
  * @return array paths
  */
 protected function _paths($plugin = null, $cached = true)
 {
     $paths = parent::_paths($plugin, $cached);
     $templatePaths = App::path('Template');
     $themeOverridePaths = [];
     if (!empty($this->theme)) {
         for ($i = 0, $count = count($templatePaths); $i < $count; $i++) {
             $themeOverridePaths[] = $templatePaths[$i] . $this->theme . DS;
             if ($plugin) {
                 $themedPluginOverride = end($themeOverridePaths) . 'Plugin' . DS . $plugin . DS;
                 array_unshift($themeOverridePaths, $themedPluginOverride);
             }
         }
     }
     $paths = array_merge($themeOverridePaths, $paths);
     return $this->_paths = $paths;
 }
开发者ID:uuking,项目名称:cakephp-cms-GintonicCMS,代码行数:27,代码来源:AppView.php

示例11: _find

 /**
  * Find theme path.
  *
  * @param string $name
  * @return null|string
  */
 protected static function _find($name)
 {
     $paths = App::path('Plugin');
     foreach ($paths as $path) {
         $path = FS::clean($path . '/', DS);
         $details = explode(DS, rtrim($path, DS));
         $folder = Str::trim(array_pop($details));
         $themeFolder = $path . $name;
         if (Arr::in($folder, self::$_skipFolder) || !FS::isDir($themeFolder)) {
             $themeFolder .= self::POSTFIX;
         }
         if (FS::isDir($themeFolder)) {
             return $themeFolder;
         }
     }
     return null;
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:23,代码来源:Theme.php

示例12: bake

 /**
  * Bake the plugin's contents
  *
  * Also update the autoloader and the root composer.json file if it can be found
  *
  * @param string $plugin Name of the plugin in CamelCased format
  * @return bool
  */
 public function bake($plugin)
 {
     $pathOptions = App::path('Plugin');
     if (count($pathOptions) > 1) {
         $this->findPath($pathOptions);
     }
     $this->out(sprintf("<info>Plugin Name:</info> %s", $plugin));
     $this->out(sprintf("<info>Plugin Directory:</info> %s", $this->path . $plugin));
     $this->hr();
     $looksGood = $this->in('Look okay?', ['y', 'n', 'q'], 'y');
     if (strtolower($looksGood) !== 'y') {
         return;
     }
     $this->_generateFiles($plugin, $this->path);
     $hasAutoloader = $this->_modifyAutoloader($plugin, $this->path);
     $this->_modifyBootstrap($plugin, $hasAutoloader);
     $this->hr();
     $this->out(sprintf('<success>Created:</success> %s in %s', $plugin, $this->path . $plugin), 2);
     return true;
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:28,代码来源:PluginTask.php

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

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

示例15: about

 /**
  * Renders the help document of the given plugin.
  *
  * @param string $pluginName The plugin name
  * @return void
  * @throws \Cake\Network\Exception\NotFoundException When no help document was found
  */
 public function about($pluginName)
 {
     $about = false;
     if (Plugin::loaded($pluginName)) {
         $locale = I18n::locale();
         $templatePath = App::path('Template', $pluginName)[0] . 'Element/Help/';
         $lookFor = ["help_{$locale}", 'help'];
         foreach ($lookFor as $ctp) {
             if (is_readable($templatePath . "{$ctp}.ctp")) {
                 $about = "{$pluginName}.Help/{$ctp}";
                 break;
             }
         }
     }
     if ($about) {
         $this->set('about', $about);
     } else {
         throw new NotFoundException(__d('system', 'No help was found.'));
     }
     $this->title(__d('system', 'About "{0}"', $pluginName));
     $this->Breadcrumb->push('/admin/system/help')->push(__d('system', 'About {0}', $pluginName), '#');
 }
开发者ID:quickapps-plugins,项目名称:system,代码行数:29,代码来源:HelpController.php


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