本文整理汇总了PHP中CakePlugin::loaded方法的典型用法代码示例。如果您正苦于以下问题:PHP CakePlugin::loaded方法的具体用法?PHP CakePlugin::loaded怎么用?PHP CakePlugin::loaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakePlugin
的用法示例。
在下文中一共展示了CakePlugin::loaded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Datasource constructor, creates the Configuration, Connection and DocumentManager objects
*
* ### You can pass the following configuration options
*
* - server: name of the server that will be used to connect to Mongo (default: `localhost`)
* - database: name of the database to use when connecting to Mongo (default: `cake`)
* - documentPaths: array containing a list of full path names where Document classes can be located (default: `App::path('Model')`)
* - proxyDir: full path to the directory that will contain the generated proxy classes for each document (default: `TMP . 'cache'`)
* - proxyNamespace: string representing the namespace the proxy classes will reside in (default: `Proxies`)
* - hydratorDir: directory well the hydrator classes will be generated in (default: `TMP . 'cache'`)
* - hydratorNamespace: string representing the namespace the hydrator classes will reside in (default: `Hydrators`)
*
* @param arary $config
* @param boolean $autoConnect whether this object should attempt connection on creation
* @throws MissingConnectionException if it was not possible to connect to MongoDB
*/
public function __construct($config = array(), $autoConnect = true)
{
$modelPaths = $this->_cleanupPaths(App::path('Model'));
$this->_baseConfig = array('proxyDir' => TMP . 'cache', 'proxyNamespace' => 'Proxies', 'hydratorDir' => TMP . 'cache', 'hydratorNamespace' => 'Hydrators', 'server' => 'localhost', 'database' => 'cake', 'documentPaths' => $modelPaths, 'prefix' => null);
foreach (CakePlugin::loaded() as $plugin) {
$this->_baseConfig['documentPaths'] = array_merge($this->_baseConfig['documentPaths'], $this->_cleanupPaths(App::path('Model', $plugin)));
}
parent::__construct($config);
extract($this->config, EXTR_OVERWRITE);
$configuration = new Configuration();
$configuration->setProxyDir($proxyDir);
$configuration->setProxyNamespace($proxyNamespace);
$configuration->setHydratorDir($hydratorDir);
$configuration->setHydratorNamespace($hydratorNamespace);
$configuration->setDefaultDB($database);
$configuration->setMetadataDriverImpl($this->_getMetadataReader($documentPaths));
if (Configure::read('debug') === 0) {
$configuration->setAutoGenerateHydratorClasses(false);
$configuration->setAutoGenerateProxyClasses(false);
$configuration->setMetadataCacheImpl(new ApcCache());
}
$this->configuration = $configuration;
$this->connection = new Connection($server, array(), $configuration);
$this->documentManager = DocumentManager::create($this->connection, $configuration);
$this->documentManager->getEventManager()->addEventListener(array(Events::prePersist, Events::preUpdate, Events::preRemove, Events::postPersist, Events::postUpdate, Events::postRemove), $this);
try {
if ($autoConnect) {
$this->connect();
}
} catch (Exception $e) {
throw new MissingConnectionException(array('class' => get_class($this)));
}
$this->setupLogger();
}
示例2: admin_index
public function admin_index()
{
if ($this->request->is('post') && isset($this->request->data)) {
$models = $this->request->data['Audit']['models'];
$models = array_combine(array_values($models), array_values($models));
$this->Setting->write('Audit.models', json_encode($models));
return $this->redirect(array('action' => 'index'));
}
$plugins = App::objects('plugin');
$models = array();
$cakePlugin = new CakePlugin();
foreach ($plugins as $plugin) {
if (!$cakePlugin->loaded($plugin)) {
continue;
}
$pluginModels = App::objects($plugin . '.Model');
foreach ($pluginModels as $pluginModel) {
if (substr($pluginModel, -8) == 'AppModel') {
continue;
}
$model = $plugin . '.' . $pluginModel;
$models[$model] = $model;
}
}
$this->request->data = array('Audit' => array('models' => json_decode(Configure::read('Audit.models'), true)));
$this->set(compact('models'));
}
示例3: update
public function update()
{
if ($this->type == 'app') {
$plugins = CakePlugin::loaded();
} else {
$plugins[] = $this->type;
}
$this->out(__d('cake_console', '<info>-- Migration status in app --</info>'));
$this->dispatchShell('Migrations.migration status -i ' . $this->connection);
$this->hr(1, 100);
if ($this->type == 'app') {
$this->out(__d('cake_console', '<info>-- Application core database migrations --</info>'));
$this->dispatchShell('Migrations.migration run all -i ' . $this->connection);
$this->out(__d('cake_console', '<info>- Application core database updated</info>'));
$this->hr(1, 100);
}
foreach ($plugins as $plugin) {
$plugin_migration_folder = new Folder(CakePlugin::path($plugin) . 'Config' . DS . 'Migration');
list($m_folders, $m_files) = $plugin_migration_folder->read(true, array('empty'));
if (count($m_files)) {
$this->out(__d('cake_console', '<info>-- %s plugin database migrations</info>', $plugin));
$this->dispatchShell('migration run all --plugin ' . $plugin . ' -i ' . $this->connection);
$this->out(__d('cake_console', '<info>- %s plugin database updated</info>', $plugin));
$this->hr(1, 100);
}
}
$this->out(__d('cake_console', '<info>-- Build static assets --</info>'));
$this->dispatchShell('AssetCompress.AssetCompress build -f');
$this->hr(1, 100);
$this->out(__d('cake_console', '<warning>All done</warning>'));
}
示例4: constructClasses
/**
* AppController::constructClasses()
*
* @return void
*/
public function constructClasses()
{
if (CakePlugin::loaded('DebugKit')) {
$this->components[] = 'DebugKit.Toolbar';
}
parent::constructClasses();
}
示例5: testIs
public function testIs()
{
$result = Reveal::is('App.online');
$expected = !in_array(gethostbyname('google.com'), array('google.com', false));
$this->assertEqual($result, $expected);
$result = Reveal::is('DebugKit.loaded');
$expected = CakePlugin::loaded('DebugKit');
$this->assertEqual($result, $expected);
$result = Reveal::is(array('OR' => array('DebugKit.enabled', 'DebugKit.automated')));
$expected = Configure::read('debug') || Configure::read('DebugKit.forceEnable') || Configure::read('DebugKit.autoRun');
$this->assertEqual($result, $expected);
$_GET['debug'] = 'true';
$this->assertTrue(Reveal::is('DebugKit.requested'));
$result = Reveal::is('DebugKit.loaded', array('OR' => array('DebugKit.enabled', array('AND' => array('DebugKit.automated', 'DebugKit.requested')))));
$expected = CakePlugin::loaded('DebugKit') || Configure::read('debug') || Configure::read('DebugKit.forceEnable') || Configure::read('DebugKit.autoRun') && isset($_GET['debug']) && 'true' == $_GET['debug'];
$this->assertEqual($result, $expected);
$this->assertEqual(Reveal::is('DebugKit.running'), $expected);
$request = new CakeRequest();
Router::setRequestInfo($request->addParams(array('controller' => 'pages', 'action' => 'display', 'pass' => array('home'))));
$result = Reveal::is('Page.front');
$this->assertTrue($result);
Router::reload();
$request = new CakeRequest();
Router::setRequestInfo($request->addParams(array('prefix' => 'admin', 'admin' => true)));
$result = Reveal::is('Page.prefixed');
$this->assertTrue($result);
Router::reload();
$request = new CakeRequest();
Router::setRequestInfo($request->addParams(array('controller' => 'users', 'action' => 'login')));
$result = Reveal::is('Page.login');
$this->assertTrue($result);
$this->assertTrue(Reveal::is('Page.test'));
}
示例6: __construct
/**
* Get a list of plugins on construct for later use
*/
public function __construct()
{
foreach (CakePlugin::loaded() as $plugin) {
$this->_pluginPaths[$plugin] = CakePlugin::path($plugin);
}
parent::__construct();
}
示例7: initialize
/**
* Overwrite shell initialize to dynamically load all Queue Related Tasks.
*
* @return void
*/
public function initialize()
{
$paths = App::path('Console/Command/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;
}
$plugins = CakePlugin::loaded();
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/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);
}
}
parent::initialize();
$this->QueuedTask->initConfig();
}
示例8: _basePath
/**
* Generates the base path to a set of tests based on the parameters.
*
* @param array $params
* @return string The base path.
*/
protected static function _basePath($params)
{
$result = null;
if (!empty($params['core'])) {
$result = CORE_TEST_CASES;
// CUSTOMIZE ADD 2014/07/02 ryuring
// >>>
} elseif ($params['baser']) {
$result = BASER_TEST_CASES;
// <<<
} elseif (!empty($params['plugin'])) {
if (!CakePlugin::loaded($params['plugin'])) {
try {
CakePlugin::load($params['plugin']);
$result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case';
} catch (MissingPluginException $e) {
}
} else {
$result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case';
}
} elseif (!empty($params['app'])) {
$result = APP_TEST_CASES;
}
return $result;
}
示例9: main
public function main()
{
$wsdl = $path = $plugin = null;
while (!$wsdl) {
$wsdl = $this->in('Enter the url of the wsdl');
}
while (!$path) {
$path = $this->in('Save to App or a plugin?', array('app', 'plugin'));
}
if ($path == 'plugin') {
$loaded = CakePlugin::loaded();
while (!$plugin) {
$plugin = $this->in('Select plugin', $loaded);
if (!in_array($plugin, $loaded)) {
$plugin = null;
}
}
$path = CakePlugin::path($plugin) . 'Lib';
$plugin .= '.';
} else {
$path = APP . 'Lib';
}
$wsdlInterpreter = new WSDLInterpreter($wsdl);
$return = $wsdlInterpreter->savePHP($path);
$path .= DS;
$file = str_replace($path, '', $return[0]);
$class = substr($file, 0, -4);
$this->hr();
$this->out('Lib saved to:' . $path . $file);
$text = "'lib' => '" . $plugin . $class . "'";
$this->out("Add 'lib' key to the config in database.php: " . $text);
$this->hr();
}
示例10: testHomeRoute
/**
* testHomeRoute
*/
public function testHomeRoute()
{
$promoted = array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'promoted');
$result = CroogoRouter::connect('/', $promoted);
$translateLoaded = CakePlugin::loaded('Translate');
$expected = $translateLoaded ? 2 : 1;
$this->assertEquals($expected, count($result));
$this->assertNotEmpty($result[0]);
$this->assertInstanceOf('CakeRoute', $result[0]);
$reversed = Router::parse('/');
$this->assertEquals($promoted, array_intersect_key($promoted, $reversed));
// another route
$index = array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'index');
$result = CroogoRouter::connect('/nodes', $index);
$expected = $translateLoaded ? 4 : 2;
$this->assertEquals($expected, count($result));
$reversed = Router::parse('/');
$this->assertEquals($promoted, array_intersect_key($promoted, $reversed));
$terms = array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'terms');
$result = CroogoRouter::connect('/', $terms);
$expected = $translateLoaded ? 6 : 3;
$this->assertEquals($expected, count($result));
// override '/' route
Router::promote();
$reversed = Router::parse('/');
$this->assertEquals($terms, array_intersect_key($terms, $reversed));
}
示例11: migrate
/**
* The migrate command.
*
* @return bool
*/
public function migrate()
{
$options = array('direction' => $this->args[0], 'scope' => 'app');
if (isset($this->params['plugin']) && CakePlugin::loaded($this->params['plugin'])) {
$options['scope'] = $this->params['plugin'];
}
if (isset($this->args[1])) {
$options['steps'] = (int) $this->args[1];
}
try {
$migrations = new Migrations($this->params['connection']);
$migrations->migrate($options);
} catch (Exception $e) {
$this->out(__d('migration_shell', 'An error occured during the migration.'));
$this->err($e->getMessage());
return false;
}
$this->out(__d('migration_shell', 'The migration was successful.'));
/** @var SchemaMigration $sm */
$sm = ClassRegistry::init('Migrations.SchemaMigration');
$sm->setDataSource($this->params['connection']);
$this->out(__d('migration_shell', 'Current Migration version: %s', array($sm->getCurrentVersion($options['scope']))));
$migrations->clearCache();
return true;
}
示例12: index
/**
* Take care of any minifying requests.
* The import is not defined outside the class to avoid errors if the class is read from the console.
*
* @return void
*/
public function index($type)
{
$files = array_unique(explode(',', $_GET['f']));
$plugins = array();
$symLinks = array();
$newFiles = array();
if (!empty($this->request->base)) {
$symLinks['/' . $this->request->base] = WWW_ROOT;
}
foreach ($files as &$file) {
if (empty($file)) {
continue;
}
$plugin = false;
list($first, $second) = pluginSplit($file);
if (CakePlugin::loaded($first) === true) {
$file = $second;
$plugin = $first;
}
$pluginPath = !empty($plugin) ? '../Plugin/' . $plugin . '/' . WEBROOT_DIR . '/' : '';
$file = $pluginPath . $type . '/' . $file . '.' . $type;
$newFiles[] = $file;
if (!empty($plugin) && !isset($plugins[$plugin])) {
$plugins[$plugin] = true;
$symLinks['/' . $this->request->base . '/' . Inflector::underscore($plugin)] = APP . 'Plugin/' . $plugin . '/' . WEBROOT_DIR . '/';
}
}
$_GET['f'] = implode(',', $newFiles);
$_GET['symlinks'] = $symLinks;
App::import('Vendor', 'Minify.minify/index');
$this->response->statusCode('304');
exit;
}
示例13: __construct
public function __construct($request = null, $response = null)
{
if (CakePlugin::loaded('DebugKit')) {
$this->components[] = 'DebugKit.Toolbar';
}
parent::__construct($request, $response);
}
示例14: _getFullAssetPath
protected function _getFullAssetPath($path)
{
$filepath = preg_replace('/^' . preg_quote($this->Helper->request->webroot, '/') . '/', '', urldecode($path));
$webrootPath = WWW_ROOT . str_replace('/', DS, $filepath);
if (file_exists($webrootPath)) {
//@codingStandardsIgnoreStart
return $webrootPath;
//@codingStandardsIgnoreEnd
}
$segments = explode('/', ltrim($filepath, '/'));
if ($segments[0] === 'theme') {
$theme = $segments[1];
unset($segments[0], $segments[1]);
$themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments);
//@codingStandardsIgnoreStart
return $themePath;
//@codingStandardsIgnoreEnd
} else {
$plugin = Inflector::camelize($segments[0]);
if (CakePlugin::loaded($plugin)) {
unset($segments[0]);
$pluginPath = CakePlugin::path($plugin) . 'webroot' . DS . implode(DS, $segments);
//@codingStandardsIgnoreStart
return $pluginPath;
//@codingStandardsIgnoreEnd
}
}
return false;
}
示例15: fetch
public function fetch()
{
$pluginName = '.';
if (isset($this->args['0'])) {
$pluginName = $this->args['0'];
}
$this->out('Installing packages for: ' . $pluginName);
$dependencies = array();
if ($pluginName == '.') {
// install ALL
$dependencies = $this->_getDependencies(APP);
foreach (CakePlugin::loaded() as $plugin) {
$dependencies = $this->_getDependencies(App::pluginPath($plugin), $dependencies);
}
} elseif (strtolower($pluginName) == 'app') {
// install App only
$path = APP;
$dependencies = $this->_getDependencies($path);
} else {
// install Plugin only
$path = App::pluginPath($pluginName);
$dependencies = $this->_getDependencies($path);
}
if (count($dependencies) > 0) {
$cmd = 'install';
foreach ($dependencies as $name => $semVer) {
$cmd .= ' ' . $name . '#' . $semVer;
}
$this->out($this->_runCmd($cmd));
} else {
$this->out('No packages info found to be installed.');
}
}