Documentation

Register
in package

This will one day have methods for various different aspects of the cms incl. widgets, search handlers, tabs, etc.

Dare to dream

Table of Contents

Properties

$admin_controllers  : mixed
$admin_headings  : mixed
$admin_tiles  : mixed
$content_replace_chains  : mixed
$cron_jobs  : mixed
$dbtool_apis  : mixed
$display_conditions  : mixed
$docimports  : mixed
$emailtexts  : mixed
$extra_pages  : mixed
$features  : mixed
$front_end_controllers  : mixed
$linkspecs  : mixed
$moderators  : mixed
$modules  : array<string|int, ModuleInterface>
$pageattrs  : mixed
$rtelibraries  : mixed
$search_handlers  : mixed
$site_settings  : mixed
$sitemap_generators  : mixed
$widget_tiles  : mixed

Methods

addDbtoolsApi()  : void
Register an API test form
addSiteSetting()  : void
Register a site setting
adminControllers()  : void
Registers a module's shorthand controller names for the admin controller
adminHeading()  : mixed
Register a "heading", which is shown in the top bar the admin
adminTile()  : mixed
Register a "tile", which is shown in the modules menu in the admin
contentReplace()  : mixed
Register a method for a content replacement chain
cronJob()  : mixed
Register a method to be called for cron job processing
displayCondition()  : mixed
Register a display condition (this is part of the Context Engine on widgets)
docImport()  : mixed
Register a DocImport class
emailText()  : mixed
Register an email text
extraPage()  : mixed
Register a type for an extra page
feature()  : mixed
Register an available feature, and the root namespace where the helpers are found
findReplace()  : void
Register doomtools with find/replace tool.
frontEndController()  : void
Register a front-end controller (also called a tool page)
getAdminController()  : string
Converts an shorthand admin controller name to its full class name, including modular namespace
getAdminControllers()  : array<string|int, string>
Gets the list of modular admin controllers with registered shorthands
getAdminControllerShorthand()  : string
Get the shorthand for a given admin controller class.
getAdminHeadings()  : array<string|int, mixed>
Return an array of admin headings.
getAdminTiles()  : array<string|int, mixed>
Return an array of admin tiles.
getAllCronJobs()  : array<string|int, mixed>
Return all registered cron jobs
getContentReplaceMethods()  : array<string|int, mixed>
Return the methods for a given content replace chain
getCronJobs()  : array<string|int, mixed>
Return the methods for a given cron job schedule
getDbtoolsApi()  : array<string|int, mixed>
Return list of dbtool api tests
getDisplayConditions()  : array<string|int, mixed>
Return a list of all display condition registrations
getDocImports()  : mixed
Get all `DocImport`s
getEmailText()  : mixed
Get a single registered email texts. Returns an EmailTextReg object
getEmailTexts()  : mixed
Get all registered email texts. Returns an array of EmailTextReg objects
getExtraPages()  : mixed
Get all extra pages
getFeatureNamespace()  : string|null
Return the namespace for a given feature
getFrontEndControllers()  : mixed
Get all front-end controllers
getLinkspecs()  : mixed
Get all `LinkSpec`s
getModerators()  : mixed
Get all moderation classes
getModuleDirs()  : array<string|int, string>
Gets a list of paths to the active modules
getPageattrs()  : mixed
Get all extra pages
getRteLibraries()  : mixed
Get all `RteLibrary`s
getSearchHandlers()  : array<string|int, mixed>
Return list of SearchHandler objects
getSitemapGens()  : mixed
Get a list of all sitemap.xml generator classes
getSiteSettings()  : array<string|int, string>
Fetch list of registered site settings
getWidgetTiles()  : array<string|int, mixed>
Return an array of widget tiles for a given widget area Each tile has four keys, 'name', 'icon', 'text', and 'widgets'.
hasFeature()  : bool
Is the given feature currently available?
linkspec()  : mixed
Register a LinkSpec
moderator()  : mixed
Register a moderation class
module()  : void
Register a module.
modules()  : void
Registers many modules.
pageattr()  : mixed
Register a type for an extra page
rteLibrary()  : mixed
Register a RteLibrary class
searchHandler()  : void
Register search handler
services()  : void
Register one or many services.
sitemapGen()  : mixed
Register a sitemap.xml generator class
templateVariable()  : void
Register an helper to expose to twig templates via the 'sprout' namespace.
widgetTile()  : mixed
Register a widget "tile", which is shown when adding widgets (content blocks) to a page

Properties

$admin_controllers

private static mixed $admin_controllers = []

$admin_headings

private static mixed $admin_headings = []

$admin_tiles

private static mixed $admin_tiles = []

$content_replace_chains

private static mixed $content_replace_chains = []

$cron_jobs

private static mixed $cron_jobs = []

$dbtool_apis

private static mixed $dbtool_apis = []

$display_conditions

private static mixed $display_conditions = []

$docimports

private static mixed $docimports = array()

$emailtexts

private static mixed $emailtexts = array()

$extra_pages

private static mixed $extra_pages = array()

$features

private static mixed $features = []

$front_end_controllers

private static mixed $front_end_controllers = []

$linkspecs

private static mixed $linkspecs = array()

$moderators

private static mixed $moderators = array()

$pageattrs

private static mixed $pageattrs = array()

$rtelibraries

private static mixed $rtelibraries = array()

$search_handlers

private static mixed $search_handlers = []

$site_settings

private static mixed $site_settings = []

$sitemap_generators

private static mixed $sitemap_generators = []

$widget_tiles

private static mixed $widget_tiles = []

Methods

addDbtoolsApi()

Register an API test form

public static addDbtoolsApi(array<string|int, mixed> $api) : void
Parameters
$api : array<string|int, mixed>

[ title => (string) API name, desc => (string) subtitle, class => (string) => class name, method => (string) class method to load form ]

addSiteSetting()

Register a site setting

public static addSiteSetting(string $key) : void
Parameters
$key : string

Setting name

adminControllers()

Registers a module's shorthand controller names for the admin controller

public static adminControllers(string|array<string, ManagedAdminController>> $namespace[, array<string|int, string>|null $controllers = null ]) : void

Two invocations:

// 1. Explicit namespace (recommended)
Register::adminControllers([
   'my-controller' => MyController::class,
   'something-else' => SomeController::class,
]);

// 2. Fragment namespaces (deprecated):
Register::adminControllers('Namespace\To\Module', [
   'my-controller' => 'Admin\MyController',
   'something-else' => 'Other\Fragment\To\SomeController',
]);

In the second form, the namespace is forced into a SproutModules\\Author\\ModuleName\\ format. There's no requirement for this but has been convention until now.

To also encourage better readability and static analysis, the fully namespaced form is recommended.

Parameters
$namespace : string|array<string, ManagedAdminController>>

namespace including both developer and module name but not 'Controllers' segment, e.g. Karmabunny\HomePage\Admin

$controllers : array<string|int, string>|null = null

map of lowercased shorthand names to class names within the specified namespace, e.g. ['home' => 'Admin\HomePageAdminController']

Tags
throws
InvalidArgumentException

adminHeading()

Register a "heading", which is shown in the top bar the admin

public static adminHeading(array<string|int, mixed> $controllers[, int $sort_order = 10 ]) : mixed

Adding anything to this will override the entire default navigation.

Parameters
$controllers : array<string|int, mixed>

Controllers to show as links, in format 'shorthand' => 'label'

$sort_order : int = 10

Tiles are sorted by the sort order, then by the name alphabetically. Lower = earlier.

adminTile()

Register a "tile", which is shown in the modules menu in the admin

public static adminTile(string $name, string $icon, string $text, array<string|int, mixed> $controllers[, int $sort_order = 10 ]) : mixed

A list of available icons can be found in the file sprout/media/fonts/iconfont/demo.html

Parameters
$name : string

The name (title) of the tile

$icon : string

The icon class, sans the 'icon-' part. Examples: 'list', 'grid', 'home', etc.

$text : string

Explanation text. Plaintext.

$controllers : array<string|int, mixed>

Controllers to show as links, in format 'shorthand' => 'label'

$sort_order : int = 10

Tiles are sorted by the sort order, then by the name alphabetically. Lower = earlier.

contentReplace()

Register a method for a content replacement chain

public static contentReplace(string $chain, callable $func) : mixed

Registered method will receive one string argument and should return a string. For the 'inner_html' chain, the input and output should be HTML

Common chains: inner_html The "inside" HTML of widgets (richtext, blog content, etc) main_content The main content of inner and wide templates

Parameters
$chain : string

The chain to register the method for, e.g. 'inner_html'

$func : callable

The method to register

Tags
example

// register method Register::contentReplace('inner_html', ['Sprout\Helpers\ContentReplace', 'intlinks']);

// execute chain $new_html = ContentReplace::executeChain('inner_html', $old_html);

cronJob()

Register a method to be called for cron job processing

public static cronJob(string $schedule, string $class, string $func) : mixed

By default there is only one schedule, 'daily', but it's easy to add another schedule by duplicating the cron_daily.sh file and making the new file call the new schedule

Parameters
$schedule : string

The schedule for the job; corresponds to call in the shell script e.g. 'daily' will be called by the request 'cron_job/run/daily'

$class : string

The class containing the cron job method. Must be a controller

$func : string

The funciton name to call

Tags
example

Register::cronJob('daily', 'Sprout\Controllers\Admin\PageAdminController', 'cronPageActivate');

displayCondition()

Register a display condition (this is part of the Context Engine on widgets)

public static displayCondition(string $class, string $group, string $label) : mixed

Condition classes must extend the base class DisplayCondition

Parameters
$class : string

Class name, including namespace

$group : string

Label of the group, e.g. 'Platform'

$label : string

Label of the condtion, e.g. 'Device category'

docImport()

Register a DocImport class

public static docImport(mixed $ext, mixed $class, mixed $label) : mixed
Parameters
$ext : mixed
$class : mixed
$label : mixed

emailText()

Register an email text

public static emailText(string $code, array<string|int, mixed> $field_defs, string $default_html_view) : mixed
Parameters
$code : string

The template code e.g. user.welcome

$field_defs : array<string|int, mixed>

An array of name => description field definitions, for the admin e.g. array('first_name' => 'First name of the new user)

$default_html_view : string

The view name for the default text. Must be a .htm view e.g 'email/user_welcome'

extraPage()

Register a type for an extra page

public static extraPage(mixed $name, mixed $label) : mixed
Parameters
$name : mixed
$label : mixed

feature()

Register an available feature, and the root namespace where the helpers are found

public static feature(string $code, string $namespace) : mixed

Features allow the Sprout core to access code provided by modules without needing to hard-code the namespace of these modules

Parameters
$code : string

The feature code. Only one in use at this time, 'users'

$namespace : string

The root namespace (without 'Helpers' part) of the feature

Tags
example

Register::feature('users', 'SproutModules\Karmabunny\Users');

frontEndController()

Register a front-end controller (also called a tool page)

public static frontEndController(string $name, string $label) : void
Parameters
$name : string

Fully namespaced class name of Controller which MUST implement FrontEndEntrance, e.g. 'SproutModules\Karmabunny\Users\Controllers\UserController'

$label : string

Human-readable short name, e.g. 'Users'

Tags
throws
InvalidArgumentException

If controller doesn't implement FrontEndEntrance

getAdminController()

Converts an shorthand admin controller name to its full class name, including modular namespace

public static getAdminController(string $shorthand) : string
Parameters
$shorthand : string
Tags
throws
InvalidArgumentException
Return values
string —

class name

getAdminControllers()

Gets the list of modular admin controllers with registered shorthands

public static getAdminControllers() : array<string|int, string>
Return values
array<string|int, string> —

shorthand => full class name

getAdminControllerShorthand()

Get the shorthand for a given admin controller class.

public static getAdminControllerShorthand(string $class) : string
Parameters
$class : string
Tags
throws
InvalidArgumentException
Return values
string —

shorthand

getAdminHeadings()

Return an array of admin headings.

public static getAdminHeadings() : array<string|int, mixed>

Each heading has two keys, 'name' and 'controllers'.

Return values
array<string|int, mixed>

getAdminTiles()

Return an array of admin tiles.

public static getAdminTiles() : array<string|int, mixed>

Each tile has four keys, 'name', 'icon', 'text', and 'controllers'.

Return values
array<string|int, mixed>

getAllCronJobs()

Return all registered cron jobs

public static getAllCronJobs() : array<string|int, mixed>
Return values
array<string|int, mixed> —

Key is schedule, and array is a list of jobs like Register::getCronJobs

getContentReplaceMethods()

Return the methods for a given content replace chain

public static getContentReplaceMethods(string $chain) : array<string|int, mixed>
Parameters
$chain : string

The chain to return, e.g. 'inner_html'

Return values
array<string|int, mixed> —

Callables

getCronJobs()

Return the methods for a given cron job schedule

public static getCronJobs(string $schedule) : array<string|int, mixed>
Parameters
$schedule : string

The jobs to return, e.g. 'daily' or 'weekly'

Return values
array<string|int, mixed> —

Each row has [0] => class, [1] => func

getDbtoolsApi()

Return list of dbtool api tests

public static getDbtoolsApi() : array<string|int, mixed>
Return values
array<string|int, mixed>

getDisplayConditions()

Return a list of all display condition registrations

public static getDisplayConditions() : array<string|int, mixed>
Return values
array<string|int, mixed> —

Key is group label, value is array of conditions [ class => label ]

getDocImports()

Get all `DocImport`s

public static getDocImports() : mixed

getEmailText()

Get a single registered email texts. Returns an EmailTextReg object

public static getEmailText(mixed $code) : mixed
Parameters
$code : mixed

getEmailTexts()

Get all registered email texts. Returns an array of EmailTextReg objects

public static getEmailTexts() : mixed

getExtraPages()

Get all extra pages

public static getExtraPages() : mixed

getFeatureNamespace()

Return the namespace for a given feature

public static getFeatureNamespace(string $code) : string|null
Parameters
$code : string

The feature code. Only one in use at this time, 'users'

Return values
string|null —

Namespace

getFrontEndControllers()

Get all front-end controllers

public static getFrontEndControllers() : mixed

getLinkspecs()

Get all `LinkSpec`s

public static getLinkspecs() : mixed

getModerators()

Get all moderation classes

public static getModerators() : mixed

getModuleDirs()

Gets a list of paths to the active modules

public static getModuleDirs() : array<string|int, string>

use Modules::getModules()

Return values
array<string|int, string>

getPageattrs()

Get all extra pages

public static getPageattrs() : mixed

getRteLibraries()

Get all `RteLibrary`s

public static getRteLibraries() : mixed

getSearchHandlers()

Return list of SearchHandler objects

public static getSearchHandlers() : array<string|int, mixed>
Return values
array<string|int, mixed> —

List of SearchHandler instances

getSitemapGens()

Get a list of all sitemap.xml generator classes

public static getSitemapGens() : mixed

getSiteSettings()

Fetch list of registered site settings

public static getSiteSettings() : array<string|int, string>
Return values
array<string|int, string>

getWidgetTiles()

Return an array of widget tiles for a given widget area Each tile has four keys, 'name', 'icon', 'text', and 'widgets'.

public static getWidgetTiles(mixed $area_name) : array<string|int, mixed>
Parameters
$area_name : mixed
Return values
array<string|int, mixed>

hasFeature()

Is the given feature currently available?

public static hasFeature(string $code) : bool
Parameters
$code : string

The feature code. Only one in use at this time, 'users'

Return values
bool —

True if the feature is available

linkspec()

Register a LinkSpec

public static linkspec(mixed $name, mixed $label) : mixed
Parameters
$name : mixed
$label : mixed

moderator()

Register a moderation class

public static moderator(mixed $class_name) : mixed
Parameters
$class_name : mixed

module()

Register a module.

public static module(string $module) : void
Parameters
$module : string

class name

Tags
throws
InvalidArgumentException

modules()

Registers many modules.

public static modules(array<string|int, mixed> $names) : void
Parameters
$names : array<string|int, mixed>

A list of module class names

pageattr()

Register a type for an extra page

public static pageattr(string $name, string $label[, string $editor = 'Sprout\Helpers\AttrEditorTextbox' ]) : mixed
Parameters
$name : string

Name of the attribute (lowercase, no spaces), e.g 'sprout.lang'

$label : string

Human-readable label for the attribute, e.g. 'Language'

$editor : string = 'Sprout\Helpers\AttrEditorTextbox'

Class name of the AttrEditor used to edit the attribute. If not specified using a namespace, the 'Sprout\Helpers' namespace is assumed.

rteLibrary()

Register a RteLibrary class

public static rteLibrary(mixed $class_name) : mixed
Parameters
$class_name : mixed

searchHandler()

Register search handler

public static searchHandler(string $class, string $table[, array<string|int, mixed> $where = [] ]) : void
Parameters
$class : string

Controller to register which implements the FrontEndSearch interface. Must be fully namespaced.

$table : string

The name of the keywords table, e.g. page_keywords

$where : array<string|int, mixed> = []

Optional list of where clauses @see SearchHandler->addWhere()

services()

Register one or many services.

public static services(string|array<string|int, string>|array<string, array<string|int, mixed>> $services) : void
// Inline configurations.
Register::service([
   RemoteAuth::class => [
      'url' => 'http://example.com/auth',
   ],
   Trace::class => [
      'url' => 'http://example.com/trace',
   ],
]);

// Implicit configurations, loaded from 'services' (if required).
Register::service(RemoteAuth::class);

// Multiple services (implicit configurations).
Register::service([
   RemoteAuth::class,
   Trace::class,
]);
Parameters
$services : string|array<string|int, string>|array<string, array<string|int, mixed>>

class string or [class] or [class => config]

Tags
throws
Exception

sitemapGen()

Register a sitemap.xml generator class

public static sitemapGen(mixed $class_name) : mixed
Parameters
$class_name : mixed

templateVariable()

Register an helper to expose to twig templates via the 'sprout' namespace.

public static templateVariable(string $name, mixed $item) : void
Parameters
$name : string
$item : mixed

widgetTile()

Register a widget "tile", which is shown when adding widgets (content blocks) to a page

public static widgetTile(string $area_name, string $name, string $icon, string $text, array<string|int, mixed> $widgets) : mixed

If a tile already exists with that name, the widgets will be added to that tile

A list of available icons can be found in the file sprout/media/fonts/iconfont/demo.html

Parameters
$area_name : string

The area to register the tile (e.g. 'embedded')

$name : string

The name (title) of the tile

$icon : string

The icon class, sans the 'icon-' part. Examples: 'list', 'grid', 'home', etc.

$text : string

Explanation text. Plaintext.

$widgets : array<string|int, mixed>

Widgets to show as links, in format 'name' => 'label'

On this page

Search results