本文整理汇总了PHP中Cake\Core\Plugin::path方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::path方法的具体用法?PHP Plugin::path怎么用?PHP Plugin::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Core\Plugin
的用法示例。
在下文中一共展示了Plugin::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testImageFromBlob
/**
* HtmlHelperTest::testImageFromBlob()
*
* @return void
*/
public function testImageFromBlob()
{
$folder = Plugin::path('Tools') . 'tests' . DS . 'test_files' . DS . 'img' . DS;
$content = file_get_contents($folder . 'hotel.png');
$is = $this->Html->imageFromBlob($content);
$this->assertTrue(!empty($is));
}
示例2: variant
/**
* Return the webroot path to the image generated variant if this exist or to the controller if not.
*
* @param string $imagePath Path to the original image file from webroot if absolute, or relative to img/
* @param string|array $variantName Name of the variant configuration key or options array
* @param array $options options
* @return string
*/
public function variant($imagePath, $variantName, array $options = [])
{
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
list($plugin, $imagePath) = $this->_View->pluginSplit($imagePath, false);
}
$url = false;
$imagePath = $imagePath[0] === '/' ? substr($imagePath, 1) : $imagePath;
if (!isset($plugin)) {
$originalFile = WWW_ROOT . $imagePath;
$variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
if (is_file($variantFile)) {
$url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
}
} else {
$originalFile = WWW_ROOT . Inflector::underscore($plugin) . DS . $imagePath;
$variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
if (is_file($variantFile)) {
$url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
} else {
$originalFile = Plugin::path($plugin) . 'webroot' . DS . $imagePath;
$variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
if (is_file($variantFile)) {
$url = str_replace(Plugin::path($plugin) . 'webroot' . DS, '/' . Inflector::underscore($plugin) . '/', $variantFile);
$url = str_replace(DS, '/', $url);
}
}
}
if ($url === false) {
$url = ['controller' => 'Presenter', 'action' => 'variant', 'plugin' => 'ImagePresenter', 'prefix' => false, '?' => ['image' => isset($plugin) ? "{$plugin}.{$imagePath}" : $imagePath, 'variant' => $variantName]];
}
return Router::url($url);
}
示例3: setUp
/**
* @return void
*/
public function setUp()
{
Configure::write('Roles', ['user' => 1, 'moderator' => 2, 'admin' => 3]);
$this->config = ['filePath' => Plugin::path('TinyAuth') . 'tests' . DS . 'test_files' . DS, 'autoClearCache' => true];
$this->View = new View();
$this->AuthUserHelper = new AuthUserHelper($this->View, $this->config);
}
示例4: getConfig
/**
* Overrides the original method from phinx in order to return a tailored
* Config object containing the connection details for the database.
*
* @return Phinx\Config\Config
*/
public function getConfig()
{
if ($this->configuration) {
return $this->configuration;
}
$folder = 'Migrations';
if ($this->input->getOption('source')) {
$folder = $this->input->getOption('source');
}
$dir = ROOT . DS . 'config' . DS . $folder;
$plugin = null;
if ($this->input->getOption('plugin')) {
$plugin = $this->input->getOption('plugin');
$dir = Plugin::path($plugin) . 'config' . DS . $folder;
}
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
$plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
$plugin = str_replace(array('\\', '/', '.'), '_', $plugin);
$connection = 'default';
if ($this->input->getOption('connection')) {
$connection = $this->input->getOption('connection');
}
$config = ConnectionManager::config($connection);
return $this->configuration = new Config(['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $this->getAdapterName($config['driver']), 'host' => isset($config['host']) ? $config['host'] : null, 'user' => isset($config['username']) ? $config['username'] : null, 'pass' => isset($config['password']) ? $config['password'] : null, 'port' => isset($config['port']) ? $config['port'] : null, 'name' => $config['database'], 'charset' => $config['encoding']]]]);
}
示例5: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'BakeTemplate' . DS;
$io = $this->getMock('Cake\\Console\\ConsoleIo', [], [], '', false);
$this->Task = $this->getMock('Bake\\Shell\\Task\\BakeTemplateTask', ['in', 'err', 'createFile', '_stop', 'clear'], [$io]);
}
示例6: getConfig
/**
* Overrides the original method from phinx in order to return a tailored
* Config object containing the connection details for the database.
*
* @param bool $forceRefresh
* @return \Phinx\Config\Config
*/
public function getConfig($forceRefresh = false)
{
if ($this->configuration && $forceRefresh === false) {
return $this->configuration;
}
$folder = 'Migrations';
if ($this->input->getOption('source')) {
$folder = $this->input->getOption('source');
}
$dir = ROOT . DS . 'config' . DS . $folder;
$plugin = null;
if ($this->input->getOption('plugin')) {
$plugin = $this->input->getOption('plugin');
$dir = Plugin::path($plugin) . 'config' . DS . $folder;
}
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
$plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
$plugin = str_replace(['\\', '/', '.'], '_', $plugin);
$connection = $this->getConnectionName($this->input);
$connectionConfig = ConnectionManager::config($connection);
$adapterName = $this->getAdapterName($connectionConfig['driver']);
$config = ['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $adapterName, 'host' => isset($connectionConfig['host']) ? $connectionConfig['host'] : null, 'user' => isset($connectionConfig['username']) ? $connectionConfig['username'] : null, 'pass' => isset($connectionConfig['password']) ? $connectionConfig['password'] : null, 'port' => isset($connectionConfig['port']) ? $connectionConfig['port'] : null, 'name' => $connectionConfig['database'], 'charset' => isset($connectionConfig['encoding']) ? $connectionConfig['encoding'] : null, 'unix_socket' => isset($connectionConfig['unix_socket']) ? $connectionConfig['unix_socket'] : null]]];
if ($adapterName === 'mysql') {
if (!empty($connectionConfig['ssl_key']) && !empty($connectionConfig['ssl_cert'])) {
$config['environments']['default']['mysql_attr_ssl_key'] = $connectionConfig['ssl_key'];
$config['environments']['default']['mysql_attr_ssl_cert'] = $connectionConfig['ssl_cert'];
}
if (!empty($connectionConfig['ssl_ca'])) {
$config['environments']['default']['mysql_attr_ssl_ca'] = $connectionConfig['ssl_ca'];
}
}
return $this->configuration = new Config($config);
}
示例7: api
/**
* Wrap Moxiemanager's api.php in a controller action.
*
* @return void
*/
public function api()
{
try {
$pluginPath = Plugin::path('CkTools');
define('MOXMAN_CLASSES', $pluginPath . 'src/Lib/moxiemanager/classes');
define('MOXMAN_PLUGINS', $pluginPath . 'src/Lib/moxiemanager/plugins');
define('MOXMAN_ROOT', $pluginPath . 'src/Lib/moxiemanager');
define('MOXMAN_API_FILE', __FILE__);
$appConfig = Configure::read('CkTools.moxiemanager');
Configure::load('CkTools.moxiemanager');
$moxieManagerConfig = Configure::read('moxiemanager');
if (is_array($appConfig)) {
$moxieManagerConfig = Hash::merge($moxieManagerConfig, $appConfig);
}
$GLOBALS['moxieManagerConfig'] = $moxieManagerConfig;
require_once MOXMAN_CLASSES . '/MOXMAN.php';
$context = \MOXMAN_Http_Context::getCurrent();
$pluginManager = \MOXMAN::getPluginManager();
foreach ($pluginManager->getAll() as $plugin) {
if ($plugin instanceof \MOXMAN_Http_IHandler) {
$plugin->processRequest($context);
}
}
} catch (Exception $e) {
\MOXMAN_Exception::printException($e);
}
return $this->render(false, false);
}
示例8: setUp
/**
* setUp method
*
* Ensure that the default template is used
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'Template' . DS;
Configure::write('App.namespace', 'Bake\\Test\\App');
$this->_setupTask(['in', 'err', 'error', 'createFile', '_stop']);
TableRegistry::get('TemplateTaskComments', ['className' => __NAMESPACE__ . '\\TemplateTaskCommentsTable']);
}
示例9: icon
public function icon()
{
$iconFile = \Cake\Core\Plugin::path('Admin') . '/config/icons.json';
$iconJson = file_get_contents($iconFile);
$iconArr = json_decode($iconJson, true);
$this->viewBuilder()->autoLayout(false);
$this->set('iconArr', $iconArr);
}
示例10: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
if ($specific = Configure::read('Country.image_path')) {
$this->imageFolder = WWW_ROOT . 'img' . DS . $specific . DS;
} else {
$this->imageFolder = Plugin::path('Data') . DS . 'webroot' . DS . 'img' . DS . 'country_flags' . DS;
}
}
示例11: testBakePlugin
/**
* Test baking within a plugin.
*
* @return void
*/
public function testBakePlugin()
{
$this->_loadTestPlugin('TestBake');
$path = Plugin::path('TestBake');
$this->Task->plugin = 'TestBake';
$this->Task->expects($this->at(0))->method('createFile')->with($this->_normalizePath($path . 'src/Shell/Task/ExampleTask.php'), $this->logicalAnd($this->stringContains('namespace TestBake\\Shell\\Task;'), $this->stringContains('class ExampleTask extends Shell')));
$result = $this->Task->bake('Example');
$this->assertSameAsFile(__FUNCTION__ . '.php', $result);
}
示例12: setUp
/**
* startTest
*
* @return void
*/
public function setUp()
{
$this->Table = new VoidUploadModel();
// $this->Table->addBehavior('Burzum/FileStorage.UploadValidator', [
// 'localFile' => true
// ]);
$this->FileUpload = $this->Table->behaviors()->UploadValidator;
$this->testFilePath = Plugin::path('Burzum/FileStorage') . 'Test' . DS . 'Fixture' . DS . 'File' . DS;
}
示例13: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->_compareBasePath = Plugin::path('Bake') . 'tests' . DS . 'comparisons' . DS . 'BakeView' . DS;
$request = new Request();
$response = new Response();
$this->View = new BakeView($request, $response);
Configure::write('App.paths.templates.x', Plugin::path('Bake') . 'tests' . DS . 'test_app' . DS . 'App' . DS . 'Template' . DS);
}
示例14: setUp
/**
* [setUp description]
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->resetReflectionCache();
$this->_eventManager = EventManager::instance();
$existing = Configure::read('App.paths.templates');
$existing[] = Plugin::path('Crud') . 'tests/App/Template/';
Configure::write('App.paths.templates', $existing);
}
示例15: setUp
/**
* setUp
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('FileStorage.imageSizes', []);
$this->fileFixtures = Plugin::path('Burzum/FileStorage') . 'tests' . DS . 'Fixture' . DS . 'File' . DS;
$this->listener = $this->getMockBuilder('Burzum\\FileStorage\\Storage\\Listener\\LegacyLocalFileStorageListener')->setMethods(['storageAdapter'])->setConstructorArgs([['models' => ['Item']]])->getMock();
$this->adapterMock = $this->getMock('\\Gaufrette\\Adapter\\Local', [], ['']);
$this->FileStorage = TableRegistry::get('Burzum/FileStorage.FileStorage');
}