本文整理匯總了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);
}