public function addBehavior($bdata)
    {
        if ($bdata instanceof Behavior) {
            $behavior = $bdata;

            // the new behavior is already registered
            if ($this->hasBehavior($behavior->getId()) && $behavior->allowMultiple()) {
                // the user probably just forgot to specify the "id" attribute
                if ($behavior->getId() === $behavior->getName()) {
                    throw new BuildException(sprintf('Behavior "%s" is already registered. Specify a different ID attribute to register the same behavior several times.', $behavior->getName()));
                } else { // or he copy-pasted it and forgot to update it.
                    throw new BuildException(sprintf('A behavior with ID "%s" is already registered.', $behavior->getId()));
                }
            }

            $this->registerBehavior($behavior);
            $this->behaviors[$behavior->getId()] = $behavior;

            return $behavior;
        }

        $locator = $this->getBehaviorLocator();
        $class = $locator->getBehavior($bdata['name']);
        $behavior = new $class();
        if (!($behavior instanceof Behavior)) {
            throw new BuildException(sprintf('Behavior [%s: %s] not instance of %s',
                    $bdata['name'], $class, '\Propel\Generator\Model\Behavior'));
        }
        $behavior->loadMapping($bdata);

        return $this->addBehavior($behavior);
    }
public function addBehavior($bdata)
    {
        if ($bdata instanceof Behavior) {
            $behavior = $bdata;

            // the new behavior is already registered
            if ($this->hasBehavior($behavior->getId()) && $behavior->allowMultiple()) {
                // the user probably just forgot to specify the "id" attribute
                if ($behavior->getId() === $behavior->getName()) {
                    throw new BuildException(sprintf('Behavior "%s" is already registered. Specify a different ID attribute to register the same behavior several times.', $behavior->getName()));
                } else { // or he copy-pasted it and forgot to update it.
                    throw new BuildException(sprintf('A behavior with ID "%s" is already registered.', $behavior->getId()));
                }
            }

            $this->registerBehavior($behavior);
            $this->behaviors[$behavior->getId()] = $behavior;

            return $behavior;
        }

        $locator = $this->getBehaviorLocator();
        $class = $locator->getBehavior($bdata['name']);
        $behavior = new $class();
        if (!($behavior instanceof Behavior)) {
            throw new BuildException(sprintf('Behavior [%s: %s] not instance of %s',
                    $bdata['name'], $class, '\Propel\Generator\Model\Behavior'));
        }
        $behavior->loadMapping($bdata);

        return $this->addBehavior($behavior);
    }
public function addBehavior ( $ bdata ) { if ( $ bdata instanceof Behavior ) { $ behavior = $ bdata ; // the new behavior is already registered if ( $ this -> hasBehavior ( $ behavior -> getId ( ) ) && $ behavior -> allowMultiple ( ) ) { // the user probably just forgot to specify the "id" attribute if ( $ behavior -> getId ( ) === $ behavior -> getName ( ) ) { throw new BuildException ( sprintf ( 'Behavior "%s" is already registered. Specify a different ID attribute to register the same behavior several times.' , $ behavior -> getName ( ) ) ) ; } else { // or he copy-pasted it and forgot to update it. throw new BuildException ( sprintf ( 'A behavior with ID "%s" is already registered.' , $ behavior -> getId ( ) ) ) ; } } $ this -> registerBehavior ( $ behavior ) ; $ this -> behaviors [ $ behavior -> getId ( ) ] = $ behavior ; return $ behavior ; } $ locator = $ this -> getBehaviorLocator ( ) ; $ class = $ locator -> getBehavior ( $ bdata [ 'name' ] ) ; $ behavior = new $ class ( ) ; if ( ! ( $ behavior instanceof Behavior ) ) { throw new BuildException ( sprintf ( 'Behavior [%s: %s] not instance of %s' , $ bdata [ 'name' ] , $ class , '\Propel\Generator\Model\Behavior' ) ) ; } $ behavior -> loadMapping ( $ bdata ) ; return $ this -> addBehavior ( $ behavior ) ; }
Adds a new Behavior

@param $bdata
@throws BuildException when the added behavior is not an instance of \Propel\Generator\Model\Behavior
@return Behavior       $bdata
Adds a new Behavior