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


PHP XmlToAppData::parseFile方法代码示例

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


在下文中一共展示了XmlToAppData::parseFile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例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: 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

示例6: loadDataModels

 /**
  * Gets all matching XML schema files and loads them into data models for class.
  * @return     void
  */
 protected function loadDataModels()
 {
     $ads = array();
     // Get all matched files from schemaFilesets
     foreach ($this->schemaFilesets as $fs) {
         $ds = $fs->getDirectoryScanner($this->project);
         $srcDir = $fs->getDir($this->project);
         $dataModelFiles = $ds->getIncludedFiles();
         $platform = $this->getGeneratorConfig()->getConfiguredPlatform();
         // Make a transaction for each file
         foreach ($dataModelFiles as $dmFilename) {
             $this->log("Processing: " . $dmFilename);
             $xmlFile = new PhingFile($srcDir, $dmFilename);
             $dom = new DomDocument('1.0', 'UTF-8');
             $dom->load($xmlFile->getAbsolutePath());
             // normalize (or transform) the XML document using XSLT
             if ($this->xslFile) {
                 $this->log("Transforming " . $xmlFile->getPath() . " 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 {
                     // modify schema to include any external schema's (and remove the external-schema nodes)
                     $this->includeExternalSchemas($dom, $srcDir);
                     // normalize the document using normalizer stylesheet
                     $xsl = new XsltProcessor();
                     $xsl->importStyleSheet(DomDocument::load($this->xslFile->getAbsolutePath()));
                     $transformed = $xsl->transformToDoc($dom);
                     $newXmlFilename = substr($xmlFile->getName(), 0, strrpos($xmlFile->getName(), '.')) . '-transformed.xml';
                     // now overwrite previous vars to point to newly transformed file
                     $xmlFile = new PhingFile($srcDir, $newXmlFilename);
                     $transformed->save($xmlFile->getAbsolutePath());
                     $this->log("\t- Using new (post-transformation) XML file: " . $xmlFile->getPath(), Project::MSG_VERBOSE);
                     $dom = new DomDocument('1.0', 'UTF-8');
                     $dom->load($xmlFile->getAbsolutePath());
                 }
             }
             // validate the XML document using XSD schema
             if ($this->validate && $this->xsdFile) {
                 $this->log("Validating XML doc (" . $xmlFile->getPath() . ") using schema file " . $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($platform, $this->getTargetPackage(), $this->dbEncoding);
             $ad = $xmlParser->parseFile($xmlFile->getAbsolutePath());
             $ad->setName($dmFilename);
             // <-- Important: use the original name, not the -transformed name.
             $ads[] = $ad;
         }
     }
     if (empty($ads)) {
         throw new BuildException("No schema files were found (matching your schema fileset definition).");
     }
     if (!$this->packageObjectModel) {
         $this->dataModels = $ads;
         $this->databaseNames = array();
         // doesn't seem to be used anywhere
         $this->dataModelDbMap = array();
         // Different datamodels may state the same database
         // names, we just want the unique names of databases.
         foreach ($this->dataModels as $dm) {
             $database = $dm->getDatabase();
             $this->dataModelDbMap[$dm->getName()] = $database->getName();
             $this->databaseNames[$database->getName()] = $database->getName();
             // making list of *unique* dbnames.
         }
     } else {
         $this->joinDatamodels($ads);
         $this->dataModels[0]->getDatabases();
         // calls doFinalInitialization()
     }
     $this->dataModelsLoaded = true;
 }
开发者ID:sensorsix,项目名称:app,代码行数:77,代码来源:AbstractPropelDataModelTask.php

示例7: testParseFileExternalSchema

    public function testParseFileExternalSchema()
    {
        $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'outerSchema.xml');
        $xtad = new XmlToAppData();
        $appData = $xtad->parseFile($path);
        $expectedAppData = <<<EOF
<app-data>
<database name="foo" defaultIdMethod="native" defaultPhpNamingMethod="underscore" defaultTranslateMethod="none">
  <table name="bar1" phpName="Bar1" idMethod="native" skipSql="false" readOnly="false" reloadOnInsert="false" reloadOnUpdate="false" abstract="false">
    <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
  </table>
  <table name="bar2" phpName="Bar2" idMethod="native" skipSql="false" readOnly="false" reloadOnInsert="false" reloadOnUpdate="false" forReferenceOnly="true" abstract="false">
    <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
  </table>
</database>
</app-data>
EOF;
        $this->assertEquals($expectedAppData, $appData->toString());
    }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:19,代码来源:XmlToAppDataTest.php

示例8: 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

示例9: getDbFromXml

 /**
  * 
  * @param \AppData $myAppData
  * @param string $targetDbName
  */
 public static function getDbFromXml(&$myAppData, $targetDbName)
 {
     $db = self::getDbConnector($targetDbName);
     $xmlDbFiles = self::buildTargetDbSchema($targetDbName);
     // Initialize XmlToAppData object
     $appDataObject = new \XmlToAppData(new CentreonMysqlPlatform($db), null, 'utf-8');
     // Get DB File
     foreach ($xmlDbFiles as $dbFile) {
         $myAppData->joinAppDatas(array($appDataObject->parseFile($dbFile)));
         unset($appDataObject);
         $appDataObject = new \XmlToAppData(new CentreonMysqlPlatform($db), null, 'utf-8');
     }
     unset($appDataObject);
 }
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:19,代码来源:Db.php

示例10: 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

示例11: setUp

 public function setUp()
 {
     $xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null);
     $appData = $xmlToAppData->parseFile('fixtures/bookstore/schema.xml');
     $this->database = $appData->getDatabase("bookstore");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:6,代码来源:OMBuilderTest.php

示例12: dropTables

 protected function dropTables()
 {
     $db = Di::getDefault()->get('db_centreon');
     $platform = new CentreonMysqlPlatform($db);
     // Get current DB State
     $currentDb = self::initializeCurrentSchema($platform);
     // Retreive target DB State
     $updatedAppData = new \AppData($platform);
     $appDataObject = new \XmlToAppData(new CentreonMysqlPlatform($db), null, 'utf-8');
     $updatedAppData->joinAppDatas(array($appDataObject->parseFile(__DIR__ . '/data/empty.xml')));
     unset($appDataObject);
     /* @todo Fatorize */
     $diff = \PropelDatabaseComparator::computeDiff($currentDb, $updatedAppData->getDatabase('centreon'), false);
     if (false !== $diff) {
         $strDiff = $platform->getModifyDatabaseDDL($diff);
         $sqlToBeExecuted = \PropelSQLParser::parseString($strDiff);
         \PropelSQLParser::executeString($strDiff, $db);
     }
 }
开发者ID:NicolasLarrouy,项目名称:centreon,代码行数:19,代码来源:DbTestCase.php


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