Skip to content

Public API: GustavSrc

Lucas Krause edited this page Jan 29, 2015 · 3 revisions

##Instance functions

###void __construct( string|string[] $path )

The class's constructor that is called when a new instance is created.
If the passed path doesn't point on a file, a RuntimeException is thrown. If no GustavContent object can be created for the passed path, a RuntimeException is thrown, too. The same happens if no GustavBlock object can be created.
If everything worked properly, the newly created object is initialized.

$path
The path of the source file represented by this object. Gets passed to GustavBase::path().

###string getPath()

Returns the path of the source file represented by this object.

###string getDesc()

Returns the source file's plaintext description. The description may contain linebreaks.
If the _desc GvBlock option is set, that option's value is used. Otherwise the description is built from the source file's content.

###string[] getCategory()

Returns the category of the source file to be used for filling a breadcrumb navigation for example.
The category is taken from the folder structure starting at the root of the source directory and ending at the directory the source file is locating in. The array contains the uppermost category as its first item, that category's subcategory as its second item and so on. If the source file is located in the root of the source directory, the category will be an empty array.
Before getting the category the source file's path is resolved using realpath() to remove symbolic links, occurences of ./ and ../, as well as sequences of /. If that function fails, the category is set to an empty array.

###bool isDis()

Returns whether the source file is disabled.

###GustavBlock|mixed|null getBlock( [ string|null $option = null ] )

A global getter function returning the source file's GvBlock or just one of its options' values.
See GustavBlock::get() for more information.

$option
The name of the GvBlock's option whose value should be returned. If it doesn't exist, null is returned. If set to null, the GustavBlock object is returned.

Returns either the whole GvBlock or just a single option's value.

Clone this wiki locally