Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Generator] Removed no more used tasks

  • Loading branch information...
commit aa56abcf83c799dc45fc6432cc068c1c3d23da7a 1 parent 36eb3f2
@willdurand willdurand authored
View
222 src/Propel/Generator/Task/PropelOMTask.php
@@ -1,222 +0,0 @@
-<?php
-
-/**
- * This file is part of the Propel package.
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @license MIT License
- */
-
-namespace Propel\Generator\Task;
-
-use Propel\Generator\Builder\Om\ClassTools;
-use Propel\Generator\Builder\Om\AbstractOMBuilder;
-
-use \PhingFile;
-use \Project;
-
-/**
- * This Task creates the OM classes based on the XML schema file.
- *
- * @author Hans Lellelid <hans@xmpl.org>
- */
-class PropelOMTask extends AbstractPropelDataModelTask
-{
-
- /**
- * The platform (php4, php5, etc.) for which the om is being built.
- * @var string
- */
- private $targetPlatform;
-
- /**
- * Sets the platform (php4, php5, etc.) for which the om is being built.
- * @param string $v
- */
- public function setTargetPlatform($v) {
- $this->targetPlatform = $v;
- }
-
- /**
- * Gets the platform (php4, php5, etc.) for which the om is being built.
- * @return string
- */
- public function getTargetPlatform() {
- return $this->targetPlatform;
- }
-
- /**
- * Utility method to create directory for package if it doesn't already exist.
- * @param string $path The [relative] package path.
- * @throws BuildException - if there is an error creating directories
- */
- protected function ensureDirExists($path)
- {
- $f = new PhingFile($this->getOutputDirectory(), $path);
- if (!$f->exists()) {
- if (!$f->mkdirs()) {
- throw new BuildException("Error creating directories: ". $f->getPath());
- }
- }
- }
-
- /**
- * Uses a builder class to create the output class.
- * This method assumes that the DataModelBuilder class has been initialized with the build properties.
- * @param OMBuilder $builder
- * @param boolean $overwrite Whether to overwrite existing files with te new ones (default is YES).
- * @todo -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic).
- */
- protected function build(AbstractOMBuilder $builder, $overwrite = true)
- {
- $path = $builder->getClassFilePath();
- $this->ensureDirExists(dirname($path));
-
- $_f = new PhingFile($this->getOutputDirectory(), $path);
-
- // skip files already created once
- if ($_f->exists() && !$overwrite) {
- $this->log("\t-> (exists) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
-
- return 0;
- }
-
- $script = $builder->build();
- foreach ($builder->getWarnings() as $warning) {
- $this->log($warning, Project::MSG_WARN);
- }
-
- // skip unchanged files
- if ($_f->exists() && $script == $_f->contents()) {
- $this->log("\t-> (unchanged) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
-
- return 0;
- }
-
- // write / overwrite new / changed files
- $action = $_f->exists() ? 'Updating' : 'Creating';
- $this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
- file_put_contents($_f->getAbsolutePath(), $script);
-
- return 1;
- }
-
- /**
- * Main method builds all the targets for a typical propel project.
- */
- public function main()
- {
- // check to make sure task received all correct params
- $this->validate();
-
- $generatorConfig = $this->getGeneratorConfig();
- $totalNbFiles = 0;
-
- $dataModels = $this->getDataModels();
- $this->log('Generating PHP files...');
-
- foreach ($dataModels as $dataModel) {
- $this->log("Datamodel: " . $dataModel->getName(), Project::MSG_VERBOSE);
-
- foreach ($dataModel->getDatabases() as $database) {
-
- if ($this->getGeneratorConfig()->getBuildProperty('disableIdentifierQuoting')) {
- $database->getPlatform()->setIdentifierQuoting(false);
- }
-
- $this->log(" - Database: " . $database->getName(), Project::MSG_VERBOSE);
-
- foreach ($database->getTables() as $table) {
-
- if (!$table->isForReferenceOnly()) {
-
- $nbWrittenFiles = 0;
-
- $this->log(" + Table: " . $table->getName(), Project::MSG_VERBOSE);
-
- // -----------------------------------------------------------------------------------------
- // Create Peer, Object, and TableMap classes
- // -----------------------------------------------------------------------------------------
-
- // these files are always created / overwrite any existing files
- foreach (array('peer', 'object', 'tablemap', 'query') as $target) {
- $builder = $generatorConfig->getConfiguredBuilder($table, $target);
- $nbWrittenFiles += $this->build($builder);
- }
-
- // -----------------------------------------------------------------------------------------
- // Create [empty] stub Peer and Object classes if they don't exist
- // -----------------------------------------------------------------------------------------
-
- // these classes are only generated if they don't already exist
- foreach (array('peerstub', 'objectstub', 'querystub') as $target) {
- $builder = $generatorConfig->getConfiguredBuilder($table, $target);
- $nbWrittenFiles += $this->build($builder, $overwrite=false);
- }
-
- // -----------------------------------------------------------------------------------------
- // Create [empty] stub child Object classes if they don't exist
- // -----------------------------------------------------------------------------------------
-
- // If table has enumerated children (uses inheritance) then create the empty child stub classes if they don't already exist.
- if ($col = $table->getChildrenColumn()) {
- if ($col->isEnumeratedClasses()) {
- foreach ($col->getChildren() as $child) {
- foreach (array('queryinheritance') as $target) {
- if (!$child->getAncestor()) {
- continue;
- }
- $builder = $generatorConfig->getConfiguredBuilder($table, $target);
- $builder->setChild($child);
- $nbWrittenFiles += $this->build($builder, $overwrite=true);
- }
- foreach (array('objectmultiextend', 'queryinheritancestub') as $target) {
- $builder = $generatorConfig->getConfiguredBuilder($table, $target);
- $builder->setChild($child);
- $nbWrittenFiles += $this->build($builder, $overwrite=false);
- }
- } // foreach
- } // if col->is enumerated
- } // if tbl->getChildrenCol
-
-
- // -----------------------------------------------------------------------------------------
- // Create [empty] Interface if it doesn't exist
- // -----------------------------------------------------------------------------------------
-
- // Create [empty] interface if it does not already exist
- if ($table->getInterface()) {
- $builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
- $nbWrittenFiles += $this->build($builder, $overwrite=false);
- }
-
- // ----------------------------------
- // Create classes added by behaviors
- // ----------------------------------
- if ($table->hasAdditionalBuilders()) {
- foreach ($table->getAdditionalBuilders() as $builderClass) {
- $builder = new $builderClass($table);
- $builder->setGeneratorConfig($generatorConfig);
- $nbWrittenFiles += $this->build($builder, isset($builder->overwrite) ? $builder->overwrite : true);
- }
- }
-
- $totalNbFiles += $nbWrittenFiles;
- if ($nbWrittenFiles == 0) {
- $this->log("\t\t(no change)", Project::MSG_VERBOSE);
- }
- } // if !$table->isForReferenceOnly()
-
- } // foreach table
-
- } // foreach database
-
- } // foreach dataModel
- if ($totalNbFiles) {
- $this->log(sprintf("Object model generation complete - %d files written", $totalNbFiles));
- } else {
- $this->log("Object model generation complete - All files already up to date");
- }
- } // main()
-}
View
9 src/Propel/Generator/Task/PropelOMTaskCompat.php
@@ -1,9 +0,0 @@
-<?php
-
-if (!class_exists('\Propel\Generator\Task\AbstractPropelDataModelTask')) {
- require_once __DIR__ . '/../../../../autoload.php.dist';
-}
-
-class PropelOMTaskCompat extends \Propel\Generator\Task\PropelOMTask
-{
-}
View
34 src/Propel/Generator/Task/PropelSqlBuildTask.php
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * This file is part of the Propel package.
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @license MIT License
- */
-
-namespace Propel\Generator\Task;
-
-use Propel\Generator\Util\SqlManager;
-
-/**
- * The new task for building SQL DDL based on the XML datamodel.
- *
- * @author William Durand <william.durand1@gmail.com>
- */
-class PropelSqlBuildTask extends AbstractPropelDataModelTask
-{
- public function main()
- {
- $this->validate();
- $this->packageObjectModel = true;
-
- $manager = new SqlManager();
- $manager->setGeneratorConfig($this->getGeneratorConfig());
- $manager->setDataModels($this->getDataModels());
- $manager->setWorkingDirectory($this->getOutputDirectory());
-
- $manager->buildSql();
- }
-}
View
9 src/Propel/Generator/Task/PropelSqlBuildTaskCompat.php
@@ -1,9 +0,0 @@
-<?php
-
-if (!class_exists('\Propel\Generator\Task\AbstractPropelDataModelTask')) {
- require_once __DIR__ . '/../../../../autoload.php.dist';
-}
-
-class PropelSqlBuildTaskCompat extends \Propel\Generator\Task\PropelSqlBuildTask
-{
-}
View
155 tools/generator/build-propel.xml
@@ -44,9 +44,6 @@
<includepath classpath="${propel.home}/../../src" />
<taskdef
- name="propel-om"
- classname="Propel.Generator.Task.PropelOMTaskCompat" />
- <taskdef
name="propel-data-dump"
classname="Propel.Generator.Task.PropelDataDumpTaskCompat" />
<taskdef
@@ -56,9 +53,6 @@
name="propel-schema-reverse"
classname="Propel.Generator.Task.PropelSchemaReverseTaskCompat" />
<taskdef
- name="propel-sql"
- classname="Propel.Generator.Task.PropelSQLTaskCompat" />
- <taskdef
name="propel-sql-diff"
classname="Propel.Generator.Task.PropelSQLDiffTaskCompat" />
<taskdef
@@ -94,11 +88,8 @@
<target
name="main"
- depends="mysqli-check"
description="==> generates sql + om classes">
- <phingcall target="sql"/>
- <phingcall target="om"/>
<phingcall target="convert-conf"/>
</target>
@@ -123,17 +114,6 @@
<!-- project should be specified in project-schema.xml. -->
<!-- ================================================================ -->
- <target
- name="sql-check"
- depends="check-run-only-on-schema-change"
- if="propel.internal.runOnlyOnSchemaChange">
- <uptodate
- property="propel.internal.sql.uptodate"
- targetfile="${propel.sql.dir}/${propel.schema.default.basename}.sql">
- <srcfiles dir="${propel.schema.dir}" includes="**/${propel.schema.default.basename}.xml" />
- </uptodate>
- </target>
-
<!-- temporary target to check whether postgres is being used with identifier quoting ON.
If so, a warning is issued, since identifier quoting is only paritally implemented & this point. -->
<target name="pgsql-quoting-check">
@@ -158,59 +138,6 @@
</if>
</target>
- <!-- temporary target to check whether mysqli is being used
- If so, a warning is issued, since this is deprecated -->
- <target name="mysqli-check">
- <if>
- <and>
- <equals arg1="${propel.database}" arg2="mysqli"/>
- </and>
- <then>
- <warn>ATTENTION: It appears you are using the mysqli driver.</warn>
- <warn></warn>
- <warn>This driver is no longer supported by Propel because Propel now uses PDO for database connections.</warn>
- <warn>Please use mysqli driver instead.</warn>
- <fail>Use 'mysql' instead of 'mysqli' for your propel.database property.</fail>
- </then>
- </if>
- </target>
-
- <target
- name="sql"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
- unless="propel.internal.sql.uptodate"
- description="==> generates the SQL for your project">
-
- <echo message="+------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating SQL for YOUR Propel project! |"/>
- <echo message="| |"/>
- <echo message="+------------------------------------------+"/>
-
- <phingcall target="sql-template"/>
-
- </target>
-
- <target name="sql-template">
- <propel-sql
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- outputDirectory="${propel.sql.dir}"
- sqldbmap="${propel.sql.dir}/sqldb.map"
- targetDatabase="${propel.database}"
- packageObjectModel="${propel.packageObjectModel}"
- url="${propel.database.url}"
- userId="${propel.database.user}"
- password="${propel.database.password}">
- <mapper type="glob" from="${propel.sql.mapper.from}" to="${propel.sql.mapper.to}"/>
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.sql.includes}"
- excludes="${propel.schema.sql.excludes}"
- />
- </propel-sql>
- </target>
-
<!-- ================================================================ -->
<!-- C R E A T E T A R G E T D A T A B A S E -->
<!-- ================================================================ -->
@@ -227,7 +154,7 @@
<target
name="create-db"
unless="propel.internal.manualCreation"
- depends="create-db-check,mysqli-check"
+ depends="create-db-check"
description="==> generates the target database">
<fail message="create-db target temporarily disabled, while we replace creole components."/>
@@ -299,7 +226,7 @@
<target
name="sql-diff"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
+ depends="pgsql-quoting-check"
unless="propel.internal.sql.uptodate"
description="==> generates a SQL diff for your project">
@@ -337,7 +264,7 @@
<target
name="migration-status"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
+ depends="pgsql-quoting-check"
unless="propel.internal.sql.uptodate"
description="Lists the migrations left to be executed">
@@ -360,7 +287,7 @@
<target
name="migration-up"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
+ depends="pgsql-quoting-check"
unless="propel.internal.sql.uptodate"
description="Execute the next migration">
@@ -383,7 +310,7 @@
<target
name="migration-down"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
+ depends="pgsql-quoting-check"
unless="propel.internal.sql.uptodate"
description="Execute the next migration">
@@ -406,7 +333,7 @@
<target
name="migration"
- depends="sql-check,pgsql-quoting-check,mysqli-check"
+ depends="pgsql-quoting-check"
unless="propel.internal.sql.uptodate"
description="Execute the next migration">
@@ -493,58 +420,6 @@
</propel-data-dump>
</target>
- <!-- ================================================================ -->
- <!-- G E N E R A T E P R O J E C T P E E R B A S E D O M -->
- <!-- ================================================================ -->
- <!-- Generate the Peer-based object model for your project. -->
- <!-- These are in addition to the base Propel OM! -->
- <!-- ================================================================ -->
-
- <target
- name="om-check"
- depends="check-run-only-on-schema-change"
- if="propel.internal.runOnlyOnSchemaChange">
- <uptodate
- property="propel.internal.om.uptodate"
- targetfile="${propel.php.dir}/report.${propel.project}.om.generation">
- <srcfiles dir="${propel.schema.dir}" includes="**/${propel.schema.om.includes}.xml" />
- </uptodate>
- </target>
-
- <target
- name="om"
- depends="om-check,mysqli-check"
- unless="propel.internal.om.uptodate"
- description="==> generates the Peer-based object model for your project">
-
- <echo message="+------------------------------------------+"/>
- <echo message="| |"/>
- <echo message="| Generating Peer-based Object Model for |"/>
- <echo message="| YOUR Propel project! |"/>
- <echo message="| |"/>
- <echo message="+------------------------------------------+"/>
-
- <phingcall target="om-template"/>
- <!--<phingcall target="om-tar"/>-->
- </target>
-
- <target name="om-template">
- <propel-om
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- outputDirectory="${propel.php.dir}"
- targetDatabase="${propel.database}"
- targetPackage="${propel.targetPackage}"
- targetPlatform="${propel.targetPlatform}"
- packageObjectModel="${propel.packageObjectModel}">
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.om.includes}"
- excludes="${propel.schema.om.excludes}"
- />
- </propel-om>
- </target>
-
<!-- ================================================================== -->
<!-- X M L R U N T I M E C O N F T O P H P A R R A Y -->
<!-- ================================================================== -->
@@ -598,7 +473,6 @@
<target
name="graphviz"
- depends="sql-check"
description="==> generates Graphviz file for your project">
<echo message="+------------------------------------------+"/>
@@ -621,21 +495,4 @@
</propel-graphviz>
</target>
- <taskdef
- name="propel-build-sql"
- classname="Propel.Generator.Task.PropelSqlBuildTaskCompat" />
-
- <target name="build-sql">
- <propel-build-sql outputDirectory="${propel.sql.dir}"
- validate="${propel.schema.validate}"
- xsd="${propel.schema.xsd.file}"
- xsl="${propel.schema.xsl.file}"
- >
- <schemafileset dir="${propel.schema.dir}"
- includes="${propel.schema.sql.includes}"
- excludes="${propel.schema.sql.excludes}"
- />
- </propel-build-sql>
- </target>
-
</project>
View
18 tools/generator/build.xml
@@ -79,9 +79,7 @@
<echo message="$&gt; propel-gen /path/to/projectdir [taskname]"/>
<echo message=" "/>
<echo message="Available tasknames are:"/>
- <echo message=" om"/>
<echo message=" convert-conf"/>
- <echo message=" sql"/>
<echo message=" insert-sql"/>
<echo message=" diff"/>
<echo message=" status"/>
@@ -176,18 +174,6 @@
<phing phingfile="build-propel.xml" target="insert-sql"/>
</target>
-<target name="om" depends="configure">
- <phing phingfile="build-propel.xml" target="om"/>
-</target>
-
-<target name="new-om" depends="configure">
- <phing phingfile="build-propel.xml" target="new-om"/>
-</target>
-
-<target name="sql" depends="configure">
- <phing phingfile="build-propel.xml" target="sql"/>
-</target>
-
<target name="sql-diff" depends="configure">
<phing phingfile="build-propel.xml" target="sql-diff"/>
</target>
@@ -222,10 +208,6 @@
<target name="migrate" depends="migration" />
-<target name="old-sql" depends="configure">
- <phing phingfile="build-propel.xml" target="old-sql"/>
-</target>
-
<target name="dbd2propel" depends="configure">
<phing phingfile="build-propel.xml" target="dbd2propel"/>
</target>
Please sign in to comment.
Something went wrong with that request. Please try again.