\Comment\View\HelperCommentHelper

CommentForm helper library.

Renders comments for a given entity.

Summary

Methods
Properties
Constants
render()
optionsForInput()
captcha()
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

render()

render(\Cake\ORM\Entity $entity) : string

Renders a comments section for given entity.

Entity's comments must be in the comments property. It is automatically filled when using CommentableBehavior.

The following events will be triggered:

  • CommentHelper.beforeRender: Triggered before default rendering operation starts. By stopping this event, you can return the final value of the rendering operation.

  • CommentHelper.afterRender: Triggered after default rendering operation is completed. Listeners will receive the rendered output. By stopping this event, you can return the final value of the rendering operation.

Parameters

\Cake\ORM\Entity $entity

Any valid entity

Throws

\Cake\Network\Exception\InternalErrorException

When comment component was not loaded

Returns

string

optionsForInput()

optionsForInput(string $input) : array

Shortcut for generate form-input's options.

It take cares of adding an asterisk "*" to each required filed label, it also adds the "required" attribute.

Parameters

string $input

Input name (author_name, author_email, author_web, subject or body)

Returns

array

captcha()

captcha() : string

Renders CAPTCHA form element.

Returns

string —

HTML

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