當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TableRegistry::config方法代碼示例

本文整理匯總了PHP中Cake\ORM\TableRegistry::config方法的典型用法代碼示例。如果您正苦於以下問題:PHP TableRegistry::config方法的具體用法?PHP TableRegistry::config怎麽用?PHP TableRegistry::config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\ORM\TableRegistry的用法示例。


在下文中一共展示了TableRegistry::config方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getMockForModel

 /**
  * Mock a model, maintain fixtures and table association
  *
  * @param string $alias
  * @param array $methods
  * @param array $options
  * @throws \Cake\ORM\Error\MissingTableClassException
  * @return Model
  */
 public function getMockForModel($alias, array $methods = array(), array $options = array())
 {
     if (empty($options['className'])) {
         $class = Inflector::camelize($alias);
         $className = App::classname($class, 'Model/Table', 'Table');
         if (!$className) {
             throw new \Cake\ORM\Error\MissingTableClassException(array($alias));
         }
         $options['className'] = $className;
     }
     list($plugin, $baseClass) = pluginSplit($alias);
     $options += ['alias' => $baseClass] + TableRegistry::config($alias);
     $mock = $this->getMock($options['className'], $methods, array($options));
     TableRegistry::set($alias, $mock);
     return $mock;
 }
開發者ID:ripzappa0924,項目名稱:carte0.0.1,代碼行數:25,代碼來源:TestCase.php

示例2: testConfigAndBuild

 /**
  * Tests that table options can be pre-configured for the factory method
  *
  * @return void
  */
 public function testConfigAndBuild()
 {
     TableRegistry::clear();
     $map = TableRegistry::config();
     $this->assertEquals([], $map);
     $connection = ConnectionManager::get('test', false);
     $options = ['connection' => $connection];
     TableRegistry::config('users', $options);
     $map = TableRegistry::config();
     $this->assertEquals(['users' => $options], $map);
     $this->assertEquals($options, TableRegistry::config('users'));
     $schema = ['id' => ['type' => 'rubbish']];
     $options += ['schema' => $schema];
     TableRegistry::config('users', $options);
     $table = TableRegistry::get('users', ['table' => 'users']);
     $this->assertInstanceOf('Cake\\ORM\\Table', $table);
     $this->assertEquals('users', $table->table());
     $this->assertEquals('users', $table->alias());
     $this->assertSame($connection, $table->connection());
     $this->assertEquals(array_keys($schema), $table->schema()->columns());
     $this->assertEquals($schema['id']['type'], $table->schema()->column('id')['type']);
     TableRegistry::clear();
     $this->assertEmpty(TableRegistry::config());
     TableRegistry::config('users', $options);
     $table = TableRegistry::get('users', ['className' => __NAMESPACE__ . '\\MyUsersTable']);
     $this->assertInstanceOf(__NAMESPACE__ . '\\MyUsersTable', $table);
     $this->assertEquals('users', $table->table());
     $this->assertEquals('users', $table->alias());
     $this->assertSame($connection, $table->connection());
     $this->assertEquals(array_keys($schema), $table->schema()->columns());
 }
開發者ID:neilan35,項目名稱:betterwindow1,代碼行數:36,代碼來源:TableRegistryTest.php

示例3: getMockForModel

 /**
  * Mock a model, maintain fixtures and table association
  *
  * @param string $alias The model to get a mock for.
  * @param mixed $methods The list of methods to mock
  * @param array $options The config data for the mock's constructor.
  * @throws \Cake\ORM\Exception\MissingTableClassException
  * @return \Cake\ORM\Table|\PHPUnit_Framework_MockObject_MockObject
  */
 public function getMockForModel($alias, array $methods = [], array $options = [])
 {
     if (empty($options['className'])) {
         $class = Inflector::camelize($alias);
         $className = App::className($class, 'Model/Table', 'Table');
         if (!$className) {
             throw new MissingTableClassException([$alias]);
         }
         $options['className'] = $className;
     }
     $connectionName = $options['className']::defaultConnectionName();
     $connection = ConnectionManager::get($connectionName);
     list(, $baseClass) = pluginSplit($alias);
     $options += ['alias' => $baseClass, 'connection' => $connection];
     $options += TableRegistry::config($alias);
     $mock = $this->getMock($options['className'], $methods, [$options]);
     if (empty($options['entityClass']) && $mock->entityClass() === '\\Cake\\ORM\\Entity') {
         $parts = explode('\\', $options['className']);
         $entityAlias = Inflector::singularize(substr(array_pop($parts), 0, -5));
         $entityClass = implode('\\', array_slice($parts, 0, -1)) . '\\Entity\\' . $entityAlias;
         if (class_exists($entityClass)) {
             $mock->entityClass($entityClass);
         }
     }
     TableRegistry::set($baseClass, $mock);
     return $mock;
 }
開發者ID:CakeDC,項目名稱:cakephp,代碼行數:36,代碼來源:TestCase.php

示例4: testConfigWithMultipleValidators

 /**
  * Tests that table options can be pre-configured with multiple validators
  *
  * @return void
  */
 public function testConfigWithMultipleValidators()
 {
     $validator1 = new Validator();
     $validator2 = new Validator();
     $validator3 = new Validator();
     TableRegistry::config('users', ['validator' => ['default' => $validator1, 'secondary' => $validator2, 'tertiary' => $validator3]]);
     $table = TableRegistry::get('users');
     $this->assertSame($table->validator('default'), $validator1);
     $this->assertSame($table->validator('secondary'), $validator2);
     $this->assertSame($table->validator('tertiary'), $validator3);
 }
開發者ID:RogerSchmeier,項目名稱:Webtruck,代碼行數:16,代碼來源:TableRegistryTest.php

示例5: getMockForModel

 /**
  * Mock a model, maintain fixtures and table association
  *
  * @param string $alias The model to get a mock for.
  * @param mixed $methods The list of methods to mock
  * @param array $options The config data for the mock's constructor.
  * @throws \Cake\ORM\Exception\MissingTableClassException
  * @return Model
  */
 public function getMockForModel($alias, array $methods = array(), array $options = array())
 {
     if (empty($options['className'])) {
         $class = Inflector::camelize($alias);
         $className = App::className($class, 'Model/Table', 'Table');
         if (!$className) {
             throw new \Cake\ORM\Exception\MissingTableClassException(array($alias));
         }
         $options['className'] = $className;
     }
     $connectionName = $options['className']::defaultConnectionName();
     $connection = ConnectionManager::get($connectionName);
     list($plugin, $baseClass) = pluginSplit($alias);
     $options += ['alias' => $baseClass, 'connection' => $connection];
     $options += TableRegistry::config($alias);
     $mock = $this->getMock($options['className'], $methods, [$options]);
     TableRegistry::set($alias, $mock);
     return $mock;
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:28,代碼來源:TestCase.php

示例6: catch

 * @copyright Copyright 2010 - 2015, Cake Development Corporation (+1 702 425 5085) (http://cakedc.com)
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
use Cake\Core\Configure;
use Cake\Core\Exception\MissingPluginException;
use Cake\Core\Plugin;
use Cake\Event\EventManager;
use Cake\Log\Log;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
Configure::load('CakeDC/Users.users');
collection((array) Configure::read('Users.config'))->each(function ($file) {
    Configure::load($file);
});
TableRegistry::config('Users', ['className' => Configure::read('Users.table')]);
TableRegistry::config('CakeDC/Users.Users', ['className' => Configure::read('Users.table')]);
if (Configure::check('Users.auth')) {
    Configure::write('Auth.authenticate.all.userModel', Configure::read('Users.table'));
}
if (Configure::read('Users.Social.login') && php_sapi_name() != 'cli') {
    try {
        EventManager::instance()->on(\CakeDC\Users\Controller\Component\UsersAuthComponent::EVENT_FAILED_SOCIAL_LOGIN, [new \CakeDC\Users\Controller\UsersController(), 'failedSocialLoginListener']);
    } catch (MissingPluginException $e) {
        Log::error($e->getMessage());
    }
}
$oauthPath = Configure::read('OAuth.path');
if (is_array($oauthPath)) {
    Router::scope('/auth', function ($routes) use($oauthPath) {
        $routes->connect('/:provider', $oauthPath, ['provider' => implode('|', array_keys(Configure::read('OAuth.providers')))]);
    });
開發者ID:cakedc,項目名稱:users,代碼行數:31,代碼來源:bootstrap.php

示例7: testConfig

 /**
  * Test config() method.
  *
  * @return void
  */
 public function testConfig()
 {
     $locator = $this->_setMockLocator();
     $locator->expects($this->once())->method('config')->with('Test', []);
     TableRegistry::config('Test', []);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:11,代碼來源:TableRegistryTest.php

示例8:

<?php

use Cake\ORM\TableRegistry;
/**
 * Create aliases for core objects.
 */
TableRegistry::config('Users', ['className' => 'BEdita\\Core\\Model\\Table\\UsersTable']);
開發者ID:bedita,項目名稱:bedita4-sandbox,代碼行數:7,代碼來源:bootstrap.php


注:本文中的Cake\ORM\TableRegistry::config方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。