当前位置: 首页>>代码示例>>PHP>>正文


PHP XmlToAppData类代码示例

本文整理汇总了PHP中XmlToAppData的典型用法代码示例。如果您正苦于以下问题:PHP XmlToAppData类的具体用法?PHP XmlToAppData怎么用?PHP XmlToAppData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XmlToAppData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetConstantName

 public function testGetConstantName()
 {
     $xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null);
     $appData = $xmlToAppData->parseFile('fixtures/bookstore/behavior-schema.xml');
     $column = $appData->getDatabase("bookstore-behavior")->getTable('table1')->getColumn('title');
     $this->assertEquals('Table1Peer::TITLE', $column->getConstantName(), 'getConstantName() returns the complete constant name by default');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:7,代码来源:ColumnTest.php

示例2: testIsLocalColumnsRequired

 public function testIsLocalColumnsRequired()
 {
     $xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null);
     $appData = $xmlToAppData->parseFile('fixtures/bookstore/schema.xml');
     $fk = $appData->getDatabase("bookstore")->getTable('book')->getColumnForeignKeys('publisher_id');
     $this->assertFalse($fk[0]->isLocalColumnsRequired());
     $fk = $appData->getDatabase("bookstore")->getTable('review')->getColumnForeignKeys('book_id');
     $this->assertTrue($fk[0]->isLocalColumnsRequired());
 }
开发者ID:nextbigsound,项目名称:propel-orm,代码行数:9,代码来源:ColumnTest.php

示例3: setUp

 public function setUp()
 {
     // run only once to save execution time
     if (null == self::$database) {
         $xmlToAppData = new XmlToAppData(new DefaultPlatform());
         $appData = $xmlToAppData->parseFile(realpath(dirname(__FILE__) . '/../../../../fixtures/bookstore/schema.xml'));
         self::$database = $appData->getDatabase("bookstore");
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:9,代码来源:OMBuilderRelatedByTest.php

示例4: testAddBehavior

 public function testAddBehavior()
 {
     $platform = new MysqlPlatform();
     $config = new GeneratorConfig();
     $config->setBuildProperties(array('propel.behavior.timestampable.class' => 'propel.engine.behavior.TimestampableBehavior'));
     $platform->setGeneratorConfig($config);
     $xmlToAppData = new XmlToAppData($platform, "defaultpackage", null);
     $appData = $xmlToAppData->parseFile('fixtures/bookstore/behavior-schema.xml');
     $table = $appData->getDatabase("bookstore-behavior")->getTable('table1');
     $this->assertThat($table->getBehavior('timestampable'), $this->isInstanceOf('TimestampableBehavior'), 'addBehavior() uses the behavior class defined in build.properties');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:11,代码来源:TableTest.php

示例5: testDescColumn

 public function testDescColumn()
 {
     $schema = '<database name="reverse_bookstore"><table name="book"><column name="title" type="VARCHAR" size="255" description="Book Title with accent éài" /></table></database>';
     $xtad = new XmlToAppData();
     $appData = $xtad->parseString($schema);
     $database = $appData->getDatabase();
     $table = $database->getTable('book');
     $c1 = $table->getColumn('title');
     $parser = new MysqlSchemaParser(Propel::getConnection('reverse-bookstore'));
     $parser->setGeneratorConfig(new QuickGeneratorConfig());
     $database = new Database();
     $database->setPlatform(new DefaultPlatform());
     $parser->parse($database);
     $c2 = $database->getTable('book')->getColumn('title');
     $this->assertEquals($c1->getDescription(), $c2->getDescription());
 }
开发者ID:thehereward,项目名称:Propel,代码行数:16,代码来源:MysqlSchemaParserTest.php

示例6: testDecimal

 public function testDecimal()
 {
     $t1 = new Table('foo');
     $schema = '<database name="reverse_bookstore"><table name="foo"><column name="longitude" type="DECIMAL" scale="7" size="10" /></table></database>';
     $xtad = new XmlToAppData();
     $appData = $xtad->parseString($schema);
     $database = $appData->getDatabase();
     $table = $database->getTable('foo');
     $c1 = $table->getColumn('longitude');
     $parser = new MysqlSchemaParser(Propel::getConnection('reverse-bookstore'));
     $parser->setGeneratorConfig(new QuickGeneratorConfig());
     $database = new Database();
     $database->setPlatform(new MysqlPlatform());
     $parser->parse($database);
     $table = $database->getTable('foo');
     $c2 = $table->getColumn('longitude');
     $this->assertEquals($c1->getSize(), $c2->getSize());
     $this->assertEquals($c1->getScale(), $c2->getScale());
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:19,代码来源:MysqlSchemaParserTest.php

示例7: getDatabasesFromSchema

 protected function getDatabasesFromSchema(\SplFileInfo $file)
 {
     $transformer = new \XmlToAppData(null, null, 'UTF-8');
     $config = new \QuickGeneratorConfig();
     if (file_exists($propelIni = $this->getContainer()->getParameter('kernel.root_dir') . '/config/propel.ini')) {
         foreach ($this->getProperties($propelIni) as $key => $value) {
             if (0 === strpos($key, 'propel.')) {
                 $newKey = substr($key, strlen('propel.'));
                 $j = strpos($newKey, '.');
                 while (false !== $j) {
                     $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1));
                     $j = strpos($newKey, '.');
                 }
                 $config->setBuildProperty($newKey, $value);
             }
         }
     }
     $transformer->setGeneratorConfig($config);
     return $transformer->parseFile($file->getPathName())->getDatabases();
 }
开发者ID:angelk,项目名称:PropelBundle,代码行数:20,代码来源:GeneratorAwareCommand.php

示例8: getDatabase

 public function getDatabase()
 {
     if (null === $this->database) {
         $xtad = new XmlToAppData($this->getPlatform());
         $appData = $xtad->parseString($this->schema);
         $this->database = $appData->getDatabase();
         // does final initialization
     }
     return $this->database;
 }
开发者ID:halfer,项目名称:Meshing,代码行数:10,代码来源:PropelQuickBuilder.php

示例9: testGetAddTableDDLEngine

    public function testGetAddTableDDLEngine()
    {
        $schema = <<<EOF
<database name="test">
    <table name="foo">
        <column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
    </table>
</database>
EOF;
        $platform = new MysqlPlatform();
        $platform->setTableEngineKeyword('TYPE');
        $platform->setDefaultTableEngine('MEMORY');
        $xtad = new XmlToAppData($platform);
        $appData = $xtad->parseString($schema);
        $table = $appData->getDatabase()->getTable('foo');
        $expected = "\nCREATE TABLE `foo`\n(\n    `id` INTEGER NOT NULL AUTO_INCREMENT,\n    PRIMARY KEY (`id`)\n) TYPE=MEMORY;\n";
        $this->assertEquals($expected, $platform->getAddTableDDL($table));
    }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:18,代码来源:MysqlPlatformTest.php

示例10: getDatabase

 public function getDatabase()
 {
     if (null === $this->database) {
         $xtad = new XmlToAppData($this->getPlatform());
         $xtad->setGeneratorConfig($this->getConfig());
         $this->database = $xtad->parseString($this->schema)->getDatabase();
     }
     return $this->database;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:9,代码来源:PropelQuickBuilder.php

示例11: testGetColumnForParameter

    public function testGetColumnForParameter()
    {
        $xmlToAppData = new XmlToAppData();
        $schema = <<<EOF
<database name="test1">
  <table name="table1">
    <column name="id" type="INTEGER" primaryKey="true" />
    <column name="title" type="VARCHAR" size="100" primaryString="true" />
    <column name="created_on" type="TIMESTAMP" />
    <column name="updated_on" type="TIMESTAMP" />
    <behavior name="timestampable">
      <parameter name="create_column" value="created_on" />
      <parameter name="update_column" value="updated_on" />
    </behavior>
  </table>
</database>
EOF;
        $appData = $xmlToAppData->parseString($schema);
        $table = $appData->getDatabase('test1')->getTable('table1');
        $behavior = $table->getBehavior('timestampable');
        $this->assertEquals($table->getColumn('created_on'), $behavior->getColumnForParameter('create_column'), 'getColumnForParameter() returns the configured column for behavior based on a parameter name');
    }
开发者ID:pkdevbox,项目名称:mootools-forge,代码行数:22,代码来源:BehaviorTest.php

示例12: getDbFromXml

 /**
  * 
  * @param \AppData $myAppData
  * @param string $targetDbName
  */
 public static function getDbFromXml(&$myAppData, $operation, $targetDbName)
 {
     // Initialize configuration
     $di = Di::getDefault();
     $targetDb = 'db_' . $targetDbName;
     $db = $di->get($targetDb);
     $xmlDbFiles = self::getAllXmlFiles($operation, $targetDbName);
     // Initialize XmlToAppData object
     $appDataObject = new \XmlToAppData(new \Centreon\Custom\Propel\CentreonMysqlPlatform($db), null, 'utf-8');
     // Get DB File
     foreach ($xmlDbFiles as $dbFile) {
         $myAppData->joinAppDatas(array($appDataObject->parseFile($dbFile)));
         unset($appDataObject);
         $appDataObject = new \XmlToAppData(new \Centreon\Custom\Propel\CentreonMysqlPlatform($db), null, 'utf-8');
     }
     unset($appDataObject);
 }
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:22,代码来源:Installer.php

示例13: testUniqueTableName

 public function testUniqueTableName()
 {
     $platform = new MysqlPlatform();
     $config = new GeneratorConfig();
     $platform->setGeneratorConfig($config);
     $xmlToAppData = new XmlToAppData($platform, 'defaultpackage', null);
     try {
         $appData = $xmlToAppData->parseFile('fixtures/unique-column/table-schema.xml');
         $this->fail('Parsing file with duplicate table name throws exception');
     } catch (EngineException $e) {
         $this->assertTrue(true, 'Parsing file with duplicate table name throws exception');
     }
 }
开发者ID:nextbigsound,项目名称:propel-orm,代码行数:13,代码来源:TableTest.php

示例14: getModels

 protected function getModels($databaseManager, $verbose = false)
 {
     Phing::startup();
     // required to locate behavior classes...
     $schemas = sfFinder::type('file')->name('*schema.xml')->follow_link()->in(sfConfig::get('sf_config_dir'));
     if (!$schemas) {
         throw new sfCommandException('You must create a schema.yml or schema.xml file.');
     }
     $ads = array();
     foreach ($schemas as $schema) {
         if ($verbose) {
             $this->logSection('schema', sprintf('  Parsing schema "%s"', $schema), null, 'COMMENT');
         }
         $dom = new DomDocument('1.0', 'UTF-8');
         $dom->load($schema);
         //$this->includeExternalSchemas($dom, sfConfig::get('sf_config_dir'));
         $xmlParser = new XmlToAppData(new DefaultPlatform(), '');
         $generatorConfig = $this->getGeneratorConfig();
         $generatorConfig->setBuildConnections($this->getConnections($databaseManager));
         $xmlParser->setGeneratorConfig($generatorConfig);
         $ad = $xmlParser->parseString($dom->saveXML(), $schema);
         $ads[] = $ad;
         $nbTables = $ad->getDatabase(null, false)->countTables();
         if ($verbose) {
             $this->logSection('schema', sprintf('  %d tables processed successfully', $nbTables), null, 'COMMENT');
         }
     }
     if (count($ads) > 1) {
         $ad = array_shift($ads);
         $ad->joinAppDatas($ads);
         //$ad = $this->joinDataModels($ads);
         //$this->dataModels = array($ad);
     } else {
         $ad = $ads[0];
     }
     $ad->doFinalInitialization();
     return $ad;
 }
开发者ID:rafix,项目名称:gesCorreo,代码行数:38,代码来源:sfPropelBaseTask.class.php

示例15: loadDataModels

 /**
  * Gets all matching XML schema files and loads them into data models for class.
  * @return void
  */
 protected function loadDataModels()
 {
     $ads = array();
     $totalNbTables = 0;
     $this->log('Loading XML schema files...');
     // Get all matched files from schemaFilesets
     foreach ($this->schemaFilesets as $fs) {
         $ds = $fs->getDirectoryScanner($this->project);
         $srcDir = $fs->getDir($this->project);
         $dataModelFiles = $ds->getIncludedFiles();
         sort($dataModelFiles);
         $defaultPlatform = $this->getGeneratorConfig()->getConfiguredPlatform();
         // Make a transaction for each file
         foreach ($dataModelFiles as $dmFilename) {
             $this->log("Processing: " . $dmFilename, Project::MSG_VERBOSE);
             $xmlFile = new PhingFile($srcDir, $dmFilename);
             $dom = new DomDocument('1.0', 'UTF-8');
             $dom->load($xmlFile->getAbsolutePath());
             // modify schema to include any external schemas (and remove the external-schema nodes)
             $this->includeExternalSchemas($dom, $srcDir);
             // normalize (or transform) the XML document using XSLT
             if ($this->getGeneratorConfig()->getBuildProperty('schemaTransform') && $this->xslFile) {
                 $this->log("Transforming " . $dmFilename . " using stylesheet " . $this->xslFile->getPath(), Project::MSG_VERBOSE);
                 if (!class_exists('XSLTProcessor')) {
                     $this->log("Could not perform XLST transformation. Make sure PHP has been compiled/configured to support XSLT.", Project::MSG_ERR);
                 } else {
                     // normalize the document using normalizer stylesheet
                     $xslDom = new DomDocument('1.0', 'UTF-8');
                     $xslDom->load($this->xslFile->getAbsolutePath());
                     $xsl = new XsltProcessor();
                     $xsl->importStyleSheet($xslDom);
                     $dom = $xsl->transformToDoc($dom);
                 }
             }
             // validate the XML document using XSD schema
             if ($this->validate && $this->xsdFile) {
                 $this->log("  Validating XML using schema " . $this->xsdFile->getPath(), Project::MSG_VERBOSE);
                 if (!$dom->schemaValidate($this->xsdFile->getAbsolutePath())) {
                     throw new EngineException("XML schema file (" . $xmlFile->getPath() . ") does not validate. See warnings above for reasons validation failed (make sure error_reporting is set to show E_WARNING if you don't see any).", $this->getLocation());
                 }
             }
             $xmlParser = new XmlToAppData($defaultPlatform, $this->getTargetPackage(), $this->dbEncoding);
             $xmlParser->setGeneratorConfig($this->getGeneratorConfig());
             $ad = $xmlParser->parseString($dom->saveXML(), $xmlFile->getAbsolutePath());
             $nbTables = $ad->getDatabase(null, false)->countTables();
             $totalNbTables += $nbTables;
             $this->log(sprintf('  %d tables processed successfully', $nbTables), Project::MSG_VERBOSE);
             $ad->setName($dmFilename);
             $ads[] = $ad;
         }
         $this->log(sprintf('%d tables found in %d schema files.', $totalNbTables, count($dataModelFiles)));
     }
     if (empty($ads)) {
         throw new BuildException("No schema files were found (matching your schema fileset definition).");
     }
     foreach ($ads as $ad) {
         // map schema filename with database name
         $this->dataModelDbMap[$ad->getName()] = $ad->getDatabase(null, false)->getName();
     }
     if (count($ads) > 1 && $this->packageObjectModel) {
         $ad = $this->joinDataModels($ads);
         $this->dataModels = array($ad);
     } else {
         $this->dataModels = $ads;
     }
     foreach ($this->dataModels as &$ad) {
         $ad->doFinalInitialization();
     }
     if ($this->validate) {
         foreach ($this->dataModels as $dataModel) {
             $validator = new PropelSchemaValidator($dataModel);
             if (!$validator->validate()) {
                 throw new EngineException(sprintf("The database schema contains errors:\n - %s", join("\n - ", $validator->getErrors())));
             }
         }
     }
     $this->dataModelsLoaded = true;
 }
开发者ID:nevalla,项目名称:Propel,代码行数:82,代码来源:AbstractPropelDataModelTask.php


注:本文中的XmlToAppData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。