当前位置: 首页>>代码示例>>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;未经允许,请勿转载。