public function render(Entity $entity)
    {
        if (!isset($this->_View->viewVars['__commentComponentLoaded__'])) {
            throw new InternalErrorException(__d('comment', 'Illegal usage of \Comment\View\Helper\CommentHelper.'));
        }

        $this->config('entity', $entity);
        $event = $this->trigger(['CommentHelper.beforeRender', $this->_View]);
        if ($event->isStopped()) {
            return $event->result;
        }

        $out = '';
        if ($this->config('visibility') > 0) {
            $out .= $this->_View->element('Comment.render_comments_list');
            if ($this->config('visibility') === 1) {
                $out .= $this->_View->element('Comment.render_comments_form');
            }
        }

        $event = $this->trigger(['CommentHelper.afterRender', $this->_View], $out);
        if ($event->isStopped()) {
            return $event->result;
        }

        return $out;
    }
public function render(Entity $entity)
    {
        if (!isset($this->_View->viewVars['__commentComponentLoaded__'])) {
            throw new InternalErrorException(__d('comment', 'Illegal usage of \Comment\View\Helper\CommentHelper.'));
        }

        $this->config('entity', $entity);
        $event = $this->trigger(['CommentHelper.beforeRender', $this->_View]);
        if ($event->isStopped()) {
            return $event->result;
        }

        $out = '';
        if ($this->config('visibility') > 0) {
            $out .= $this->_View->element('Comment.render_comments_list');
            if ($this->config('visibility') === 1) {
                $out .= $this->_View->element('Comment.render_comments_form');
            }
        }

        $event = $this->trigger(['CommentHelper.afterRender', $this->_View], $out);
        if ($event->isStopped()) {
            return $event->result;
        }

        return $out;
    }
public function render ( Entity $ entity ) { if ( ! isset ( $ this -> _View -> viewVars [ '__commentComponentLoaded__' ] ) ) { throw new InternalErrorException ( __d ( 'comment' , 'Illegal usage of \Comment\View\Helper\CommentHelper.' ) ) ; } $ this -> config ( 'entity' , $ entity ) ; $ event = $ this -> trigger ( [ 'CommentHelper.beforeRender' , $ this -> _View ] ) ; if ( $ event -> isStopped ( ) ) { return $ event -> result ; } $ out = '' ; if ( $ this -> config ( 'visibility' ) > 0 ) { $ out .= $ this -> _View -> element ( 'Comment.render_comments_list' ) ; if ( $ this -> config ( 'visibility' ) === 1 ) { $ out .= $ this -> _View -> element ( 'Comment.render_comments_form' ) ; } } $ event = $ this -> trigger ( [ 'CommentHelper.afterRender' , $ this -> _View ] , $ out ) ; if ( $ event -> isStopped ( ) ) { return $ event -> result ; } return $ out ; }
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.

@param \Cake\ORM\Entity $entity Any valid entity
@return string
@throws \Cake\Network\Exception\InternalErrorException When comment
component was not loaded
Renders a comments section for given entity .