Overview

Namespaces

  • Charcoal
    • Object
    • User
      • Acl

Classes

  • Content
  • ObjectRevision
  • ObjectRoute
  • ObjectSchedule
  • UserData

Interfaces

  • ArchivableInterface
  • CategorizableInterface
  • CategorizableMultipleInterface
  • CategoryInterface
  • ContentInterface
  • HierarchicalInterface
  • ObjectRevisionInterface
  • ObjectRouteInterface
  • ObjectScheduleInterface
  • PublishableInterface
  • RevisionableInterface
  • RoutableInterface
  • UserDataInterface

Traits

  • ArchivableTrait
  • CategorizableMultipleTrait
  • CategorizableTrait
  • CategoryTrait
  • HierarchicalTrait
  • PublishableTrait
  • RevisionableTrait
  • RoutableTrait
  • Overview
  • Namespace
  • Class

Trait HierarchicalTrait

Full implementation, as a trait, of the HierarchicalInterface

Namespace: Charcoal\Object
Located at Charcoal/Object/HierarchicalTrait.php
Methods summary
public Charcoal\Object\HierarchicalInterface
# resetHierarchy( )

Reset this object's hierarchy.

Reset this object's hierarchy.

The object's hierarchy can be rebuilt with self::hierarchy().

Returns

Charcoal\Object\HierarchicalInterface
Chainable
public Charcoal\Object\HierarchicalInterface
# setMaster( mixed $master )

Set this object's immediate parent.

Set this object's immediate parent.

Parameters

$master
The object's parent (or master).

Returns

Charcoal\Object\HierarchicalInterface
Chainable

Throws

UnexpectedValueException
The current object cannot be its own parent.
public Charcoal\Object\HierarchicalInterface|null
# master( )

Retrieve this object's immediate parent.

Retrieve this object's immediate parent.

Returns

Charcoal\Object\HierarchicalInterface|null
public boolean
# hasMaster( )

Determine if this object has a direct parent.

Determine if this object has a direct parent.

Returns

boolean
public boolean
# isTopLevel( )

Determine if this object is the head (top-level) of its hierarchy.

Determine if this object is the head (top-level) of its hierarchy.

Top-level objects do not have a parent (master).

Returns

boolean
public boolean
# isLastLevel( )

Determine if this object is the tail (last-level) of its hierarchy.

Determine if this object is the tail (last-level) of its hierarchy.

Last-level objects do not have a children.

Returns

boolean
public integer
# hierarchyLevel( )

Retrieve this object's position (level) in its hierarchy.

Retrieve this object's position (level) in its hierarchy.

Starts at "1" (top-level).

The level is calculated by loading all ancestors with self::hierarchy().

Returns

integer
public Charcoal\Object\HierarchicalInterface|null
# toplevelMaster( )

Retrieve the top-level ancestor of this object.

Retrieve the top-level ancestor of this object.

Returns

Charcoal\Object\HierarchicalInterface|null
public boolean
# hasParents( )

Determine if this object has any ancestors.

Determine if this object has any ancestors.

Returns

boolean
public array
# hierarchy( )

Retrieve this object's ancestors (from immediate parent to top-level).

Retrieve this object's ancestors (from immediate parent to top-level).

Returns

array
public array
# invertedHierarchy( )

Retrieve this object's ancestors, inverted from top-level to immediate.

Retrieve this object's ancestors, inverted from top-level to immediate.

Returns

array
public boolean
# isMasterOf( mixed $child )

Determine if the object is the parent of the given object.

Determine if the object is the parent of the given object.

Parameters

$child
The child (or ID) to match against.

Returns

boolean
public boolean
# recursiveIsMasterOf( mixed $child )

Determine if the object is a parent/ancestor of the given object.

Determine if the object is a parent/ancestor of the given object.

Parameters

$child
The child (or ID) to match against.

Returns

boolean
public boolean
# hasChildren( )

Get wether the object has any children at all

Get wether the object has any children at all

Returns

boolean
public integer
# numChildren( )

Get the number of children directly under this object.

Get the number of children directly under this object.

Returns

integer
public integer
# recursiveNumChildren( )

Get the total number of children in the entire hierarchy. This method counts all children and sub-children, unlike numChildren() which only count 1 level.

Get the total number of children in the entire hierarchy. This method counts all children and sub-children, unlike numChildren() which only count 1 level.

Returns

integer
public Charcoal\Object\HierarchicalInterface
# setChildren( array $children )

Parameters

$children
The children to set.

Returns

Charcoal\Object\HierarchicalInterface
Chainable
public Charcoal\Object\HierarchicalInterface
# addChild( mixed $child )

Parameters

$child
The child object (or ident) to add.

Returns

Charcoal\Object\HierarchicalInterface
Chainable

Throws

UnexpectedValueException
The current object cannot be its own child.
public array
# children( )

Get the children directly under this object.

Get the children directly under this object.

Returns

array
abstract public array
# loadChildren( )

Returns

array
public boolean
# isChildOf( mixed $master )

Parameters

$master
The master object (or ident) to check against.

Returns

boolean
public boolean
# recursiveIsChildOf( mixed $master )

Parameters

$master
The master object (or ident) to check against.

Returns

boolean
public boolean
# hasSiblings( )

Returns

boolean
public integer
# numSiblings( )

Returns

integer
public array
# siblings( )

Get all the objects on the same level as this one.

Get all the objects on the same level as this one.

Returns

array
public boolean
# isSiblingOf( mixed $sibling )

Parameters

$sibling
The sibling to check.

Returns

boolean
abstract public Charcoal\Factory\FactoryInterface
# modelFactory( )

Retrieve the object model factory.

Retrieve the object model factory.

Returns

Charcoal\Factory\FactoryInterface
Properties summary
protected Charcoal\Object\HierarchicalInterface|null $master

The object's parent, if any, in the hierarchy.

The object's parent, if any, in the hierarchy.

#
public static Charcoal\Model\ModelInterface $objectCache

A store of cached objects.

A store of cached objects.

# []
API documentation generated by ApiGen