\Content\Controller\AdminCommentsController

Controller for Field UI Manager.

Allows to approved, detach and configure Fields to Content Types.

Summary

Methods
Properties
Constants
beforeRender()
beforeFilter()
index()
edit()
status()
delete()
emptyTrash()
__construct()
isAction()
title()
description()
prepareTheme()
checkMaintenanceMode()
trigger()
eventDispatcher()
triggered()
viewMode()
addViewMode()
viewModes()
onViewMode()
asViewMode()
$theme
$layout
$viewClass
$components
$Contents
No constants found
_inResponseTo()
_setCounters()
$_manageTable
N/A
No private methods found
No private properties found
N/A

Properties

$theme

$theme : string

In use theme name.

Type

string

$layout

$layout : string

Name of the layout that should be used by current theme.

Type

string

$viewClass

$viewClass : string

The name of the View class controllers sends output to.

Type

string

$components

$components : array

An array containing the names of components controllers uses.

Type

array

$Contents

$Contents : \Content\Model\Table\ContentsTable

Type

\Content\Model\Table\ContentsTable

$_manageTable

$_manageTable : string

Name of the table managed by Comment UI API.

Type

string

Methods

beforeRender()

beforeRender(\Cake\Event\Event $event) : void

Fallback for template location when extending Comment UI API.

If controller tries to render an unexisting template under its Template directory, then we try to find that view under Comment/Template/CommentUI directory.

Example:

Suppose you are using this trait to manage comments attached to Persons entities. You would probably have a Person plugin and a clean controller as follow:

// http://example.com/admin/person/comments_manager
Person\Controller\CommentsManagerController::index()

The above controller action will try to render /plugins/Person/Template/CommentsManager/index.ctp. But if does not exists then <QuickAppsCorePath>/plugins/Comment/Template/CommentUI/index.ctp will be used instead.

Of course you may create your own template and skip this fallback functionality.

Parameters

\Cake\Event\Event $event

the event instance.

beforeFilter()

beforeFilter(\Cake\Event\Event $event) : void

Validation rules.

Parameters

\Cake\Event\Event $event

The event instance.

Throws

\Cake\Network\Exception\ForbiddenException

When

  • $_manageTable is not defined.
  • trait is used in non-controller classes.
  • the controller is not a backend controller.
  • the "_inResponseTo()" is not implemented.

index()

index(string $status) : void

Field UI main action.

Shows all the comments attached to the Table being managed. Possibles values for status are:

  • all: Comments marked as pending or approved. (by default)
  • pending: Comments awaiting for moderation.
  • approved: Comments approved and published.
  • spam: Comments marked as SPAM by Akismet.
  • trash: Comments that were sent to trash bin.

Parameters

string $status

Filter comments by status, see list above

edit()

edit(integer $id) : void

Edit form for given comment.

Parameters

integer $id

Comment id

Throws

\Cake\ORM\Exception\RecordNotFoundException

When comment was not found

status()

status(integer $id, string $status) : void

Changes the status of the given comment.

Parameters

integer $id

Comment id

string $status

New status for the comment

delete()

delete(integer $id) : void

Permanently deletes the given comment.

Parameters

integer $id

Comment id

emptyTrash()

emptyTrash() : void

Permanently deletes all comments marked as "trash".

__construct()

__construct(\Cake\Network\Request $request, \Cake\Network\Response $response)

Constructor.

Parameters

\Cake\Network\Request $request

Request object for this controller. Can be null for testing, but expect that features that use the request parameters will not work.

\Cake\Network\Response $response

Response object for this controller.

isAction()

isAction(string $action) : boolean

Method to check that an action is accessible from a URL.

Override this method to change which controller methods can be reached. The default implementation disallows access to all methods defined on Cake\Controller\Controller or QuickApps\Controller\Controller, and allows all public methods on all subclasses of this class.

Parameters

string $action

The action to check.

Returns

boolean —

Whether or not the method is accessible from a URL.

title()

title(string $titleForLayout) : void

Shortcut for Controller::set('title_for_layout', .

..)

Parameters

string $titleForLayout

The title to use on layout's title tag

description()

description(string $descriptionForLayout) : void

Shortcut for Controller::set('description_for_layout', .

..)

Parameters

string $descriptionForLayout

The description to use as meta-description on layout's head tag

prepareTheme()

prepareTheme() : void

Sets the theme to use.

checkMaintenanceMode()

checkMaintenanceMode() : void

Checks if maintenance is enabled, and renders the corresponding maintenance message.

Login & logout sections of the site still working even on maintenance mode, administrators can access the whole site as well.

Throws

\QuickApps\Controller\QuickApps\Error\SiteUnderMaintenanceException

When site is under maintenance mode

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

viewMode()

viewMode(string|null $slug) : void

Sets a view mode or get current view mode.

Parameters

string|null $slug

Slug name of the view mode

addViewMode()

addViewMode(string|array $slug, string|null $name, string|null $description) : void

Registers a new view mode. Or overwrite if already exists.

Parameters

string|array $slug

Slug name of your view mode. e.g.: my-view mode. Or an array of view modes to register indexed by slug name

string|null $name

Human readable name. e.g.: My View Mode

string|null $description

A brief description about for what is this view mode

viewModes()

viewModes(boolean|string $viewMode) : array

Gets the full list of all registered view modes, or for a single view mode if $viewMode is set to a string value.

Parameters

boolean|string $viewMode

Set to true to get full list. Or false (by default) to get only the slug of all registered view modes. Or set to a string value to get information for that view mode only.

Returns

array

onViewMode()

onViewMode(string|array $viewMode, callable $method) : mixed

Runs the given callable when the in-use view mode matches.

You can provide multiple view modes, in that case callable method will be executed if current view mode matches any in the given array.

Usage

// run this only on `teaser` view mode
echo $this->onViewMode('teaser', function () use ($someVar) {
    return $this->element('teaser_element', compact('someVar'));
});

// run this on "teaser" view mode, or "search-result" view mode
echo $this->onViewMode(['teaser', 'search-result'], function () use ($someVar) {
    return $this->element('teaser_or_search_result', compact('someVar'));
});

Parameters

string|array $viewMode

View Mode slug, or an array of slugs

callable $method

A callable function to run, it receives $this as only argument

Returns

mixed —

Callable return

asViewMode()

asViewMode(string|array $viewMode, callable $method) : mixed

Runs the given callable as it were under the given view mode.

Usage

$this->viewMode('full');
echo 'before: ' . $this->viewMode();

echo $this->asViewMode('teaser', function () {
     echo 'callable: ' . $this->viewMode();
});

echo 'after: ' . $this->viewMode();

// output:
// before: full
// callable: teaser
// after: full

Parameters

string|array $viewMode

View Mode slug, or an array of slugs

callable $method

A callable function to run, it receives $this as only argument

Returns

mixed —

Callable return

_inResponseTo()

_inResponseTo(\Comment\Model\Entity\Comment $comment) : string

Renders the description of the entity to which comment is attached to.

Parameters

\Comment\Model\Entity\Comment $comment

Comment entity

Returns

string

_setCounters()

_setCounters() : void

Sets a few view-variables holding counters for each status ("pending", "approved", "spam" or "trash").