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


PHP Doctrine_Import_Builder类代码示例

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


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

示例1: importObj

 /**
  * importObj
  *
  * A method to import a XML Schema and translate it into a Doctrine_Record object
  *
  * @param string $schema       The file containing the XML schema
  * @param string $directory    The directory where the Doctrine_Record classes will
  *                             be written
  */
 public function importObj($schema, $directory)
 {
     $builder = new Doctrine_Import_Builder();
     $builder->setTargetPath($directory);
     $arr = $this->importArr($schema);
     foreach ($arr as $name => $columns) {
         $Builder->buildRecord($name, $columns);
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:18,代码来源:Xml.php

示例2: testTest

 public function testTest()
 {
     // String values for non-constant values
     $builder = new Doctrine_Import_Builder();
     $code = trim($builder->buildAttributes(array('coll_key' => 'id')));
     $this->assertEqual($code, "\$this->setAttribute(Doctrine::ATTR_COLL_KEY, 'id');");
     // Boolean values
     $code = trim($builder->buildAttributes(array('use_dql_callbacks' => true)));
     $this->assertEqual($code, "\$this->setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, true);");
     $code = trim($builder->buildAttributes(array('use_dql_callbacks' => false)));
     $this->assertEqual($code, "\$this->setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, false);");
     // Constant values
     $code = trim($builder->buildAttributes(array('model_loading' => 'conservative')));
     $this->assertEqual($code, "\$this->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);");
     $code = trim($builder->buildAttributes(array('export' => array('all', 'constraints'))));
     $this->assertEqual($code, "\$this->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL ^ Doctrine::EXPORT_CONSTRAINTS);");
 }
开发者ID:swk,项目名称:bluebox,代码行数:17,代码来源:1628TestCase.php

示例3: generateClass

 /**
  * Generates the class definition for plugin class
  *
  * @param array $definition  Definition array defining columns, relations and options
  *                           for the model
  * @return void
  */
 public function generateClass(array $definition = array())
 {
     $definition['className'] = $this->_options['className'];
     $definition['toString'] = isset($this->_options['toString']) ? $this->_options['toString'] : false;
     if (isset($this->_options['listeners'])) {
         $definition['listeners'] = $this->_options['listeners'];
     }
     $builder = new Doctrine_Import_Builder();
     $builderOptions = isset($this->_options['builderOptions']) ? (array) $this->_options['builderOptions'] : array();
     $builder->setOptions($builderOptions);
     if ($this->_options['generateFiles']) {
         if (isset($this->_options['generatePath']) && $this->_options['generatePath']) {
             $builder->setTargetPath($this->_options['generatePath']);
             $builder->buildRecord($definition);
         } else {
             throw new Doctrine_Record_Exception('If you wish to generate files then you must specify the path to generate the files in.');
         }
     } else {
         $def = $builder->buildDefinition($definition);
         eval($def);
     }
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:29,代码来源:Generator.php

示例4: importSchema

 /**
  * importSchema
  *
  * A method to import a Schema and translate it into a Doctrine_Record object
  *
  * @param  string $schema       The file containing the XML schema
  * @param  string $format       Format of the schema file
  * @param  string $directory    The directory where the Doctrine_Record class will be written
  * @param  array  $models       Optional array of models to import
  *
  * @return void
  */
 public function importSchema($schema, $format = 'yml', $directory = null, $models = array())
 {
     $schema = (array) $schema;
     $builder = new Doctrine_Import_Builder();
     $builder->setTargetPath($directory);
     $builder->setOptions($this->getOptions());
     $array = $this->buildSchema($schema, $format);
     if (count($array) == 0) {
         throw new Doctrine_Import_Exception(sprintf('No ' . $format . ' schema found in ' . implode(", ", $schema)));
     }
     foreach ($array as $name => $definition) {
         if (!empty($models) && !in_array($definition['className'], $models)) {
             continue;
         }
         $builder->buildRecord($definition);
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:29,代码来源:Schema.php

示例5: importSchema

 /**
  * importSchema
  *
  * A method to import a Schema and translate it into a Doctrine_Record object
  *
  * @param  string $schema       The file containing the XML schema
  * @param  string $format       Format of the schema file
  * @param  string $directory    The directory where the Doctrine_Record class will be written
  * @param  array  $models       Optional array of models to import
  *
  * @return void
  */
 public function importSchema($schema, $format = 'yml', $directory = null, $models = array())
 {
     $builder = new Doctrine_Import_Builder();
     $builder->setTargetPath($directory);
     $builder->setOptions($this->getOptions());
     $array = $this->buildSchema($schema, $format);
     foreach ($array as $name => $definition) {
         if (!empty($models) && !in_array($definition['className'], $models)) {
             continue;
         }
         $builder->buildRecord($definition);
     }
 }
开发者ID:walterfrs,项目名称:mladek,代码行数:25,代码来源:Schema.php

示例6: importSchema

 /**
  * importSchema
  *
  * method for importing existing schema to Doctrine_Record classes
  *
  * @param string $directory
  * @param array $databases
  * @return array                the names of the imported classes
  */
 public function importSchema($directory, array $databases = array(), array $options = array())
 {
     $connections = Doctrine_Manager::getInstance()->getConnections();
     foreach ($connections as $name => $connection) {
         // Limit the databases to the ones specified by $databases.
         // Check only happens if array is not empty
         if (!empty($databases) && !in_array($name, $databases)) {
             continue;
         }
         $builder = new Doctrine_Import_Builder();
         $builder->setTargetPath($directory);
         $builder->setOptions($options);
         $classes = array();
         foreach ($connection->import->listTables() as $table) {
             $builder->buildRecord(array('tableName' => $table, 'className' => Doctrine::classify($table)), $connection->import->listTableColumns($table), array());
             $classes[] = Doctrine::classify($table);
         }
     }
     return $classes;
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:29,代码来源:Import.php

示例7: testBaseTableClass

 public function testBaseTableClass()
 {
     $builder = new Doctrine_Import_Builder();
     $builder->setOption('baseTableClassName', 'MyBaseTable');
     $class = $builder->buildTableClassDefinition('MyTestTable', array('className' => 'MyTest'));
     $this->assertTrue(strpos($class, 'class MyTestTable extends MyBaseTable'));
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:7,代码来源:BuilderTestCase.php

示例8: _buildRecord

 /**
  * @param Doctrine_Import_Builder $builder
  * @param array $definition
  */
 protected function _buildRecord($builder, $definition)
 {
     $className = $definition['className'];
     if (strpos($className, "Model_") === false) {
         throw ZFDoctrine_DoctrineException::invalidZendModel($className);
     }
     $classPrefix = substr($className, 0, strpos($className, 'Model_') + strlen('Model_'));
     $camelCaseToDash = new Zend_Filter_Word_CamelCaseToDash();
     $moduleName = current(explode("_", $className));
     $moduleName = strtolower($camelCaseToDash->filter($moduleName));
     if (!isset($this->_modules[$moduleName])) {
         throw ZFDoctrine_DoctrineException::unknownModule($moduleName, $className);
     }
     $builder->setTargetPath($this->_modules[$moduleName]);
     $builder->buildRecord($definition);
     if ($this->_listener) {
         $this->_listener->notifyRecordBuilt($className, $moduleName);
     }
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:23,代码来源:Schema.php

示例9: importSchema

 /**
  * importSchema
  *
  * A method to import a Schema and translate it into a Doctrine_Record object
  *
  * @param  string $schema       The file containing the XML schema
  * @param  string $directory    The directory where the Doctrine_Record class will be written
  * @param  array $models        Optional array of models to import
  *
  * @return void
  */
 public function importSchema($schema, $format = 'yml', $directory = null, $models = array())
 {
     $builder = new Doctrine_Import_Builder();
     $builder->setTargetPath($directory);
     foreach ($this->_options as $key => $value) {
         if ($value) {
             $builder->setOption($key, $value);
         }
     }
     $array = $this->buildSchema($schema, $format);
     foreach ($array as $name => $properties) {
         if (!empty($models) && !in_array($properties['className'], $models)) {
             continue;
         }
         $options = $this->getOptions($properties);
         $columns = $this->getColumns($properties);
         $relations = $this->getRelations($properties);
         $indexes = $this->getIndexes($properties);
         $attributes = $this->getAttributes($properties);
         $templates = $this->getTemplates($properties);
         $actAs = $this->getActAs($properties);
         $tableOptions = $this->getTableOptions($properties);
         $builder->buildRecord($options, $columns, $relations, $indexes, $attributes, $templates, $actAs, $tableOptions);
     }
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:36,代码来源:Schema.php

示例10: generateClass

 /**
  * generates the class definition for plugin class
  *
  * @param array $columns    the plugin class columns, keys representing the column names
  *                          and values as column definitions
  *
  * @param array $relations  the bound relations of the plugin class
  *
  * @param array $options    plugin class options, keys representing the option names
  *                          and values as option values
  * @return void
  */
 public function generateClass(array $columns = array(), array $relations = array(), array $options = array())
 {
     $options['className'] = $this->_options['className'];
     $builder = new Doctrine_Import_Builder();
     if ($this->_options['generateFiles']) {
         if (isset($this->_options['generatePath']) && $this->_options['generatePath']) {
             $builder->setTargetPath($this->_options['generatePath']);
             $builder->buildRecord($options, $columns, $relations);
         } else {
             throw new Doctrine_Plugin_Exception('If you wish to generate files then you must specify the path to generate the files in.');
         }
     } else {
         $def = $builder->buildDefinition($options, $columns, $relations);
         eval($def);
     }
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:28,代码来源:Plugin.php

示例11: importSchema

 /**
  * importSchema
  *
  * method for importing existing schema to Doctrine_Record classes
  *
  * @param string $directory
  * @param array $connections Array of connection names to generate models for
  * @return array                the names of the imported classes
  */
 public function importSchema($directory, array $connections = array(), array $options = array())
 {
     $classes = array();
     $manager = Doctrine_Manager::getInstance();
     foreach ($manager as $name => $connection) {
         // Limit the databases to the ones specified by $connections.
         // Check only happens if array is not empty
         if (!empty($connections) && !in_array($name, $connections)) {
             continue;
         }
         $builder = new Doctrine_Import_Builder();
         $builder->setTargetPath($directory);
         $builder->setOptions($options);
         $definitions = array();
         foreach ($connection->import->listTables() as $table) {
             $definition = array();
             $definition['tableName'] = $table;
             $definition['className'] = Doctrine_Inflector::classify(Doctrine_Inflector::tableize($table));
             $definition['columns'] = $connection->import->listTableColumns($table);
             $definition['connection'] = $connection->getName();
             $definition['connectionClassName'] = $definition['className'];
             try {
                 $definition['relations'] = array();
                 $relations = $connection->import->listTableRelations($table);
                 $relClasses = array();
                 foreach ($relations as $relation) {
                     $table = $relation['table'];
                     $class = Doctrine_Inflector::classify(Doctrine_Inflector::tableize($table));
                     if (in_array($class, $relClasses)) {
                         $alias = $class . '_' . (count($relClasses) + 1);
                     } else {
                         $alias = $class;
                     }
                     $relClasses[] = $class;
                     $definition['relations'][$alias] = array('alias' => $alias, 'class' => $class, 'local' => $relation['local'], 'foreign' => $relation['foreign']);
                 }
             } catch (Exception $e) {
             }
             $definitions[strtolower($definition['className'])] = $definition;
             $classes[] = $definition['className'];
         }
         // Build opposite end of relationships
         foreach ($definitions as $definition) {
             $className = $definition['className'];
             $relClasses = array();
             foreach ($definition['relations'] as $alias => $relation) {
                 if (in_array($relation['class'], $relClasses) || isset($definitions[$relation['class']]['relations'][$className])) {
                     $alias = $className . '_' . (count($relClasses) + 1);
                 } else {
                     $alias = $className;
                 }
                 $relClasses[] = $relation['class'];
                 $definitions[strtolower($relation['class'])]['relations'][$alias] = array('type' => Doctrine_Relation::MANY, 'alias' => $alias, 'class' => $className, 'local' => $relation['foreign'], 'foreign' => $relation['local']);
             }
         }
         // Build records
         foreach ($definitions as $definition) {
             $builder->buildRecord($definition);
         }
     }
     return $classes;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:71,代码来源:Import.php

示例12: importSchema

 /**
  * importSchema
  *
  * method for importing existing schema to Doctrine_Record classes
  *
  * @param string $directory
  * @param array $databases
  * @return array                the names of the imported classes
  */
 public function importSchema($directory, array $databases = array(), array $options = array())
 {
     $options['singularize'] = !isset($options['singularize']) ? $this->conn->getAttribute('singularize_import') : $options['singularize'];
     $connections = Doctrine_Manager::getInstance()->getConnections();
     foreach ($connections as $name => $connection) {
         // Limit the databases to the ones specified by $databases.
         // Check only happens if array is not empty
         if (!empty($databases) && !in_array($name, $databases)) {
             continue;
         }
         $builder = new Doctrine_Import_Builder();
         $builder->setTargetPath($directory);
         $builder->setOptions($options);
         $classes = array();
         foreach ($connection->import->listTables() as $table) {
             $definition = array();
             $definition['tableName'] = $table;
             // echo $table . "<br />\n";
             if (!isset($options['singularize']) || $options['singularize'] !== false) {
                 $e = explode('_', Doctrine_Inflector::tableize($table));
                 foreach ($e as $k => $v) {
                     $e[$k] = Doctrine_Inflector::singularize($v);
                 }
                 $classTable = implode('_', $e);
             } else {
                 $classTable = Doctrine_Inflector::tableize($table);
             }
             $definition['className'] = Doctrine_Inflector::classify($classTable);
             $definition['columns'] = $connection->import->listTableColumns($table);
             //var_dump ($definition);
             $builder->buildRecord($definition);
             $classes[] = $definition['className'];
         }
     }
     return $classes;
 }
开发者ID:adnanali,项目名称:munch,代码行数:45,代码来源:Import.php

示例13: import

 /**
  * import
  *
  * method for importing existing schema to Doctrine_Record classes
  *
  * @param string $directory
  * @param array $databases
  * @return array                the names of the imported classes
  */
 public function import($directory, array $databases = array())
 {
     $builder = new Doctrine_Import_Builder();
     $builder->setTargetPath($directory);
     $classes = array();
     foreach ($this->listTables() as $table) {
         $builder->buildRecord($table, $this->listTableColumns($table));
         $classes[] = Doctrine::classify($table);
     }
     return $classes;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:20,代码来源:Import.php

示例14: writeDefinition

 public function writeDefinition(array $definition)
 {
     if (isset($definition['is_main_class']) && $definition['is_main_class'] === true) {
         $definition['inheritance']['extends'] = $this->_getBaseClassName($definition['className']);
     }
     return parent::writeDefinition($definition);
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:7,代码来源:Builder.php

示例15: loadTemplate

 /**
  * loadTemplate
  *
  * Loads the class template used for generating classes
  *
  * @return void
  */
 public function loadTemplate()
 {
     if (isset(self::$_tpl)) {
         return;
     }
     self::$_tpl = '/**' . PHP_EOL . ' * This class has been auto-generated by the Doctrine ORM Framework' . PHP_EOL . ' */' . PHP_EOL . '%sclass %s extends %s' . PHP_EOL . '{' . '%s' . PHP_EOL . '%s' . PHP_EOL . '}';
 }
开发者ID:silky,项目名称:littlesis,代码行数:14,代码来源:Builder.php


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