public function setRelationship($name, $config = array())
    {
        $relationships = is_string($name) ? array($name => $config) : $name;
        settype($relationships, 'array');
        $property = null;

        foreach ($relationships as $name => $config) {
            if (is_numeric($name)) {
                $name = $config;
                $config = array();
            }

            $config['name'] = pick($this->getAlias($name), $name);
            $config['description'] = $this;
            $property = AnDomainProperty::setRelationship(new AnConfig($config));

            if ($property instanceof AnDomainRelationshipOnetomany) {
                //if the entity is abstract then
                //keep track of all the has relationships
                //this relationship will propgate through children
                if ($this->isAbstract()) {
                    self::$__has_relationships[$property->getName()][$this->_entity_identifier->classname] = $property;
                }
            }
        }

        return $property;
    }
public function setRelationship($name, $config = array())
    {
        $relationships = is_string($name) ? array($name => $config) : $name;
        settype($relationships, 'array');
        $property = null;

        foreach ($relationships as $name => $config) {
            if (is_numeric($name)) {
                $name = $config;
                $config = array();
            }

            $config['name'] = pick($this->getAlias($name), $name);
            $config['description'] = $this;
            $property = AnDomainProperty::setRelationship(new AnConfig($config));

            if ($property instanceof AnDomainRelationshipOnetomany) {
                //if the entity is abstract then
                //keep track of all the has relationships
                //this relationship will propgate through children
                if ($this->isAbstract()) {
                    self::$__has_relationships[$property->getName()][$this->_entity_identifier->classname] = $property;
                }
            }
        }

        return $property;
    }
public function setRelationship ( $ name , $ config = array ( ) ) { $ relationships = is_string ( $ name ) ? array ( $ name => $ config ) : $ name ; settype ( $ relationships , 'array' ) ; $ property = null ; foreach ( $ relationships as $ name => $ config ) { if ( is_numeric ( $ name ) ) { $ name = $ config ; $ config = array ( ) ; } $ config [ 'name' ] = pick ( $ this -> getAlias ( $ name ) , $ name ) ; $ config [ 'description' ] = $ this ; $ property = AnDomainProperty :: setRelationship ( new AnConfig ( $ config ) ) ; if ( $ property instanceof AnDomainRelationshipOnetomany ) { //if the entity is abstract then //keep track of all the has relationships //this relationship will propgate through children if ( $ this -> isAbstract ( ) ) { self :: $ __has_relationships [ $ property -> getName ( ) ] [ $ this -> _entity_identifier -> classname ] = $ property ; } } } return $ property ; }
Set a relationship or relationships property. It is possible to set an set of relationships by
passing an array as the name.

@param string $name   The name of the relationshp or an array of name/option value
@param array  $config The relationship options

@return AnDomainAttributeAbstract
Set a relationship or relationships property . It is possible to set an set of relationships by passing an array as the name .