\QuickApps\View\HelperHtmlHelper

Html helper class for easy use of HTML widgets.

Overwrites CakePHP's Html Helper and adds alter hooks to every method, so plugins may alter html elements rendering cycle.

Summary

Methods
Properties
Constants
head()
trigger()
eventDispatcher()
triggered()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

head()

head(mixed $options) : string

Renders default layout's header.

This should be used within "" & "", provides a basic head configuration for usage in theme's layouts.

Usage:

In your theme's layout (e.g. default.ctp) you have to use this method between <head> & </head> tags, for example:

<!DOCTYPE html>
<html>
      <head>
        <?php echo $this->head(); ?>
        <!-- rest of your head code -->
     </head>
     <body>
         <!-- page content -->
     </body>
</html>

If you want to automatically include some Twitter Bootstrap's files set bootstrap key in the $options array as follow:

  • (bool) false: Nothing will be automatically included.
  • (bool) true: Will include Twitter Bootstrap's CSS & JS files.
  • (string) "css": Include CSS files only. (By default)
  • (string) "js": Include JS files only.
  • (string) Both "css,js" or "js,css": Equivalent to bool true, will include both, JS and CSS files.

Example:

// no CSS nor JS
<?php echo $this->Html->head(['boostrap' => false]); ?>

// CSS files only (default)
<?php echo $this->Html->head(['boostrap' => 'css']); ?>

// CSS & JS files
<?php echo $this->Html->head(['boostrap' => true]); ?>

// JS files only
<?php echo $this->Html->head(['boostrap' => 'js']); ?>

// CSS & JS files, it can be either "css,js" or "js,css"
<?php echo $this->Html->head(['boostrap' => 'css,js']); ?>

Other options available are:

  • icon: True to include favicon meta-tag. Defaults to true.
  • prepend: Any additional HTML code you need to prepend to the result.
  • append: Any additional HTML code you need to append to the result.

Parameters

mixed $options

As described above

Returns

string —

HTML code

trigger()

trigger(array|string $eventName) : \Cake\Event\Event

Triggers the given event name. This method provides a shortcut for:

$this->trigger('EventName', $arg1, $arg2, ..., $argn);

You can provide a subject to use by passing an array as first arguments where the first element is the event name and the second one is the subject, if no subject is given $this will be used by default:

$this->trigger(['GetTime', new MySubject()], $arg_0, $arg_1, ..., $arg_n);

You can also indicate an EventDispatcher instance to use by prefixing the event name with <InstanceName>::, for instance:

$this->trigger('Blog::EventName', $arg1, $arg2, ..., $argn);

This will use the EventDispacher instance named Blog and will trigger the event EventName within that instance.

Parameters

array|string $eventName

The event name to trigger

Returns

\Cake\Event\Event —

The event object that was fired

eventDispatcher()

eventDispatcher(string $name) : \QuickApps\Event\EventDispatcher

Gets an instance of the given Event Dispatcher name.

Usage:

$this->eventDispatcher('myDispatcher')
    ->trigger('MyEventName', $argument)
    ->result;

Parameters

string $name

Name of the dispatcher to get, defaults to 'default'

Returns

\QuickApps\Event\EventDispatcher

triggered()

triggered(string|null $eventName) : integer|array

Retrieves the number of times an event was triggered, or the complete list of events that were triggered.

Parameters

string|null $eventName

The name of the event, if null returns the entire list of event that were fired

Returns

integer|array