ArchivableBehavior and namespaces issue #238

Closed
auss opened this Issue Dec 20, 2011 · 4 comments

Comments

Projects
None yet
3 participants
@auss
Contributor

auss commented Dec 20, 2011

Hi,

I've found problem with Archivable and symfony 2. After generation, all classes are created correctly, and are working ok untill I try to archive object. Then propel generates fatal error:

 Fatal error: Class 'Vend\CBundle\Model\Product\om\CurrencyExchangeArchiveQuery' not found in /media/projects/certyfikaty2/src/Vend/CBundle/Model/Product/om/BaseCurrencyExchange.php on line 1188

It seems, that behavior forgets to add use statements... Or I'm doing something wrong.

Schema:

<?xml version="1.0" encoding="UTF-8"?>
< database name="default" namespace="Vend\CBundle\Model\Product" defaultIdMethod="native" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xsd.propelorm.org/1.6/database.xsd">

    < table name="currency_exchange">
        < column name="id"                   type="INTEGER"   required="true"  primaryKey="true" autoIncrement="true" />  
        < column name="exchange"             type="NUMERIC"   required="false" size="12" scale="2" />
        < column name="currency"             type="VARCHAR"   required="true"  size="10" />
        < column name="type"                 type="INTEGER"   required="false" default="0" />
        < behavior name="timestampable" />
        < behavior name="archivable" />
    < /table>
< /database>

Generated BaseCurrencyExchange.php:

namespace Vend\CBundle\Model\Product\om;

use \BaseObject;
use \BasePeer;
use \Criteria;
use \DateTime;
use \DateTimeZone;
use \Exception;
use \PDO;
use \Persistent;
use \Propel;
use \PropelCollection;
use \PropelDateTime;
use \PropelException;
use \PropelObjectCollection;
use \PropelPDO;
use Vend\CBundle\Model\Product\CurrencyExchangePeer;
use Vend\CBundle\Model\Product\CurrencyExchangeQuery;

MISSING use Vend\CBundle\Model\Product\CurrencyExchangeArchiveQuery;
                use Vend\CBundle\Model\Product\CurrencyExchangeArchive;

abstract class BaseCurrencyExchange extends BaseObject  implements Persistent
{ ...
   // archivable behavior

/**
 * Get an archived version of the current object.
 *
 * @param PropelPDO $con Optional connection object
 *
 * @return     CurrencyExchangeArchive An archive object, or null if the current object was never archived
 */
public function getArchive(PropelPDO $con = null)
{
    if ($this->isNew()) {
        return null;
    }
    $archive = CurrencyExchangeArchiveQuery::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 PropelPDO $con Optional connection object
 *
 * @throws PropelException If the object is new
 *
 * @return     CurrencyExchangeArchive The archive object based on this object
 */
public function archive(PropelPDO $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($con)) {
        $archive = new CurrencyExchangeArchive();
        $archive->setPrimaryKey($this->getPrimaryKey());
    }
    $this->copyInto($archive, $deepCopy = false, $makeNew = false);
    $archive->save($con);

    return $archive;
}
@fzaninotto

This comment has been minimized.

Show comment Hide comment
@fzaninotto

fzaninotto Feb 14, 2012

Member

Fixed in f2d1cce

Member

fzaninotto commented Feb 14, 2012

Fixed in f2d1cce

@bmeynell

This comment has been minimized.

Show comment Hide comment
@bmeynell

bmeynell Jul 31, 2013

@auss - Does this now work for you? I'm trying now and even after f2d1cce it still doesn't work over here.

@auss - Does this now work for you? I'm trying now and even after f2d1cce it still doesn't work over here.

@bmeynell

This comment has been minimized.

Show comment Hide comment
@bmeynell

bmeynell Aug 1, 2013

This is fixed in PR #735

Problem was that the previous fix only declared the Query class but needed to include both the Query and Object classes.

bmeynell commented Aug 1, 2013

This is fixed in PR #735

Problem was that the previous fix only declared the Query class but needed to include both the Query and Object classes.

@bmeynell

This comment has been minimized.

Show comment Hide comment
@bmeynell

bmeynell Aug 1, 2013

Just completely updated to Propel 1.6 and this issue appears to be resolved. Something between f2d1cce and 7b85973 must have fixed this. Closing aforementioned PR.

bmeynell commented Aug 1, 2013

Just completely updated to Propel 1.6 and this issue appears to be resolved. Something between f2d1cce and 7b85973 must have fixed this. Closing aforementioned PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment