/** * Getter for node type * * @return NodeType */ public function getNodeType() { $bag = hierarchy_bag('nodetype'); if ($this->relationLoaded('nodeType')) { $nodeType = $this->getRelation('nodeType'); } elseif ($nodeType = $bag->getNodeType($this->getNodeTypeKey())) { $this->setRelation('nodeType', $nodeType); } else { $nodeType = $this->load('nodeType')->getRelation('nodeType'); } if ($nodeType) { $bag->addNodeType($nodeType); return $nodeType; } return null; }
/** @test */ function it_registers_hierarchy_bag_helper() { $this->assertInstanceOf('Nuclear\\Hierarchy\\Bags\\NodeTypeBag', hierarchy_bag('nodetype')); }