本文整理汇总了PHP中Cake\ORM\TableRegistry::locator方法的典型用法代码示例。如果您正苦于以下问题:PHP TableRegistry::locator方法的具体用法?PHP TableRegistry::locator怎么用?PHP TableRegistry::locator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\TableRegistry
的用法示例。
在下文中一共展示了TableRegistry::locator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTableLocator
/**
* Tests tableLocator method
*
* @return void
*/
public function testTableLocator()
{
$tableLocator = $this->subject->tableLocator();
$this->assertSame(TableRegistry::locator(), $tableLocator);
$newLocator = $this->getMock('Cake\\ORM\\Locator\\LocatorInterface');
$subjectLocator = $this->subject->tableLocator($newLocator);
$this->assertSame($newLocator, $subjectLocator);
}
示例2: get
/**
* Get the factory for the specified repository type.
*
* @param string $type The repository type to get the factory for.
* @throws InvalidArgumentException If the specified repository type has no factory.
* @return callable The factory for the repository type.
*/
public static function get($type)
{
if (!isset(static::$_modelFactories['Table'])) {
static::$_modelFactories['Table'] = [TableRegistry::locator(), 'get'];
}
if (!isset(static::$_modelFactories[$type])) {
throw new InvalidArgumentException(sprintf('Unknown repository type "%s". Make sure you register a type before trying to use it.', $type));
}
return static::$_modelFactories[$type];
}
示例3: tableLocator
/**
* Sets the table locator.
* If no parameters are passed, it will return the currently used locator.
*
* @param \Cake\ORM\Locator\LocatorInterface|null $tableLocator LocatorInterface instance.
* @return \Cake\ORM\Locator\LocatorInterface
*/
public function tableLocator(LocatorInterface $tableLocator = null)
{
if ($tableLocator !== null) {
$this->_tableLocator = $tableLocator;
}
if (!$this->_tableLocator) {
$this->_tableLocator = TableRegistry::locator();
}
return $this->_tableLocator;
}
示例4: __construct
/**
* Constructor. Looks at Session configuration information and
* sets up the session model.
*
* @param array $config The configuration for this engine. It requires the 'model'
* key to be present corresponding to the Table to use for managing the sessions.
*/
public function __construct(array $config = [])
{
$tableLocator = isset($config['tableLocator']) ? $config['tableLocator'] : TableRegistry::locator();
if (empty($config['model'])) {
$config = $tableLocator->exists('Sessions') ? [] : ['table' => 'sessions'];
$this->_table = $tableLocator->get('Sessions', $config);
} else {
$this->_table = $tableLocator->get($config['model']);
}
$this->_timeout = ini_get('session.gc_maxlifetime');
}
示例5: testLocatorDefault
/**
* Test that locator() method is returing TableLocator by default.
*
* @return void
*/
public function testLocatorDefault()
{
$locator = TableRegistry::locator();
$this->assertInstanceOf('Cake\\ORM\\Locator\\TableLocator', $locator);
}