Properties

$shouldRenderLayout

$shouldRenderLayout : boolean

Whether the admin environment should wrap the page environment with the layout (i.e. admin shell chrome.

Type

boolean

$path

$path : string

The path to the component class.

Type

string

$env

$env : \Dewdrop\Admin\Env\EnvInterface

The admin environment. Used to do anything environment (i.e. WP or Silex) specific, like perform redirects.

Type

\Dewdrop\Admin\Env\EnvInterface

$pageFactories

$pageFactories : array

The page factories registered with this component to provide page objects.

Type

array

$customPageFactory

$customPageFactory : \Dewdrop\Admin\PageFactory\Custom

A page factory to allow overriding of page classes that come from other factories.

Type

\Dewdrop\Admin\PageFactory\Custom

$pageDispatchCallbacks

$pageDispatchCallbacks : array

Callbacks registered with this component via onPageDispatch().

Type

array

Methods

getPath()

getPath() : string

Get the path to this component's class.

Returns

string

getFullyQualifiedName()

getFullyQualifiedName() : string

Get a fully-qualified name for the component that can be used when referencing the component in externals systems like the DB.

Returns

string

getListingQueryParamsSessionName()

getListingQueryParamsSessionName() : string

Get an identifier that can be used when storing this component's listing query string parameters in the session. We store the params so that we can redirect while maintaining filter and pagination state.

Returns

string

getPermissions()

getPermissions() : \Dewdrop\Admin\Permissions

Get the Permissions object for this component.

Returns

\Dewdrop\Admin\Permissions

getPageFactories()

getPageFactories() : array

Get all the page factories associated with this component.

Returns

array

getCustomPageFactory()

getCustomPageFactory() : \Dewdrop\Admin\PageFactory\Custom

Get the custom page factory for this component.

Returns

\Dewdrop\Admin\PageFactory\Custom

createPageObject()

createPageObject(string  $name) : \Dewdrop\Admin\Page\PageAbstract|false

Iterate over the page factories, attempting to create a page object for the supplied name. If no page factory can handle the page name, that's a 404.

Parameters

string $name

Throws

\Dewdrop\Exception

Returns

\Dewdrop\Admin\Page\PageAbstract|false

onPageDispatch()

onPageDispatch(  $pageName, callable  $callback) : $this

Register a callback to run when the page matching the supplied name is dispatched on this component. Your callback will receive the new page object as its first argument.

Parameters

$pageName
callable $callback

Returns

$this

dispatchPage()

dispatchPage(mixed  $page = null, \Dewdrop\Admin\Response  $response = null) : mixed

Dispatch the routed page, working through its init(), process() and render() methods.

Each abstract page class can specify whether the process() method should actually be run by implementing a shouldProcess() method. The page's init() method is guaranteed to always be called. If after calling render there is no output, the component will attempt to render the page's default view script automatically.

Parameters

mixed $page
\Dewdrop\Admin\Response $response

Returns

mixed

setShouldRenderLayout()

setShouldRenderLayout(boolean  $shouldRenderLayout) : $this

Set whether the admin environment should wrap the page's output with the layout (the admin shell chrome).

Parameters

boolean $shouldRenderLayout

Returns

$this

shouldRenderLayout()

shouldRenderLayout() : boolean

Check to see whether the page output should be wrapped by the layout.

Returns

boolean

getSlug()

getSlug() : string

Get WP slug for this component.

We use the component name, with namespace back slashes replaced with URL-friendly front slashes, as the slug.

Returns

string

renderJsonResponse()

renderJsonResponse(array  $output) : void

Render the supplied output as a JSON response. This method is mostly in place to allow mocking (and thus dodging the exit statement) during testing.

Parameters

array $output

executePageDispatchCallbacks()

executePageDispatchCallbacks(\Dewdrop\Admin\Page\PageAbstract  $page) : $this

Run any page dispatch callbacks assigned to the provided page. We support both the WP and hyphen-separated versions of the page names in this method to make it easier to reuse page dispatch code across different environments.

Parameters

\Dewdrop\Admin\Page\PageAbstract $page

Returns

$this