propelorm/Propel — Issue #183: Absolute path in BasePeer::CLASS_DEFAULT
Author: gabrielpillet
Created: 2011-11-08 11:22:50+00:00
State: open

We are using namespaced Propel classes.

In PHP5PeerBuilder::addConstantsAndAttribute is the following code :

/** A class that can be returned by this peer. */
const CLASS_DEFAULT = '".$this->getStubObjectBuilder()->getClasspath()."';

the resulting generated code is something like :

/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'home/gpillet/workspace/src/Pmsipilot/MyBundle/Model.MyClass';

It's a problem because each time we rebuild the model, we have diff in our version control system (ignoring these files is out of question).

Overrigind the builder with a relative path for our specific needs like

/** A class that can be returned by this peer. */
const CLASS_DEFAULT = '".'../../../../myPath'."';

Does not work because Propel::importClass replaces each . by a /

// turn to filesystem path
$path = strtr($path, '.', DIRECTORY_SEPARATOR) . '.php';

The easiest way to solve this problem would be to modify Propel::importClass to first detect if file_exists before replacings dots by slashes. But I wanted your opinion before submitting a PR.