當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。