I want to do this:
// Model class
namespace Bookshop\Inventory\Model;
use Core\Inventory\Model\Product as BaseProduct;
class Book extends BaseProduct {
// ...
}
// Query class
namespace Bookshop\Inventory\Model;
use Core\Inventory\Model\ProductQuery as BaseProductQuery;
class BookQuery extends BaseProductQuery {
// ...
}
Looks fine, right? But:
$book = BookQuery::create()->find($id);
var_dump(get_class($book));
// expected: Bookshop\Inventory\Model\Book
// actual: Core\Inventory\Model\Product
AFAIK this is due to the fact that Propel's relationships are defined at build-time, not runtime... The only way I have found of achieving this is by using the extend behaviour found in the GlorpenPropelBundle and defining the extended classes in my config:
glorpen_propel:
extended_models:
Core\Inventory\Model\Product: Bookshop\Inventory\Model\Book
Fine, it works, but surely there's a better way? Have I missed something, or is this really the only way to extend Models in Propel + Symfony? I really want to use Propel over Doctrine, but things like this leave me thinking that Propel simply isn't suited for projects over a certain size...
(Propel 1.6 + Symfony 2.3 btw)