本文整理汇总了PHP中Cake\Core\Plugin::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::load方法的具体用法?PHP Plugin::load怎么用?PHP Plugin::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Core\Plugin
的用法示例。
在下文中一共展示了Plugin::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddPluginWidgetsFromConfigInConstuctor
/**
* Test loading templates files from a plugin
*
* @return void
*/
public function testAddPluginWidgetsFromConfigInConstuctor()
{
Plugin::load('TestPlugin');
$widgets = ['text' => ['Cake\\View\\Widget\\BasicWidget'], 'TestPlugin.test_widgets'];
$inputs = new WidgetRegistry($this->templates, $this->view, $widgets);
$this->assertInstanceOf('Cake\\View\\Widget\\LabelWidget', $inputs->get('text'));
}
示例2: setUp
/**
* reset environment.
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
Plugin::load(array('TestPlugin', 'TestPluginTwo'));
$this->Case = $this->getMockForAbstractClass('Cake\\TestSuite\\ControllerTestCase');
$this->Case->loadRoutes = false;
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
Router::scope('/', function ($routes) {
$routes->fallbacks();
});
Router::prefix('admin', function ($routes) {
$routes->plugin('TestPlugin', function ($routes) {
$routes->fallbacks();
});
$routes->fallbacks();
});
Router::plugin('TestPlugin', function ($routes) {
$routes->fallbacks();
});
Router::plugin('TestPluginTwo', function ($routes) {
$routes->fallbacks();
});
TableRegistry::clear();
}
示例3: testConfigPlugin
/**
* Test config() method with plugin syntax aliases
*
* @return void
*/
public function testConfigPlugin()
{
Plugin::load('TestPlugin');
$data = ['connection' => 'testing', 'entityClass' => 'TestPlugin\\Model\\Entity\\Comment'];
$result = $this->_locator->config('TestPlugin.TestPluginComments', $data);
$this->assertEquals($data, $result, 'Returns config data.');
}
示例4: setUp
/**
* Setup test data.
*
* @return void
*/
public function setUp()
{
parent::setUp();
Plugin::load('TestPlugin', ['autoload' => true]);
Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
$this->View = $this->getMock('Union\\Core\\View\\AppView', ['append']);
}
示例5: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Plugin::load('TestPlugin');
Configure::write('App.namespace', 'TestApp');
$this->dispatcher = $this->getMockBuilder('Cake\\Console\\ShellDispatcher')->setMethods(['_stop'])->getMock();
}
示例6: 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);
}
}
}
示例7: 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;
}
示例8: setUp
/**
* Setup test data.
*
* @return void
*/
public function setUp()
{
parent::setUp();
Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
$this->View = new AppView();
$this->Document = new DocumentHelper($this->View);
}
示例9: testMainWithPlugin
/**
* Test the main with plugin.name method.
*
* @return void
*/
public function testMainWithPlugin()
{
Plugin::load('SimpleBakeTest', ['path' => APP . 'Plugin' . DS . 'SimpleBakeTest' . DS]);
$filename = $this->_normalizePath(APP . 'Plugin/SimpleBakeTest/src/Model/Behavior/ExampleBehavior.php');
$this->Task->expects($this->once())->method('createFile')->with($filename, $this->stringContains('class ExampleBehavior extends Behavior'));
$this->Task->Test->expects($this->once())->method('bake')->with('behavior', 'Example');
$this->Task->main('SimpleBakeTest.Example');
}
示例10: setUp
/**
* Setup test data.
*
* @return void
*/
public function setUp()
{
Plugin::load('TestPlugin', ['autoload' => true]);
Router::plugin('TestPlugin', function ($routes) {
$routes->fallbacks('DashedRoute');
});
Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
}
示例11: setUp
/**
* Setup test data.
*
* @return void
*/
public function setUp()
{
parent::setUp();
Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
$padding = ['Pages' => ['page' => 1, 'current' => 4, 'count' => 4, 'perPage' => 30, 'limit' => null, 'finder' => 'all', 'prevPage' => false, 'nextPage' => false, 'pageCount' => false, 'directionDefault' => 'DESC', 'direction' => 'DESC', 'sort' => 'Pages.id', 'sortDefault' => 'Pages.id']];
$this->ViewAdmin = new AppView(new Request(['params' => ['pass' => [], 'prefix' => 'admin', 'paging' => $padding]]));
$this->View = new AppView(new Request(['params' => ['pass' => [], 'paging' => $padding]]));
}
示例12: setUp
/**
* Setup test data.
*
* @return void
*/
public function setUp()
{
parent::setUp();
Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
$this->View = $this->getMock('Union\\Core\\View\\AppView', ['append']);
$this->Nav = new NavHelper($this->View);
Nav::add('test_menu', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'icon' => 'dashboard', 'url' => 'link', 'children' => ['link-1' => ['title' => __d('union', 'Children 1'), 'weight' => 0, 'url' => 'link-2']]]);
Nav::add('test_menu_2', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'class' => 'customClass', 'liClass' => 'customLiClass', 'icon' => 'dashboard', 'url' => 'link', 'children' => ['link-1' => ['title' => __d('union', 'Children 1'), 'weight' => 0, 'url' => 'link-2']]]);
}
示例13: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Plugin::load(['TestPlugin', 'TestPluginTwo']);
$this->out = new TestStringOutput();
$io = new ConsoleIo($this->out);
$this->Shell = $this->getMock('Cake\\Shell\\CommandListShell', ['in', 'err', '_stop', 'clear'], [$io]);
$this->Shell->Command = $this->getMock('Cake\\Shell\\Task\\CommandTask', ['in', '_stop', 'err', 'clear'], [$io]);
}
示例14: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Plugin::load(['TestPlugin', 'TestPluginTwo']);
$this->out = new ConsoleOutput();
$io = new ConsoleIo($this->out);
$this->Shell = $this->getMockBuilder('Cake\\Shell\\CommandListShell')->setMethods(['in', 'err', '_stop', 'clear'])->setConstructorArgs([$io])->getMock();
$this->Shell->Command = $this->getMockBuilder('Cake\\Shell\\Task\\CommandTask')->setMethods(['in', '_stop', 'err', 'clear'])->setConstructorArgs([$io])->getMock();
}
示例15: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
Plugin::load(['TestPlugin', 'TestTheme']);
$request = $this->getMock('Cake\\Network\\Request');
$response = $this->getMock('Cake\\Network\\Response');
$this->View = new \Cake\View\View($request, $response);
}