public function setLocation($referenceId, $position = self::LOCATION_AFTER)
    {
        $allow = [
            static::LOCATION_AFTER,
            static::LOCATION_BEFORE,
            static::LOCATION_FIRST_CHILD,
            static::LOCATION_LAST_CHILD,
        ];

        // Make sure the location is valid.
        if (!in_array($position, $allow)) {
            throw new \InvalidArgumentException(
                sprintf(
                    '%s::setLocation(%d, *%s*)',
                    get_class($this),
                    $referenceId,
                    $position
                )
            );
        }

        // Set the location properties.
        $this->location = $position;
        $this->locationId = $referenceId;

        return $this;
    }
public function setLocation($referenceId, $position = self::LOCATION_AFTER)
    {
        $allow = [
            static::LOCATION_AFTER,
            static::LOCATION_BEFORE,
            static::LOCATION_FIRST_CHILD,
            static::LOCATION_LAST_CHILD,
        ];

        // Make sure the location is valid.
        if (!in_array($position, $allow)) {
            throw new \InvalidArgumentException(
                sprintf(
                    '%s::setLocation(%d, *%s*)',
                    get_class($this),
                    $referenceId,
                    $position
                )
            );
        }

        // Set the location properties.
        $this->location = $position;
        $this->locationId = $referenceId;

        return $this;
    }
public function setLocation ( $ referenceId , $ position = self :: LOCATION_AFTER ) { $ allow = [ static :: LOCATION_AFTER , static :: LOCATION_BEFORE , static :: LOCATION_FIRST_CHILD , static :: LOCATION_LAST_CHILD , ] ; // Make sure the location is valid. if ( ! in_array ( $ position , $ allow ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s::setLocation(%d, *%s*)' , get_class ( $ this ) , $ referenceId , $ position ) ) ; } // Set the location properties. $ this -> location = $ position ; $ this -> locationId = $ referenceId ; return $ this ; }
Method to set the location of a node in the tree object.  This method does not
save the new location to the database, but will set it in the object so
that when the node is stored it will be stored in the new location.

@param   integer $referenceId The primary key of the node to reference new location by.
@param   integer $position    Location type string. ['before', 'after', 'first-child', 'last-child']

@return  static

@since   2.0
@throws  \InvalidArgumentException
Method to set the location of a node in the tree object . This method does not save the new location to the database but will set it in the object so that when the node is stored it will be stored in the new location .