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


PHP ConnectionManager::alias方法代码示例

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


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

示例1: _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
  * @see \Cake\TestSuite\Fixture\FixtureManager::_aliasConnections()
  */
 protected function _aliasConnections()
 {
     $connections = ConnectionManager::configured();
     ConnectionManager::alias('test', 'default');
     $map = [];
     foreach ($connections as $connection) {
         if (in_array($connection, ['default', 'test', 'debug_kit'])) {
             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);
     }
 }
开发者ID:nojimage,项目名称:cakephp-TestDatasourceSwitcher,代码行数:31,代码来源:Switcher.php

示例2: 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');
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:11,代码来源:ConnectionManagerTest.php

示例3: bootstrap

 /**
  * A callback method that is used to inject the PDO object created from phinx into
  * the CakePHP connection. This is needed in case the user decides to use tables
  * from the ORM and executes queries.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input the input object
  * @param \Symfony\Component\Console\Output\OutputInterface $output the output object
  * @return void
  */
 public function bootstrap(InputInterface $input, OutputInterface $output)
 {
     parent::bootstrap($input, $output);
     $name = $this->getConnectionName($input);
     ConnectionManager::alias($name, 'default');
     $connection = ConnectionManager::get($name);
     $manager = $this->getManager();
     if (!$manager instanceof CakeManager) {
         $this->setManager(new CakeManager($this->getConfig(), $output));
     }
     $env = $this->getManager()->getEnvironment('default');
     $adapter = $env->getAdapter();
     if (!$adapter instanceof CakeAdapter) {
         $env->setAdapter(new CakeAdapter($adapter, $connection));
     }
 }
开发者ID:Slayug,项目名称:castor,代码行数:25,代码来源:ConfigurationTrait.php

示例4: testGetMockForModelSecondaryDatasource

 /**
  * Test getMockForModel on secondary datasources.
  *
  * @return void
  */
 public function testGetMockForModelSecondaryDatasource()
 {
     ConnectionManager::alias('test', 'secondary');
     $post = $this->getMockForModel(__NAMESPACE__ . '\\SecondaryPostsTable', ['save']);
     $this->assertEquals('test', $post->connection()->configName());
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:11,代码来源:TestCaseTest.php

示例5: _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 $testConnection => $normal) {
         ConnectionManager::alias($testConnection, $normal);
     }
 }
开发者ID:lhas,项目名称:pep,代码行数:30,代码来源:FixtureManager.php

示例6: testGetWithConnectionName

 /**
  * Test that get() uses config data set with config()
  *
  * @return void
  */
 public function testGetWithConnectionName()
 {
     ConnectionManager::alias('test', 'testing');
     $result = $this->_locator->get('Articles', ['connectionName' => 'testing']);
     $this->assertEquals('articles', $result->table());
     $this->assertEquals('test', $result->connection()->configName());
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:12,代码来源:TableLocatorTest.php


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