Hive_Container::relation PHP Method

relation() public method

public relation ( Hive_Relation $relation = NULL )
$relation Hive_Relation
    public function relation(Hive_Relation $relation = NULL)
    {
        if (!$relation) {
            return $this->__relation;
        }
        $this->__relation = $relation;
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Create a new container.
  *
  *     $container = Hive_Container::factory($owner, $relation);
  *
  * @param   Hive           owner of this container
  * @param   Hive_Relation  relation that generated this container
  * @return  Hive_Container
  */
 public static function factory(Hive $owner = NULL, Hive_Relation $relation = NULL)
 {
     $container = new Hive_Container();
     if ($owner) {
         // Store the owner that created this container
         $container->owner($owner);
     }
     if ($relation) {
         // Store the relation that created this container
         $container->relation($relation);
     }
     return $container;
 }