PHP Class Noherczeg\Breadcrumb\Breadcrumb

ファイルを表示 Open project: noherczeg/breadcrumb Class Usage Examples

Public Methods

Method Description
__construct ( $base_url = null, $config = 'en' )
append ( String $raw_name = null, String $side = 'right', boolean $base = false, mixed $translate = true, boolean $disabled = false ) : Breadcrumb append: Appends an element to the list of Segments. Can do it from both sides, and can mark an element as base element, which means that it'll point to the base URL.
build ( String $format = null, String | null $casing = null, boolean $last_not_link = true, String | null $separator = null, array $customizations = [], boolean $different_links = false ) : String Builder method which returns with a result type as required.
disable ( integer $pos = null ) : Breadcrumb Disables a Segment at the given position.
from ( mixed $input = null ) : Breadcrumb from: Reads the first parameter which can be a String, PHP array, JSON array and creates + appends Segments from it in one step.
map ( array $rawArray ) : Breadcrumb Registers a list of title => link pairs with the package.
num_of_segments ( ) : integer num_of_segments: Returns the number of segments which are registered in the system.
registered ( ) : array registered: Returns all the registered Segments.
remove ( integer $pos, boolean $reindex_after_remove = false ) : Breadcrumb remove: Removes an element from the list, optionally can reindex the list after removal.
segment ( String $id ) : Segment segment: A getter which returns the Segment which is at the given position.
setBaseURL ( String $urlString ) : Breadcrumb Sets the base URL for the package.
setConfiguration ( mixed $config ) : Breadcrumb Dynamic Package configuration

Private Methods

Method Description
appendToSide ( $segment, $side )
checkAppendArgs ( $raw_name, $side )
checkFromArgs ( $input )
inputToArray ( $input = null )
loadBuilders ( ) : array
safeArrayAssignment ( $input ) : array
setParam ( mixed $to_this ) : String setParam: basic system method, don't bother.

Method Details

__construct() public method

public __construct ( $base_url = null, $config = 'en' )

append() public method

Supports method chaining. Warning! It doesn't fix multiple "base element" issues, so it's up to the programmer to append base elements wisely!
public append ( String $raw_name = null, String $side = 'right', boolean $base = false, mixed $translate = true, boolean $disabled = false ) : Breadcrumb
$raw_name String Name of the appendable Segment
$side String Which side to place the segment in the array
$base boolean true if it is referring to the base url
$translate mixed Set to true if you want to use the provided dictionary, set to false if you want to skip translation, or set to a specific string to assign that value
$disabled boolean
return Breadcrumb

build() public method

Supports separator switching, casing switching, and custom property insertion from an array (only if output is set to html!).
public build ( String $format = null, String | null $casing = null, boolean $last_not_link = true, String | null $separator = null, array $customizations = [], boolean $different_links = false ) : String
$format String Format of the output
$casing String | null Casing of Segments
$last_not_link boolean
$separator String | null Separator String (not there in Foundation!)
$customizations array Array of properties (only in HTML!)
$different_links boolean
return String

disable() public method

Segment will still remain, but won't be translated, and will be handled specially in the building process. Supports method chaining.
public disable ( integer $pos = null ) : Breadcrumb
$pos integer Position of the element
return Breadcrumb

from() public method

Supports method chaining.
public from ( mixed $input = null ) : Breadcrumb
$input mixed Either: PHP array, JSON array, URI string
return Breadcrumb

map() public method

All of the given data will be used as-is no translation, no URL conversion will be applied!
public map ( array $rawArray ) : Breadcrumb
$rawArray array Array with title => link pairs
return Breadcrumb

num_of_segments() public method

num_of_segments: Returns the number of segments which are registered in the system.
public num_of_segments ( ) : integer
return integer

registered() public method

registered: Returns all the registered Segments.
public registered ( ) : array
return array

remove() public method

Supports method chaining.
public remove ( integer $pos, boolean $reindex_after_remove = false ) : Breadcrumb
$pos integer Position of the element
$reindex_after_remove boolean To do the reindex or not
return Breadcrumb

segment() public method

segment: A getter which returns the Segment which is at the given position.
public segment ( String $id ) : Segment
$id String The ID of the required Segment.
return Segment

setBaseURL() public method

Sets the base URL for the package.
public setBaseURL ( String $urlString ) : Breadcrumb
$urlString String Base URL
return Breadcrumb

setConfiguration() public method

Dynamic Package configuration
public setConfiguration ( mixed $config ) : Breadcrumb
$config mixed Configurations (either lang code as String, or configuration array)
return Breadcrumb