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


PHP Plugin::getNamespace方法代码示例

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


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

示例1: templateData

 /**
  * Get template data.
  *
  * @return array
  */
 public function templateData()
 {
     $namespace = Configure::read('App.namespace');
     if ($this->plugin) {
         $namespace = Plugin::getNamespace($this->plugin);
     }
     return ['namespace' => $namespace];
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:13,代码来源:SimpleBakeTask.php

示例2: classname

 /**
  * Return the classname namespaced. This method checks if the class is defined on the
  * application/plugin, otherwise try to load from the CakePHP core
  *
  * @param string $class Classname
  * @param string $type Type of class
  * @param string $suffix Classname suffix
  * @return bool|string False if the class is not found or namespaced classname
  */
 public static function classname($class, $type = '', $suffix = '')
 {
     if (strpos($class, '\\') !== false) {
         return $class;
     }
     list($plugin, $name) = pluginSplit($class);
     if ($plugin) {
         $base = Plugin::getNamespace($plugin);
     } else {
         $base = Configure::read('App.namespace');
     }
     $base = rtrim($base, '\\');
     $fullname = '\\' . str_replace('/', '\\', $type . '\\' . $name) . $suffix;
     if (static::_classExistsInBase($fullname, $base)) {
         return $base . $fullname;
     }
     if ($plugin) {
         return false;
     }
     if (static::_classExistsInBase($fullname, 'Cake')) {
         return 'Cake' . $fullname;
     }
     return false;
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:33,代码来源:App.php

示例3: testLoadAllWithPluginAlreadyLoaded

 /**
  * Test that plugins don't reload using loadAll();
  *
  * @return void
  */
 public function testLoadAllWithPluginAlreadyLoaded()
 {
     Plugin::load('PluginJs', ['namespace' => 'Company\\TestPluginJs']);
     Plugin::loadAll();
     $this->assertEquals('Company\\TestPluginJs', Plugin::getNamespace('PluginJs'));
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:11,代码来源:PluginTest.php

示例4: _loadFixtures

 /**
  * Looks for fixture files and instantiates the classes accordingly
  *
  * @param \Cake\TestSuite\Testcase $test The test suite to load fixtures for.
  * @return void
  * @throws \UnexpectedValueException when a referenced fixture does not exist.
  */
 protected function _loadFixtures($test)
 {
     if (empty($test->fixtures)) {
         return;
     }
     foreach ($test->fixtures as $fixture) {
         if (isset($this->_loaded[$fixture])) {
             continue;
         }
         list($type, $pathName) = explode('.', $fixture, 2);
         $path = explode('/', $pathName);
         $name = array_pop($path);
         $additionalPath = implode('\\', $path);
         if ($type === 'core') {
             $baseNamespace = 'Cake';
         } elseif ($type === 'app') {
             $baseNamespace = Configure::read('App.namespace');
         } elseif ($type === 'plugin') {
             if (strlen($additionalPath)) {
                 list($plugin, $additionalPath) = explode('.', $additionalPath);
             } else {
                 list($plugin, $name) = explode('.', $name);
             }
             $baseNamespace = Plugin::getNamespace(Inflector::camelize($plugin));
         } else {
             $name = $fixture;
         }
         $name = Inflector::camelize($name);
         $nameSegments = [$baseNamespace, 'Test\\Fixture', $additionalPath, $name . 'Fixture'];
         $className = implode('\\', array_filter($nameSegments));
         if (class_exists($className)) {
             $this->_loaded[$fixture] = new $className();
             $this->_fixtureMap[$name] = $this->_loaded[$fixture];
         } else {
             $msg = sprintf('Referenced fixture class "%s" not found. Fixture "%s" was referenced in test case "%s".', $className, $fixture, get_class($test));
             throw new \UnexpectedValueException($msg);
         }
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:46,代码来源:FixtureManager.php

示例5: loadTasks

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

示例6: testCaseFileName

 /**
  * Make the filename for the test case. resolve the suffixes for controllers
  * and get the plugin path if needed.
  *
  * @param string $type The Type of object you are generating tests for eg. controller
  * @param string $className The fully qualified classname of the class the test is being generated for.
  * @return string filename the test should be created on.
  */
 public function testCaseFileName($type, $className)
 {
     $path = $this->getPath();
     $namespace = Configure::read('App.namespace');
     if ($this->plugin) {
         $namespace = Plugin::getNamespace($this->plugin);
     }
     $classTail = substr($className, strlen($namespace) + 1);
     $path = $path . $classTail . 'Test.php';
     return str_replace(['/', '\\'], DS, $path);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:19,代码来源:TestTask.php


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