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


PHP TableRegistry::locator方法代碼示例

本文整理匯總了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);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:13,代碼來源:LocatorAwareTraitTest.php

示例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];
 }
開發者ID:nrother,項目名稱:cakephp,代碼行數:17,代碼來源:FactoryLocator.php

示例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;
 }
開發者ID:rlugojr,項目名稱:cakephp,代碼行數:17,代碼來源:LocatorAwareTrait.php

示例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');
 }
開發者ID:thanghexp,項目名稱:project,代碼行數:18,代碼來源:DatabaseSession.php

示例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);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:10,代碼來源:TableRegistryTest.php


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