public function __construct($relationshipName, $modelType, $fieldRelationshipName) { parent::__construct($relationshipName); $this->modelType = $modelType; $this->fieldRelationshipName = $fieldRelationshipName; $this->fieldRelationship = $modelType::getRelationship($fieldRelationshipName); }
public static function addRelationship(Relationship $relationship) { // first we need to namespace the relationships, as the relationship array is staticly defined; // meaning if we would add 2 relationships with the same name on different models, the first one would be overridden // we use the relationshipKey, which is a namespaced version with the relationship source added $sourceModelType = get_called_class(); if (!array_key_exists($sourceModelType, static::$relationships)) { static::$relationships[$sourceModelType] = array(); } $relationship->setRelationshipSource($sourceModelType); static::$relationships[$sourceModelType][$relationship->getRelationshipKey()] = $relationship; }
public function __construct($relationshipName, $relationshipField) { parent::__construct($relationshipName); $this->relationshipField = $relationshipField; }