0

That's it. I created behavior and only some of its classes are added into head with use due to my behavior.

E.g. behavior creates new table named acme. Propel generator adds to my Foo class (app/propel/AppPropelModel/AcmeBundle/om/BaseFoo.php) AcmeBehavior and AcmeBehaviorQuery, but not AcmeBehaviorPeer.

I don't want to mess with full class name in behaviour-building class AcmeBehaviorObjectBuilderModifier.php How could I make Propel add use AppPropelModel\HornsAndHooves\AcmeBundle\AcmeBehaviorPeer to the destination class file as well?

kirilloid
  • 14,011
  • 6
  • 38
  • 52
  • Sorry, but I'm not sure I understand what you're trying to do (or what isn't working). Are you saying you have a Behavior you wrote which creates a table, but that the `*Peer` class isn't being generated? Is that the only issue? – Jordan Kasper Feb 08 '13 at 18:19
  • No, class is generated. It is not _written_ into `uses` block. – kirilloid Feb 11 '13 at 07:22

1 Answers1

1

If you use a class and want to add it to "use" block, you have to declare that class in the builder. Just call declareClass in this function with your full namespace:

class MyBehavior extends Behavior {
    ...

    public function objectMethods($builder)
    {
        $builder->declareClass('MyNamespace\\MyBundle\\Subfolder');
    }
}

This will result:

use MyNamespace\MyBundle\Subfolder;

abstract class MyModelClass extends ...
BenMorel
  • 34,448
  • 50
  • 182
  • 322
zebra
  • 51
  • 4