diff --git a/README.md b/README.md index 19a5857..3fc91fe 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,123 @@ From the View you can bubble up to the Loader, grab the global parameters, enter Other features: * Child themes: Instead of having to duplicate the entire theme directory, you can extend another and fallback on its files. You can also extend a theme that by itself extends another, without depth limit. -* Asset Manager: compile LESS files on the fly. \ No newline at end of file +* Asset Manager: compile LESS files on the fly. + + +## Classes + +#### Theme + +The Theme object abstracts the content of the theme. These will be returned by the Loader, and you will be able to choose which to use. + +* __$theme->createBuilder()__ + + Returns a new builder. It's used to create the HTML. + +* __$theme->createAssetManager()__ + + Returns a new asset manager. It's used to load and edit the content of the package that the user will download, like stylesheets and images. + +#### Builder + +The builder is used to create the HTML. It divides the job between layouts and partials, and provides a global parameter manager. + +* __$builder->getTheme()__ + + Returns the Theme that generated this builder object. + +* __$builder->getParamManager()__ + + Returns the parameter manager used to hold parameters for the views. + +* __$builder->createLayout($view)__ + + * string _$view_ - The name of the layout with underscores + + Sets the layout and returns the View object. + +* __$builder->createPartial($name, $view)__ + + * string _$name_ - A given name for the partial + * string _$view_ - The name of the layout with underscores + + Sets a partial with the given $name, and returns the View object. + +* __$builder->getLayout()__ + + Returns the currently set Layout. + +* __$builder->getPartial($name)__ + + * string _$name_ - The given name of the partial + + Returns the partial with the given name. + +* __$builder->build()__ + + Builds the entire HTML with the given parameters. + +#### Parameter Manager + +Parameter managers are used to consistently store variables for being used in the theme. The Builder owns a global one, and every View has a local one. + +* __$pm->reset()__ + + Resets the object to its original state. + +* __$pm->getParams()__ + + Returns an array of parameters. + +* __$pm->getParam($key)__ + + * string _$key_ - The key for the value + + Returns the value stored with $key. + + __Throws:__ _\OutOfBoundsException_ - If the value was not set + +* __$pm->setParam($key, $value)__ + + * string _$key_ - The key for the value + * mixed _$value_ - The value + + Sets a parameter + +* __$pm->setParams($array)__ + + * array _$array_ - An array of parameters to set + + Takes an array and inserts every single parameter. Doesn't delete previous parameters. + +#### View + +The View returned by the Builder is most often a custom object extending \Foolz\Theme\View. + +__It's compulsory to override the `toString()` method (not the `__toString()` magic method!) in order to output the HTML. This function should output HTML or return a string.__ + +* __$view->toString()__ + + Called when the HTML must be generated. It should contain the classic HTML building logic. `$this` can be used. No manual output buffering is necessary. + +* __$view->getType()__ + + Returns the type of View. `layout` or `partial`. + +* __$view->getView()__ + + Returns the name of the View. + +* __$view->getParamManager()__ + + Returns the local parameter manager. + +* __$view->build()__ + + Builds _and cached_ the HTML. Returns the HTML. + +* __$view->doBuild()__ + + Builds the HTML and stores it in a variable. Rebuilds the HTML every time it's called. + + __CHAINABLE__ \ No newline at end of file diff --git a/classes/Foolz/Theme/Builder.php b/classes/Foolz/Theme/Builder.php index ea6658b..3f53054 100644 --- a/classes/Foolz/Theme/Builder.php +++ b/classes/Foolz/Theme/Builder.php @@ -128,8 +128,8 @@ public function getPartial($name) * @return string The content generated * @throws \OutOfBoundsException If the layout wasn't selected */ - public function get() + public function build() { - return $this->getLayout()->get(); + return $this->getLayout()->build(); } } \ No newline at end of file diff --git a/classes/Foolz/Theme/ParamManager.php b/classes/Foolz/Theme/ParamManager.php index 3ffd83f..3ad06fd 100644 --- a/classes/Foolz/Theme/ParamManager.php +++ b/classes/Foolz/Theme/ParamManager.php @@ -18,7 +18,7 @@ class ParamManager */ public function reset() { - $this->params = [];; + $this->params = []; return $this; } diff --git a/classes/Foolz/Theme/View.php b/classes/Foolz/Theme/View.php index d458bed..3e594f6 100644 --- a/classes/Foolz/Theme/View.php +++ b/classes/Foolz/Theme/View.php @@ -156,11 +156,11 @@ public function getParamManager() * * @return string The compiled view */ - public function get() + public function build() { if ($this->built === null) { - $this->build(); + $this->doBuild(); } return $this->built; @@ -171,7 +171,7 @@ public function get() * * @return \Foolz\Theme\View The current object */ - public function build() + public function doBuild() { $this->built = $this->toString();