本文整理汇总了PHP中Propel\Generator\Model\Table::setNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::setNamespace方法的具体用法?PHP Table::setNamespace怎么用?PHP Table::setNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Table
的用法示例。
在下文中一共展示了Table::setNamespace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTableNamespaceAndDbNamespace
public function testTableNamespaceAndDbNamespace()
{
$d = new Database('fooDb');
$d->setNamespace('Baz');
$t = new Table('fooTable');
$t->setNamespace('Foo\\Bar');
$d->addTable($t);
$builder = new TestableOMBuilder2($t);
$this->assertEquals('Baz\\Foo\\Bar', $builder->getNamespace(), 'Builder namespace is composed from the database and table namespaces when both are set');
}
示例2: _before
/**
* @return void
*/
protected function _before()
{
$config = new QuickGeneratorConfig();
$table = new Table('Foo');
$column = new Column('testColumn', PropelTypes::INTEGER);
$table->addColumn($column);
$table->setNamespace('Unit\\Spryker\\Zed\\Propel\\Business\\Builder\\QueryBuilder');
$table->setDatabase(new Database('TestDB', new DefaultPlatform()));
foreach ($this->getFilesToGenerate() as $fileName => $builderClass) {
$builder = new $builderClass($table);
$builder->setGeneratorConfig($config);
$this->writePropelFile($builder, $fileName);
}
}
示例3: computeTableNamespace
/**
* Computes the table namespace based on the current relative or
* absolute table namespace and the database namespace.
*
* @param Table $table
* @return string
*/
private function computeTableNamespace(Table $table)
{
$namespace = $table->getNamespace();
if ($this->isAbsoluteNamespace($namespace)) {
$namespace = ltrim($namespace, '\\');
$table->setNamespace($namespace);
return $namespace;
}
if ($namespace = $this->getNamespace()) {
if ($table->getNamespace()) {
$namespace .= '\\' . $table->getNamespace();
}
$table->setNamespace($namespace);
}
return $namespace;
}
示例4: testSetNamespace
/**
* @dataProvider provideNamespaces
*
*/
public function testSetNamespace($namespace, $expected)
{
$table = new Table();
$table->setNamespace($namespace);
$this->assertSame($expected, $table->getNamespace());
}
示例5: Table
$table3->setPackage('Acme.Blog');
$table3->addColumns([$column31, $column32]);
$table4 = new Table('blog_tag');
$table4->setDescription('The list of tags');
$table4->setNamespace('Blog');
$table4->setPackage('Acme.Blog');
$table4->addColumns([$column41, $column42]);
$table5 = new Table('blog_post_tag');
$table5->setNamespace('Blog');
$table5->setPackage('Acme.Blog');
$table5->setCrossRef();
$table5->addColumns([$column51, $column52]);
$table5->addForeignKeys([$fkPostTag, $fkTagPost]);
$table6 = new Table('cms_page');
$table6->setPhpName('Page');
$table6->setNamespace('Cms');
$table6->setBaseClass('Acme\\Model\\PublicationActiveRecord');
$table6->setPackage('Acme.Cms');
$table6->addColumns([$column61, $column62, $column63, $column64]);
$table6->addIndex($pageContentFulltextIdx);
$table6->addVendorInfo(new VendorInfo('mysql', ['Engine' => 'MyISAM']));
/* Database */
$database = new Database('acme_blog', new MysqlPlatform());
$database->setSchema('acme');
$database->setTablePrefix('acme_');
$database->setNamespace('Acme\\Model');
$database->setBaseClass('Acme\\Model\\ActiveRecord');
$database->setPackage('Acme');
$database->setHeavyIndexing();
$database->addVendorInfo(new VendorInfo('mysql', ['Engine' => 'InnoDB', 'Charset' => 'utf8']));
$database->addTables([$table1, $table2, $table3, $table4, $table5, $table6]);
示例6: testAppendXmlNamespaceWithAutoPackage
public function testAppendXmlNamespaceWithAutoPackage()
{
$schema = <<<EOF
<?xml version="1.0"?>
<table name="test" namespace="\\testNs"/>
EOF;
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$config = new GeneratorConfig();
$config->setBuildProperties(array('propel.namespace.autoPackage' => 'true'));
$appData = new AppData();
$appData->setGeneratorConfig($config);
$db = new Database('testDb');
$db->setAppData($appData);
$table = new Table('test');
$table->setDatabase($db);
$table->setNamespace('\\testNs');
$table->appendXml($doc);
$xmlstr = trim($doc->saveXML());
$this->assertSame($schema, $xmlstr);
$schema = <<<EOF
<?xml version="1.0"?>
<table name="test" namespace="\\testNs" package="testPkg"/>
EOF;
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$table->setPackage('testPkg');
$table->appendXml($doc);
$xmlstr = trim($doc->saveXML());
$this->assertSame($schema, $xmlstr);
}
示例7: testAddTableSkipsDatabaseNamespaceWhenTableNamespaceIsAbsolute
public function testAddTableSkipsDatabaseNamespaceWhenTableNamespaceIsAbsolute()
{
$db = new Database();
$db->setNamespace('Foo');
$t1 = new Table('t1');
$t1->setNamespace('\\Bar');
$db->addTable($t1);
$this->assertEquals('Bar', $t1->getNamespace());
}
示例8: testValidateReturnsTrueWhenTwoTablesHaveSamePhpNameInDifferentNamespaces
public function testValidateReturnsTrueWhenTwoTablesHaveSamePhpNameInDifferentNamespaces()
{
$column1 = new Column('id');
$column1->setPrimaryKey(true);
$table1 = new Table('foo');
$table1->addColumn($column1);
$table1->setNamespace('Foo');
$column2 = new Column('id');
$column2->setPrimaryKey(true);
$table2 = new Table('bar');
$table2->addColumn($column2);
$table2->setPhpName('Foo');
$table2->setNamespace('Bar');
$database = new Database();
$database->addTable($table1);
$database->addTable($table2);
$schema = new Schema();
$schema->addDatabase($database);
$validator = new SchemaValidator($schema);
$this->assertTrue($validator->validate());
}