Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved some behavior code

  • Loading branch information...
commit 9777ca2a891752fce2f7a90297768de89bd38353 1 parent e4767fb
@mpscholten authored
Showing with 244 additions and 460 deletions.
  1. +8 −26 src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php
  2. +0 −23 src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php
  3. +31 −0 src/Propel/Generator/Behavior/AggregateColumn/templates/Object/_methods.php.twig
  4. +0 −18 src/Propel/Generator/Behavior/AggregateColumn/templates/objectCompute.php
  5. +0 −11 src/Propel/Generator/Behavior/AggregateColumn/templates/objectUpdate.php
  6. +0 −16 src/Propel/Generator/Behavior/AggregateColumn/templates/objectUpdateRelated.php
  7. +1 −0  src/Propel/Generator/Behavior/AggregateColumn/templates_relation/Object/_hooks/_postSave.php.twig
  8. +16 −0 src/Propel/Generator/Behavior/AggregateColumn/templates_relation/Object/_methods.php.twig
  9. +0 −9 src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php
  10. +0 −198 src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php
  11. +7 −0 src/Propel/Generator/Behavior/Archivable/templates/Object/_hooks/_postInsert.php.twig
  12. +7 −0 src/Propel/Generator/Behavior/Archivable/templates/Object/_hooks/_postUpdate.php.twig
  13. +19 −0 src/Propel/Generator/Behavior/Archivable/templates/Object/_hooks/_preDelete.php.twig
  14. +154 −0 src/Propel/Generator/Behavior/Archivable/templates/Object/_methods.php.twig
  15. +0 −29 src/Propel/Generator/Behavior/Archivable/templates/objectArchive.php
  16. +0 −14 src/Propel/Generator/Behavior/Archivable/templates/objectDeleteWithoutArchive.php
  17. +0 −19 src/Propel/Generator/Behavior/Archivable/templates/objectGetArchive.php
  18. +0 −31 src/Propel/Generator/Behavior/Archivable/templates/objectPopulateFromArchive.php
  19. +0 −17 src/Propel/Generator/Behavior/Archivable/templates/objectPreDelete.php
  20. +0 −20 src/Propel/Generator/Behavior/Archivable/templates/objectRestoreFromArchive.php
  21. +0 −28 src/Propel/Generator/Behavior/Archivable/templates/objectSaveWithoutArchive.php
  22. +1 −1  src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php
View
34 src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnBehavior.php
@@ -33,6 +33,11 @@ class AggregateColumnBehavior extends Behavior
*/
public function modifyTable()
{
+ // TODO: behavior should get a validate() method like the builder::validate()
+ if (!$this->getParameter('foreign_table')) {
+ throw new \InvalidArgumentException(sprintf('You must define a \'foreign_table\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $this->getTable()->getName()));
+ }
+
$table = $this->getTable();
if (!$columnName = $this->getParameter('name')) {
throw new \InvalidArgumentException(sprintf('You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $table->getName()));
@@ -57,19 +62,7 @@ public function modifyTable()
}
}
- public function objectMethods($builder)
- {
- if (!$this->getParameter('foreign_table')) {
- throw new \InvalidArgumentException(sprintf('You must define a \'foreign_table\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $this->getTable()->getName()));
- }
- $script = '';
- $script .= $this->addObjectCompute();
- $script .= $this->addObjectUpdate();
-
- return $script;
- }
-
- protected function addObjectCompute()
+ public function buildQuery()
{
$conditions = array();
if ($this->getParameter('condition')) {
@@ -94,18 +87,7 @@ protected function addObjectCompute()
implode(' AND ', $conditions)
);
- return $this->renderTemplate('objectCompute', array(
- 'column' => $this->getColumn(),
- 'sql' => $sql,
- 'bindings' => $bindings,
- ));
- }
-
- protected function addObjectUpdate()
- {
- return $this->renderTemplate('objectUpdate', array(
- 'column' => $this->getColumn(),
- ));
+ return ['sql' => $sql, 'bindings' => $bindings];
}
protected function getForeignTable()
@@ -131,7 +113,7 @@ protected function getForeignKey()
return array_shift($fks);
}
- protected function getColumn()
+ public function getColumn()
{
return $this->getTable()->getColumn($this->getParameter('name'));
}
View
23 src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php
@@ -25,29 +25,6 @@ class AggregateColumnRelationBehavior extends Behavior
'update_method' => '',
);
- public function postSave($builder)
- {
- $relationName = $this->getRelationName($builder);
-
- return "\$this->updateRelated{$relationName}(\$con);";
- }
-
- public function objectMethods($builder)
- {
- return $this->addObjectUpdateRelated($builder);
- }
-
- protected function addObjectUpdateRelated($builder)
- {
- $relationName = $this->getRelationName($builder);
-
- return $this->renderTemplate('objectUpdateRelated', array(
- 'relationName' => $relationName,
- 'variableName' => lcfirst($relationName),
- 'updateMethodName' => $this->getParameter('update_method'),
- ));
- }
-
public function objectFilter(&$script, $builder)
{
$relationName = $this->getRelationName($builder);
View
31 src/Propel/Generator/Behavior/AggregateColumn/templates/Object/_methods.php.twig
@@ -0,0 +1,31 @@
+{% set query = behavior.buildQuery %}
+{% set column = behavior.column %}
+/**
+ * Computes the value of the aggregate column {{ column.name }}
+ *
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return mixed The scalar result from the aggregate query
+ */
+public function compute{{ column.phpName }}(ConnectionInterface $con)
+{
+ $stmt = $con->prepare('{{ query.sql }}');
+ {% for key, binding in query.bindings %}
+ $stmt->bindValue(':p{{ key }}', $this->get{{ binding }}());
+ {% endfor %}
+ $stmt->execute();
+
+ return $stmt->fetchColumn();
+}
+
+
+/**
+ * Updates the aggregate column {{ column.name }}
+ *
+ * @param ConnectionInterface $con A connection object
+ */
+public function update{{ column.phpName }}(ConnectionInterface $con)
+{
+ $this->set{{ column.phpName }}($this->compute{{ column.phpName }}($con));
+ $this->save($con);
+}
View
18 src/Propel/Generator/Behavior/AggregateColumn/templates/objectCompute.php
@@ -1,18 +0,0 @@
-
-/**
- * Computes the value of the aggregate column <?=$column->getName()?>
- *
- * @param ConnectionInterface $con A connection object
- *
- * @return mixed The scalar result from the aggregate query
- */
-public function compute<?=$column->getPhpName()?>(ConnectionInterface $con)
-{
- $stmt = $con->prepare('<?=$sql?>');
-<?php foreach ($bindings as $key => $binding):?>
- $stmt->bindValue(':p<?=$key?>', $this->get<?=$binding?>());
-<?php endforeach;?>
- $stmt->execute();
-
- return $stmt->fetchColumn();
-}
View
11 src/Propel/Generator/Behavior/AggregateColumn/templates/objectUpdate.php
@@ -1,11 +0,0 @@
-
-/**
- * Updates the aggregate column <?=$column->getName()?>
- *
- * @param ConnectionInterface $con A connection object
- */
-public function update<?=$column->getPhpName()?>(ConnectionInterface $con)
-{
- $this->set<?=$column->getPhpName()?>($this->compute<?=$column->getPhpName()?>($con));
- $this->save($con);
-}
View
16 src/Propel/Generator/Behavior/AggregateColumn/templates/objectUpdateRelated.php
@@ -1,16 +0,0 @@
-
-/**
- * Update the aggregate column in the related <?=$relationName?> object
- *
- * @param ConnectionInterface $con A connection object
- */
-protected function updateRelated<?=$relationName?>(ConnectionInterface $con)
-{
- if ($<?=$variableName?> = $this->get<?=$relationName?>()) {
- $<?=$variableName?>-><?=$updateMethodName?>($con);
- }
- if ($this->old<?=$relationName?>) {
- $this->old<?=$relationName?>-><?=$updateMethodName?>($con);
- $this->old<?=$relationName?> = null;
- }
-}
View
1  src/Propel/Generator/Behavior/AggregateColumn/templates_relation/Object/_hooks/_postSave.php.twig
@@ -0,0 +1 @@
+$this->updateRelated{{ behavior.relationName(builder) }}($con);
View
16 src/Propel/Generator/Behavior/AggregateColumn/templates_relation/Object/_methods.php.twig
@@ -0,0 +1,16 @@
+{% set relationName = behavior.relationName(builder) %}
+/**
+ * Update the aggregate column in the related {{ relationName }} object
+ *
+ * @param ConnectionInterface $con A connection object
+ */
+protected function updateRelated{{ relationName }}(ConnectionInterface $con)
+{
+ if (${{ relationName|lcfirst }} = $this->get{{ relationName }}()) {
+ ${{ relationName|lcfirst }}->{{ behavior.parameter('update_method') }}($con);
+ }
+ if ($this->old{{ relationName }}) {
+ $this->old{{ relationName }}->{{ behavior.parameter('update_method') }}($con);
+ $this->old{{ relationName }} = null;
+ }
+}
View
9 src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php
@@ -182,15 +182,6 @@ public function isArchiveOnDelete()
return 'true' === $this->getParameter('archive_on_delete');
}
- public function getObjectBuilderModifier()
- {
- if (null === $this->objectBuilderModifier) {
- $this->objectBuilderModifier = new ArchivableBehaviorObjectBuilderModifier($this);
- }
-
- return $this->objectBuilderModifier;
- }
-
public function getQueryBuilderModifier()
{
if (null === $this->queryBuilderModifier) {
View
198 src/Propel/Generator/Behavior/Archivable/ArchivableBehaviorObjectBuilderModifier.php
@@ -1,198 +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\Behavior\Archivable;
-
-/**
- * Keeps tracks of an ActiveRecord object, even after deletion
- *
- * @author François Zaninotto
- */
-class ArchivableBehaviorObjectBuilderModifier
-{
- protected $behavior;
- protected $table;
- protected $builder;
-
- public function __construct($behavior)
- {
- $this->behavior = $behavior;
- $this->table = $behavior->getTable();
- }
-
- protected function getParameter($key)
- {
- return $this->behavior->getParameter($key);
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function objectAttributes($builder)
- {
- $script = '';
- if ($this->behavior->isArchiveOnInsert()) {
- $script .= "protected \$archiveOnInsert = true;
-";
- }
- if ($this->behavior->isArchiveOnUpdate()) {
- $script .= "protected \$archiveOnUpdate = true;
-";
- }
- if ($this->behavior->isArchiveOnDelete()) {
- $script .= "protected \$archiveOnDelete = true;
-";
- }
-
- return $script;
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function postInsert($builder)
- {
- if ($this->behavior->isArchiveOnInsert()) {
- return "if (\$this->archiveOnInsert) {
- \$this->archive(\$con);
-} else {
- \$this->archiveOnInsert = true;
-}";
- }
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function postUpdate($builder)
- {
- if ($this->behavior->isArchiveOnUpdate()) {
- return "if (\$this->archiveOnUpdate) {
- \$this->archive(\$con);
-} else {
- \$this->archiveOnUpdate = true;
-}";
- }
- }
-
- /**
- * Using preDelete rather than postDelete to allow user to retrieve
- * related records and archive them before cascade deletion.
- *
- * The actual deletion is made by the query object, so the AR class must tell
- * the query class to enable or disable archiveOnDelete.
- *
- * @return string the PHP code to be added to the builder
- */
- public function preDelete($builder)
- {
- if ($this->behavior->isArchiveOnDelete()) {
- return $this->behavior->renderTemplate('objectPreDelete', array(
- 'queryClassName' => $builder->getQueryClassName(),
- 'isAddHooks' => $builder->getGeneratorConfig()->getBuildProperty('addHooks'),
- ));
- }
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function objectMethods($builder)
- {
- $this->builder = $builder;
- $script = '';
- $script .= $this->addGetArchive($builder);
- $script .= $this->addArchive($builder);
- $script .= $this->addRestoreFromArchive($builder);
- $script .= $this->addPopulateFromArchive($builder);
- if ($this->behavior->isArchiveOnInsert() || $this->behavior->isArchiveOnUpdate()) {
- $script .= $this->addSaveWithoutArchive($builder);
- }
- if ($this->behavior->isArchiveOnDelete()) {
- $script .= $this->addDeleteWithoutArchive($builder);
- }
-
- return $script;
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function addGetArchive($builder)
- {
- return $this->behavior->renderTemplate('objectGetArchive', array(
- 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder),
- 'archiveTableQueryName' => $this->behavior->getArchiveTableQueryName($builder),
- ));
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function addArchive($builder)
- {
- return $this->behavior->renderTemplate('objectArchive', array(
- 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder),
- 'archiveTableQueryName' => $this->behavior->getArchiveTableQueryName($builder),
- 'archivedAtColumn' => $this->behavior->getArchivedAtColumn(),
- 'hasArchiveClass' => $this->behavior->hasArchiveClass()
- ));
- }
-
- /**
- *
- * @return string the PHP code to be added to the builder
- */
- public function addRestoreFromArchive($builder)
- {
- return $this->behavior->renderTemplate('objectRestoreFromArchive', array(
- 'objectClassName' => $this->builder->getObjectClassName(),
- ));
- }
-
- /**
- * Generates a method to populate the current AR object based on an archive object.
- * This method is necessary because the archive's copyInto() may include the archived_at column
- * and therefore cannot be used. Besides, the way autoincremented PKs are handled should be explicit.
- *
- * @return string the PHP code to be added to the builder
- */
- public function addPopulateFromArchive($builder)
- {
- return $this->behavior->renderTemplate('objectPopulateFromArchive', array(
- 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder),
- 'usesAutoIncrement' => $this->table->hasAutoIncrementPrimaryKey(),
- 'objectClassName' => $this->builder->getObjectClassName(),
- 'columns' => $this->table->getColumns(),
- ));
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function addSaveWithoutArchive($builder)
- {
- return $this->behavior->renderTemplate('objectSaveWithoutArchive', array(
- 'objectClassName' => $this->builder->getObjectClassName(),
- 'isArchiveOnInsert' => $this->behavior->isArchiveOnInsert(),
- 'isArchiveOnUpdate' => $this->behavior->isArchiveOnUpdate(),
- ));
- }
-
- /**
- * @return string the PHP code to be added to the builder
- */
- public function addDeleteWithoutArchive($builder)
- {
- return $this->behavior->renderTemplate('objectDeleteWithoutArchive', array(
- 'objectClassName' => $this->builder->getObjectClassName(),
- ));
- }
-}
View
7 src/Propel/Generator/Behavior/Archivable/templates/Object/_hooks/_postInsert.php.twig
@@ -0,0 +1,7 @@
+{% if behavior.archiveOnInsert %}
+ if ($this->archiveOnInsert) {
+ $this->archive($con);
+ } else {
+ $this->archiveOnInsert = true;
+ }
+{% endif %}
View
7 src/Propel/Generator/Behavior/Archivable/templates/Object/_hooks/_postUpdate.php.twig
@@ -0,0 +1,7 @@
+{% if behavior.archiveOnUpdate %}
+ if ($this->archiveOnUpdate) {
+ $this->archive($con);
+ } else {
+ $this->archiveOnUpdate = true;
+ }
+{% endif %}
View
19 src/Propel/Generator/Behavior/Archivable/templates/Object/_hooks/_preDelete.php.twig
@@ -0,0 +1,19 @@
+{% if behavior.archiveOnDelete %}
+ {% if builder.generatorConfig.buildProperty('addHooks') %}
+ if ($ret) {
+ if ($this->archiveOnDelete) {
+ // do nothing yet. The object will be archived later when calling {{ builder.queryClassName }}::delete().
+ } else {
+ $deleteQuery->setArchiveOnDelete(false);
+ $this->archiveOnDelete = true;
+ }
+ }
+ {% else %}
+ if ($this->archiveOnDelete) {
+ // do nothing yet. The object will be archived later when calling {{ builder.queryClassName }}::delete().
+ } else {
+ $deleteQuery->setArchiveOnDelete(false);
+ $this->archiveOnDelete = true;
+ }
+ {% endif %}
+{% endif %}
View
154 src/Propel/Generator/Behavior/Archivable/templates/Object/_methods.php.twig
@@ -0,0 +1,154 @@
+{% set archiveTablePhpName = behavior.archiveTablePhpName(builder) %}
+{% set archiveTableQueryName = behavior.archiveTableQueryName(builder) %}
+/**
+ * Get an archived version of the current object.
+ *
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return {{ archiveTablePhpName }} An archive object, or null if the current object was never archived
+ */
+public function getArchive(ConnectionInterface $con = null)
+{
+ if ($this->isNew()) {
+ return null;
+ }
+ $archive = {{ archiveTableQueryName }}::create()
+ ->filterByPrimaryKey($this->getPrimaryKey())
+ ->findOne($con);
+
+ return $archive;
+}
+
+
+/**
+ * Copy the data of the current object into a $archiveTablePhpName archive object.
+ * The archived object is then saved.
+ * If the current object has already been archived, the archived object
+ * is updated and not duplicated.
+ *
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @throws PropelException If the object is new
+ *
+ * @return {{ archiveTablePhpName }} The archive object based on this object
+ */
+public function archive(ConnectionInterface $con = null)
+{
+ if ($this->isNew()) {
+ throw new PropelException('New objects cannot be archived. You must save the current object before calling archive().');
+ }
+ if (!$archive = $this->getArchive({% if behavior.hasArchiveClass %}$con{% endif %})) {
+ $archive = new {{ archiveTablePhpName }}();
+ $archive->setPrimaryKey($this->getPrimaryKey());
+ }
+ $this->copyInto($archive, $deepCopy = false, $makeNew = false);
+ {% if behavior.archivedAtColumn %}
+ $archive->set{{ behavior.archivedAtColumn.phpName }}(time());
+ {% endif %}
+ $archive->save({% if behavior.hasArchiveClass %}$con{% endif %});
+
+ return $archive;
+}
+
+
+
+/**
+ * Revert the the current object to the state it had when it was last archived.
+ * The object must be saved afterwards if the changes must persist.
+ *
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @throws PropelException If the object has no corresponding archive.
+ *
+ * @return {{ builder.objectClassName }} The current object (for fluent API support)
+ */
+public function restoreFromArchive(ConnectionInterface $con = null)
+{
+ if (!$archive = $this->getArchive($con)) {
+ throw new PropelException('The current object has never been archived and cannot be restored');
+ }
+ $this->populateFromArchive($archive);
+
+ return $this;
+}
+
+
+
+/**
+ * Populates the the current object based on a $archiveTablePhpName archive object.
+ *
+ * @param {{ archiveTablePhpName }} $archive An archived object based on the same class
+{% if behavior.table.hasAutoIncrementPrimaryKey %}
+ * @param Boolean $populateAutoIncrementPrimaryKeys
+ * If true, autoincrement columns are copied from the archive object.
+ * If false, autoincrement columns are left intact.
+{% endif %}
+ *
+ * @return {{ builder.objectClassName }} The current object (for fluent API support)
+ */
+public function populateFromArchive($archive{% if behavior.table.hasAutoIncrementPrimaryKey %}, $populateAutoIncrementPrimaryKeys = false{% endif %})
+{
+ {% if behavior.table.hasAutoIncrementPrimaryKey %}
+ if ($populateAutoIncrementPrimaryKeys) {
+ {% for column in behavior.table.columns %}
+ {% if column.autoIncrement %}
+ $this->set{{ column.phpName }}($archive->get{{ column.phpName }}());
+ {% endif %}
+ {% endfor %}
+ }
+ {% endif %}
+
+ {% for column in behavior.table.columns %}
+ {% if not column.autoIncrement %}
+ $this->set{{ column.phpName }}($archive->get{{ column.phpName }}());
+ {% endif %}
+ {% endfor %}
+
+ return $this;
+}
+
+{% if behavior.archiveOnInsert or behavior.archiveOnUpdate %}
+ /**
+ * Persists the object to the database without archiving it.
+ *
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return {{ builder.objectClassName }} The current object (for fluent API support)
+ */
+ public function saveWithoutArchive(ConnectionInterface $con = null)
+ {
+ {% if not behavior.archiveOnInsert %}
+ if (!$this->isNew()) {
+ $this->archiveOnUpdate = false;
+ }
+ {% elseif not behavior.archiveOnUpdate %}
+ if ($this->isNew()) {
+ $this->archiveOnInsert = false;
+ }
+ {% else %}
+ if ($this->isNew()) {
+ $this->archiveOnInsert = false;
+ } else {
+ $this->archiveOnUpdate = false;
+ }
+ {% endif %}
+
+ return $this->save($con);
+ }
+{% endif %}
+
+{% if behavior.archiveOnDelete %}
+ /**
+ * Removes the object from the database without archiving it.
+ *
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return {{ builder.objectClassName }} The current object (for fluent API support)
+ */
+ public function deleteWithoutArchive(ConnectionInterface $con = null)
+ {
+ $this->archiveOnDelete = false;
+
+ return $this->delete($con);
+ }
+{% endif %}
View
29 src/Propel/Generator/Behavior/Archivable/templates/objectArchive.php
@@ -1,29 +0,0 @@
-/**
- * Copy the data of the current object into a $archiveTablePhpName archive object.
- * The archived object is then saved.
- * If the current object has already been archived, the archived object
- * is updated and not duplicated.
- *
- * @param ConnectionInterface $con Optional connection object
- *
- * @throws PropelException If the object is new
- *
- * @return <?php echo $archiveTablePhpName ?> The archive object based on this object
- */
-public function archive(ConnectionInterface $con = null)
-{
- if ($this->isNew()) {
- throw new PropelException('New objects cannot be archived. You must save the current object before calling archive().');
- }
- if (!$archive = $this->getArchive(<?php if (!$hasArchiveClass): ?>$con<?php endif; ?>)) {
- $archive = new <?php echo $archiveTablePhpName ?>();
- $archive->setPrimaryKey($this->getPrimaryKey());
- }
- $this->copyInto($archive, $deepCopy = false, $makeNew = false);
-<?php if ($archivedAtColumn): ?>
- $archive->set<?php echo $archivedAtColumn->getPhpName() ?>(time());
-<?php endif; ?>
- $archive->save(<?php if (!$hasArchiveClass): ?>$con<?php endif; ?>);
-
- return $archive;
-}
View
14 src/Propel/Generator/Behavior/Archivable/templates/objectDeleteWithoutArchive.php
@@ -1,14 +0,0 @@
-
-/**
- * Removes the object from the database without archiving it.
- *
- * @param ConnectionInterface $con Optional connection object
- *
- * @return <?php echo $objectClassName ?> The current object (for fluent API support)
- */
-public function deleteWithoutArchive(ConnectionInterface $con = null)
-{
- $this->archiveOnDelete = false;
-
- return $this->delete($con);
-}
View
19 src/Propel/Generator/Behavior/Archivable/templates/objectGetArchive.php
@@ -1,19 +0,0 @@
-
-/**
- * Get an archived version of the current object.
- *
- * @param ConnectionInterface $con Optional connection object
- *
- * @return <?php echo $archiveTablePhpName ?> An archive object, or null if the current object was never archived
- */
-public function getArchive(ConnectionInterface $con = null)
-{
- if ($this->isNew()) {
- return null;
- }
- $archive = <?php echo $archiveTableQueryName ?>::create()
- ->filterByPrimaryKey($this->getPrimaryKey())
- ->findOne($con);
-
- return $archive;
-}
View
31 src/Propel/Generator/Behavior/Archivable/templates/objectPopulateFromArchive.php
@@ -1,31 +0,0 @@
-
-/**
- * Populates the the current object based on a $archiveTablePhpName archive object.
- *
- * @param <?php echo $archiveTablePhpName ?> $archive An archived object based on the same class
- <?php if ($usesAutoIncrement): ?>
- * @param Boolean $populateAutoIncrementPrimaryKeys
- * If true, autoincrement columns are copied from the archive object.
- * If false, autoincrement columns are left intact.
- <?php endif; ?>
- *
- * @return <?php echo $objectClassName ?> The current object (for fluent API support)
- */
-public function populateFromArchive($archive<?php if ($usesAutoIncrement): ?>, $populateAutoIncrementPrimaryKeys = false<?php endif; ?>) {
-<?php if ($usesAutoIncrement): ?>
- if ($populateAutoIncrementPrimaryKeys) {
-<?php foreach ($columns as $col): ?>
-<?php if ($col->isAutoIncrement()): ?>
- $this->set<?php echo $col->getPhpName() ?>($archive->get<?php echo $col->getPhpName() ?>());
-<?php endif; ?>
-<?php endforeach; ?>
- }
-<?php endif; ?>
-<?php foreach ($columns as $col): ?>
-<?php if (!$col->isAutoIncrement()): ?>
- $this->set<?php echo $col->getPhpName() ?>($archive->get<?php echo $col->getPhpName() ?>());
-<?php endif; ?>
-<?php endforeach; ?>
-
- return $this;
-}
View
17 src/Propel/Generator/Behavior/Archivable/templates/objectPreDelete.php
@@ -1,17 +0,0 @@
-<?php if ($isAddHooks) : ?>
-if ($ret) {
- if ($this->archiveOnDelete) {
- // do nothing yet. The object will be archived later when calling <?php echo $queryClassName ?>::delete().
- } else {
- $deleteQuery->setArchiveOnDelete(false);
- $this->archiveOnDelete = true;
- }
-}
-<?php else: ?>
-if ($this->archiveOnDelete) {
- // do nothing yet. The object will be archived later when calling <?php echo $queryClassName ?>::delete().
-} else {
- $deleteQuery->setArchiveOnDelete(false);
- $this->archiveOnDelete = true;
-}
-<?php endif;
View
20 src/Propel/Generator/Behavior/Archivable/templates/objectRestoreFromArchive.php
@@ -1,20 +0,0 @@
-
-/**
- * Revert the the current object to the state it had when it was last archived.
- * The object must be saved afterwards if the changes must persist.
- *
- * @param ConnectionInterface $con Optional connection object
- *
- * @throws PropelException If the object has no corresponding archive.
- *
- * @return <?php echo $objectClassName ?> The current object (for fluent API support)
- */
-public function restoreFromArchive(ConnectionInterface $con = null)
-{
- if (!$archive = $this->getArchive($con)) {
- throw new PropelException('The current object has never been archived and cannot be restored');
- }
- $this->populateFromArchive($archive);
-
- return $this;
-}
View
28 src/Propel/Generator/Behavior/Archivable/templates/objectSaveWithoutArchive.php
@@ -1,28 +0,0 @@
-
-/**
- * Persists the object to the database without archiving it.
- *
- * @param ConnectionInterface $con Optional connection object
- *
- * @return <?php echo $objectClassName ?> The current object (for fluent API support)
- */
-public function saveWithoutArchive(ConnectionInterface $con = null)
-{
-<?php if (!$isArchiveOnInsert): ?>
- if (!$this->isNew()) {
- $this->archiveOnUpdate = false;
- }
-<?php elseif (!$isArchiveOnUpdate): ?>
- if ($this->isNew()) {
- $this->archiveOnInsert = false;
- }
-<?php else: ?>
- if ($this->isNew()) {
- $this->archiveOnInsert = false;
- } else {
- $this->archiveOnUpdate = false;
- }
-<?php endif; ?>
-
- return $this->save($con);
-}
View
2  src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php
@@ -58,7 +58,7 @@ public function objectMethods($builder)
public function objectFilter(&$script, $builder)
{
$i18nTable = $this->behavior->getI18nTable();
- $i18nTablePhpName = $this->builder->getNewStubObjectBuilder($i18nTable)->getUnprefixedClassName();
+ $i18nTablePhpName = $builder->getNewStubObjectBuilder($i18nTable)->getUnprefixedClassName();
$localeColumnName = $this->behavior->getLocaleColumn()->getPhpName();
$pattern = '/public function add' . $i18nTablePhpName . '.*[\r\n]\s*\{/';
$addition = "
Please sign in to comment.
Something went wrong with that request. Please try again.