本文整理汇总了PHP中Cake\Datasource\ConnectionManager::configured方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionManager::configured方法的具体用法?PHP ConnectionManager::configured怎么用?PHP ConnectionManager::configured使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Datasource\ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager::configured方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Override main() to handle action
*
* @return mixed
*/
public function main()
{
if ($this->args && $this->args[0] === 'view') {
$this->out('<error>The view command has been renamed.</error>');
$this->out('To create template files, please use the template command:', 2);
$args = $this->args;
array_shift($args);
$args = implode($args, ' ');
$this->out(sprintf(' <info>`bin/cake bake template %s`</info>', $args), 2);
return false;
}
$connections = ConnectionManager::configured();
if (empty($connections)) {
$this->out('Your database configuration was not found.');
$this->out('Add your database connection information to config/app.php.');
return false;
}
$this->out('The following commands can be used to generate skeleton code for your application.', 2);
$this->out('<info>Available bake commands:</info>', 2);
$this->out('- all');
$names = [];
foreach ($this->tasks as $task) {
list(, $name) = pluginSplit($task);
$names[] = Inflector::underscore($name);
}
sort($names);
foreach ($names as $name) {
$this->out('- ' . $name);
}
$this->out('');
$this->out('By using <info>`cake bake [name]`</info> you can invoke a specific bake task.');
return false;
}
示例2: main
/**
* Override main() to handle action
*
* @return mixed
*/
public function main()
{
$connections = ConnectionManager::configured();
if (empty($connections)) {
$this->out('Your database configuration was not found.');
$this->out('Add your database connection information to config/app.php.');
return false;
}
}
示例3: setUp
protected function setUp()
{
parent::setUp();
$configured = ConnectionManager::configured();
if (empty($configured)) {
ConnectionManager::config('default', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Sqlite', 'database' => self::SQLITE_PATH]);
}
$this->Posts = TableRegistry::get('Posts');
}
示例4: install
/**
* main() method.
*
* @return bool|int Success or error code.
*/
public function install()
{
$connections = ConnectionManager::configured();
if (empty($connections)) {
$this->out('Your database configuration was not found.');
$this->out('Add your database connection information to config/app.php.');
return false;
}
$this->migrate();
$this->migrate('Users');
$this->migrate('Permissions');
$this->cleanup();
}
示例5: main
/**
* Override main() to handle action
*
* @return mixed
*/
public function main()
{
$connections = ConnectionManager::configured();
if (empty($connections)) {
$this->out('Your database configuration was not found.');
$this->out('Add your database connection information to config/app.php.');
return false;
}
$this->out('The following commands can be used to generate skeleton code for your application.', 2);
$this->out('<info>Available bake commands:</info>', 2);
$this->out('- all');
foreach ($this->tasks as $task) {
list($p, $name) = pluginSplit($task);
$this->out('- ' . Inflector::underscore($name));
}
$this->out('');
$this->out('By using <info>`cake bake [name]`</info> you can invoke a specific bake task.');
}
示例6: main
/**
* Override main() to handle action
*
* @return mixed
*/
public function main()
{
$connections = ConnectionManager::configured();
if (empty($connections)) {
$this->out(__d('cake_console', 'Your database configuration was not found.'));
$this->out(__d('cake_console', 'Add your database connection information to App/Config/app.php.'));
return false;
}
$this->out(__d('cake_console', 'The following commands you can generate skeleton code your your application.'));
$this->out('');
$this->out(__d('cake_console', '<info>Available bake commands:</info>'));
$this->out('');
foreach ($this->tasks as $task) {
list($p, $name) = pluginSplit($task);
$this->out(Inflector::underscore($name));
}
$this->out('');
$this->out(__d('cake_console', 'By using <info>Console/cake bake [name]</info> you can invoke a specific bake task.'));
}
示例7: initialize
/**
* Initialize hook - configures logger.
*
* This will unfortunately build all the connections, but they
* won't connect until used.
*
* @return void
*/
public function initialize()
{
$configs = ConnectionManager::configured();
foreach ($configs as $name) {
$connection = ConnectionManager::get($name);
if ($connection->configName() === 'debug_kit') {
continue;
}
$logger = null;
if ($connection->logQueries()) {
$logger = $connection->logger();
}
if ($logger instanceof DebugLog) {
continue;
}
$logger = new DebugLog($logger, $name);
$connection->logQueries(true);
$connection->logger($logger);
$this->_loggers[] = $logger;
}
}
示例8: main
/**
* Override main() to handle action
*
* @return mixed
*/
public function main()
{
$connections = ConnectionManager::configured();
if (empty($connections)) {
$this->out('Your database configuration was not found.');
$this->out('Add your database connection information to config/app.php.');
return false;
}
$this->out('The following commands can be used to import or export tsv file.', 2);
$this->out('<info>Available tsvio commands:</info>', 2);
$names = [];
foreach ($this->tasks as $task) {
list(, $name) = pluginSplit($task);
$names[] = Inflector::underscore($name);
}
sort($names);
foreach ($names as $name) {
$this->out('- ' . $name);
}
$this->out('');
return false;
}
示例9: _aliasConnections
/**
* Add aliases for all non test prefixed connections.
*
* This allows models to use the test connections without
* a pile of configuration work.
*
* @return void
*/
protected function _aliasConnections()
{
$connections = ConnectionManager::configured();
ConnectionManager::alias('test', 'default');
$map = [];
foreach ($connections as $connection) {
if ($connection === 'test' || $connection === 'default') {
continue;
}
if (isset($map[$connection])) {
continue;
}
if (strpos($connection, 'test_') === 0) {
$map[$connection] = substr($connection, 5);
} else {
$map['test_' . $connection] = $connection;
}
}
foreach ($map as $alias => $connection) {
ConnectionManager::alias($alias, $connection);
}
}
示例10: _getQueryLog
/**
* Helper method to get query log.
*
* @return array Query log.
*/
protected function _getQueryLog()
{
$queryLog = [];
$sources = ConnectionManager::configured();
foreach ($sources as $source) {
$logger = ConnectionManager::get($source)->logger();
if (method_exists($logger, 'getLogs')) {
$queryLog[$source] = $logger->getLogs();
}
}
return $queryLog;
}
示例11: testAliasError
/**
* Test alias() raises an error when aliasing an undefined connection.
*
* @expectedException \Cake\Datasource\Exception\MissingDatasourceConfigException
* @return void
*/
public function testAliasError()
{
$this->assertNotContains('test_kaboom', ConnectionManager::configured());
ConnectionManager::alias('test_kaboom', 'other_name');
}
示例12: _getSources
/**
* Get a list of sources defined in database.php
*
* @return array
* @codeCoverageIgnore
*/
protected function _getSources()
{
return ConnectionManager::configured();
}
示例13: main
/**
* Override main() to handle action
*
* @return mixed
*/
public function main()
{
// This adds a style for console formatting. It's used in the menu to better recognize
// the actions' letters.
$this->_io->styles('bold', ['bold' => true, 'underline' => true]);
// Menu
$this->out('', 1, 0);
$this->out('+--[ SuperBake ]------------------------------------------------+');
$this->out('| | ___ |');
$this->out('| | | | <success>Experiments</success> |');
$this->out('| This script generates plugins, models, | / \\ <success>Labs</success> |');
$this->out('| views and controllers for them. | (____\') |');
$this->out('| | |');
$this->out('+---------------------------------------------------------------+', 1, 0);
$this->out('| |', 1, 0);
$this->out('| <info>Welcome to the SuperBake Shell.</info> |', 1, 0);
$this->out('| <info>This Shell can be quieter if launched with the -q option.</info> |');
$this->out('| |', 1, 0);
$this->out('| <warning>Read the doc before things turns bad</warning> |', 1, 0);
$this->out('| |', 1, 0);
$this->out('+---------------------------------------------------------------+', 1, 0);
$this->out('|', 1, 0);
$this->out('| <info>You currently use the ' . $this->Sbc->getTemplateName() . ' template</info>', 1, 0);
$this->out('|', 1, 0);
// Disabled for now as invalid for 3.0
// if (count($this->Sbc->getPrefixesList()) != (count(Configure::read('Routing.prefixes')) + 1)) {
// debug(Configure::read('Routing.prefixes'));die();
// $this->out('| <warning>-->The amount of routing prefixes defined in your core.php.</warning>', 1, 0);
// $this->out('| <warning>--> differs from the ones defined in your configuration files...</warning>', 1, 0);
// $this->out('|', 1, 0);
// }
if ($this->Sbc->getErrors() > 0) {
$this->out('| <warning>--> This file contains errors. Check it.</warning>', 1, 0);
$this->out('|', 1, 0);
}
$connections = ConnectionManager::configured();
if (empty($connections)) {
$this->out('+---------------------------------------------------------------+', 1, 0);
$this->out('| <warning>--> Your database configuration was not found.</warning>');
$this->out('| <warning>--> Add your database connection information to config/app.php.</warning>');
$this->out('|', 1, 0);
return false;
}
$this->out('+--[ <error>' . __d('superBake', 'Plugin creation') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>P</bold>]lugins (Creates all plugins structures)'), 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>S</bold>]pecific entire plugin (M/C/V)'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'Batch generation') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>M</bold>]odels (Generates all models)'), 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>C</bold>]ontrollers (Generates all controllers)'), 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>V</bold>]iews (Generates all views)'), 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>A</bold>]ll (Models, Controllers and Views)'), 1, 0);
$this->out('| ' . __d('superBake', ' Risk[<bold>Y</bold>] (Models, Controllers, Views, Menus, Files and copy required.)'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'Model generation') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' One plugin mo[<bold>D</bold>]els (All models for a specific plugin)'), 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>B</bold>]ake one model'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'Controller generation') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>O</bold>]ne plugin controllers (All controllers for a specific plugin)'), 1, 0);
$this->out('| ' . __d('superBake', ' Bake one contro[<bold>L</bold>]ler'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'View generation') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', '<info>View generation is based on the configuration file, and not</info>'));
$this->out('| ' . __d('superBake', '<info>from the existing controller. That means that if you have modified your</info>'));
$this->out('| ' . __d('superBake', '<info>controllers, the new actions will not be available.</info>'));
$this->out('| ' . __d('superBake', ' O[<bold>N</bold>]e plugin views (All views for a specific plugin)'), 1, 0);
$this->out('| ' . __d('superBake', ' Bake a view for one [<bold>G</bold>]iven action (plugin/controller specific)'), 1, 0);
$this->out('| ' . __d('superBake', ' Views fo[<bold>R</bold>] one given controller'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'Menus') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' M[<bold>E</bold>]nus (Generates menus)'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'Files') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>F</bold>]iles (Generates files)'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'Required files') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' Required f[<bold>I</bold>]les (Copies files and dirs)'), 1, 0);
$this->out('|', 1, 0);
$this->out('+--[ <error>' . __d('superBake', 'Misc') . '</error> ]', 1, 0);
$this->out('| ' . __d('superBake', ' Config [<bold>J</bold>]anitor (Cleans and fills your config. Outputs the result)'), 1, 0);
$this->out('| ' . __d('superBake', ' [<bold>Q</bold>]uit'), 1, 0);
$this->out('|', 1, 0);
// Used letters (just for info):
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
// = = = = = = = = = = = = = = = = = = =
$classToGenerate = strtoupper($this->in('+--> ' . __d('superBake', 'What would you like to generate ?'), ['A', 'B', 'C', 'D', 'E', 'G', 'I', 'J', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'V', 'Y']));
switch ($classToGenerate) {
// Plugins: -------------------------------------------------------
case 'P':
// Plugin structures
$this->Plugins();
break;
case 'M':
// Models
//.........这里部分代码省略.........