本文整理汇总了PHP中Cake\ORM\TableRegistry::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP TableRegistry::remove方法的具体用法?PHP TableRegistry::remove怎么用?PHP TableRegistry::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\TableRegistry
的用法示例。
在下文中一共展示了TableRegistry::remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
// 1. Not all fixtures want to use the dev db.
if (is_null($this->tableName)) {
return;
}
// 2. We need to do this to ensure that the tables really do use the connection to the
// dev db.
TableRegistry::remove($this->tableName);
$table = TableRegistry::get($this->tableName, ['connection' => ConnectionManager::get('dev')]);
//if(!is_null($this->joinTableName)) {
//TableRegistry::remove($this->joinTableName);
//$n=TableRegistry::get($this->joinTableName, ['connection' => ConnectionManager::get('fixture')]);
//}
// 3. Now build the query to retrieve the source records
$query = new Query(ConnectionManager::get('dev'), $table);
$query->find('all');
//if(!is_null($this->order)) $query->order($this->order);
//if(!is_null($this->joinTableName)) $query->leftJoin($this->joinTableName,'semesters.id = sections.semester_id');
//$c=$query->count();
// 4. Copy the records
/* @var \Cake\ORM\Entity $record */
foreach ($query as $record) {
$this->records[] = $record->toArray();
}
// 5. Do this again to ensure that the table uses the 'test' connection.
TableRegistry::remove($this->tableName);
TableRegistry::get($this->tableName, ['connection' => ConnectionManager::get('test')]);
//if(!is_null($this->joinTableName)) {
//TableRegistry::remove($this->joinTableName);
//TableRegistry::get($this->joinTableName, ['connection' => ConnectionManager::get('test')]);
//}
}
示例2: tearDown
/**
* tearDown() method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
ini_set('intl.default_locale', $this->default_locale);
unset($this->Items);
TableRegistry::remove('Items');
}
示例3: startup
/**
* Override startup of the Shell
*
* @return void
*/
public function startup()
{
parent::startup();
if (isset($this->params['connection'])) {
$this->connection = $this->params['connection'];
}
$class = Configure::read('Acl.classname');
$className = App::classname('Acl.' . $class, 'Adapter');
if ($class !== 'DbAcl' && !is_subclass_of($className, 'Acl\\Adapter\\DbAcl')) {
$out = "--------------------------------------------------\n";
$out .= __d('cake_acl', 'Error: Your current CakePHP configuration is set to an ACL implementation other than DB.') . "\n";
$out .= __d('cake_acl', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
$out .= "--------------------------------------------------\n";
$out .= __d('cake_acl', 'Current ACL Classname: {0}', [$class]) . "\n";
$out .= "--------------------------------------------------\n";
$this->err($out);
return $this->_stop();
}
if ($this->command) {
if (Configure::check('Datasource') === null) {
$this->out(__d('cake_acl', 'Your database configuration was not found. Take a moment to create one.'));
$this->args = null;
return $this->DbConfig->execute();
}
try {
\Cake\ORM\TableRegistry::get('Aros')->schema();
\Cake\ORM\TableRegistry::remove('Aros');
} catch (\Cake\Database\Exception $e) {
$this->out(__d('cake_acl', 'Acl database tables not found. To create them, run:'));
$this->out();
$this->out(' bin/cake Migrations.migrations migrate -p Acl');
$this->out();
return $this->_stop();
}
$registry = new ComponentRegistry();
$this->Acl = new AclComponent($registry);
$controller = new Controller();
}
}
示例4: tearDown
public function tearDown()
{
TableRegistry::remove('Messages');
TableRegistry::remove('Threads');
TableRegistry::remove('MessageReadStatuses');
}
示例5: testRemove
/**
* Tests remove an instance
*
* @return void
*/
public function testRemove()
{
Plugin::load('TestPlugin');
$pluginTable = TableRegistry::get('TestPlugin.Comments');
$cachedTable = TableRegistry::get('Comments');
$this->assertTrue(TableRegistry::exists('Comments'));
$this->assertSame($pluginTable, $cachedTable);
TableRegistry::remove('Comments');
$this->assertFalse(TableRegistry::exists('Comments'));
$appTable = TableRegistry::get('Comments');
$this->assertTrue(TableRegistry::exists('Comments'));
$this->assertNotSame($pluginTable, $appTable);
}
示例6: testRemovePlugin
/**
* testRemovePlugin
*
* Removing a plugin-prefixed model should not affect any other
* plugin-prefixed model, or app model.
* Removing an app model should not affect any other
* plugin-prefixed model.
*
* @return void
*/
public function testRemovePlugin()
{
Plugin::load('TestPlugin');
Plugin::load('TestPluginTwo');
$app = TableRegistry::get('Comments');
TableRegistry::get('TestPlugin.Comments');
$plugin = TableRegistry::get('TestPluginTwo.Comments');
$this->assertTrue(TableRegistry::exists('Comments'));
$this->assertTrue(TableRegistry::exists('TestPlugin.Comments'));
$this->assertTrue(TableRegistry::exists('TestPluginTwo.Comments'));
TableRegistry::remove('TestPlugin.Comments');
$this->assertTrue(TableRegistry::exists('Comments'));
$this->assertFalse(TableRegistry::exists('TestPlugin.Comments'));
$this->assertTrue(TableRegistry::exists('TestPluginTwo.Comments'));
$app2 = TableRegistry::get('Comments');
$plugin2 = TableRegistry::get('TestPluginTwo.Comments');
$this->assertSame($app, $app2, 'Should be the same Comments object');
$this->assertSame($plugin, $plugin2, 'Should be the same TestPluginTwo.Comments object');
TableRegistry::remove('Comments');
$this->assertFalse(TableRegistry::exists('Comments'));
$this->assertFalse(TableRegistry::exists('TestPlugin.Comments'));
$this->assertTrue(TableRegistry::exists('TestPluginTwo.Comments'));
$plugin3 = TableRegistry::get('TestPluginTwo.Comments');
$this->assertSame($plugin, $plugin3, 'Should be the same TestPluginTwo.Comments object');
}
示例7: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->News);
TableRegistry::remove('CkTools.News');
parent::tearDown();
}
示例8: getAttachedTables
/**
* Vrátí tabulky s chováním, které se mají indexovat
* Return tables with behavior which should be indexed
*
*
* @param bool $indexedByName Pass true if names should be returned instead of Tables
*
* @return array
*/
public function getAttachedTables($indexedByName = false)
{
$modelPath = 'Model' . DS . 'Table';
$modelPath = APP . $modelPath;
$tables = [];
foreach ((new Folder($modelPath))->find('.*.php') as $file) {
$table = str_replace('Table.php', '', $file);
if (TableRegistry::exists($table)) {
TableRegistry::remove($table);
}
$tableTable = TableRegistry::get($table, ['options' => ['skipSimilarInitialize' => true]]);
if ($tableTable->hasBehavior('InRelatedIndex')) {
if ($indexedByName) {
$tables[$table] = $tableTable;
} else {
$tables[] = $tableTable;
}
}
}
return $tables;
}
示例9: testRemove
/**
* Test the remove() method.
*
* @return void
*/
public function testRemove()
{
$locator = $this->_setMockLocator();
$locator->expects($this->once())->method('remove')->with('Test');
TableRegistry::remove('Test');
}