Backend\Classes\ControllerBehavior

Source: ~/modules/backend/classes/ControllerBehavior.php

Extends:

Controller Behavior base class

Public properties

public string $assetPath

Specifies a path to the asset directory.

public array $vars

A list of variables to pass to the page.

public string $layout

Layout to use for the view.

public bool $suppressLayout

Prevents the use of a layout.

Show inherited public properties

Inherited public properties

Protected properties

protected array $config

Supplied configuration.

protected Backend\Classes\Controller $controller

Reference to the back end controller.

protected array $requiredProperties

Properties that must exist in the controller using this behavior.

protected array $assets

Collection of assets to display in the layout.

protected string $configPath

Specifies a path to the config directory.

protected string|array $viewPath

Specifies a path to the views directory.

protected string $layoutPath

Specifies a path to the layout directory.

Show inherited protected properties

Inherited protected properties

Public methods

public void __construct($controller)

Constructor.

Parameters
  • $controller

public void addCss(string $name, array $attributes=array())

Adds StyleSheet asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

Parameters
  • string $name - Specifies a path (URL) to the script.
  • array $attributes - Adds extra HTML attributes to the asset link.

public void addJs(string $name, array $attributes=array())

Adds JavaScript asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

Parameters
  • string $name - Specifies a path (URL) to the script.
  • array $attributes - Adds extra HTML attributes to the asset link.

public void addRss(string $name, array $attributes=array())

Adds an RSS link asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

Parameters
  • string $name - Specifies a path (URL) to the RSS channel
  • array $attributes - Adds extra HTML attributes to the asset link.

public void addViewPath(string|array $path)

Prepends a path on the available view path locations.

Parameters
  • string|array $path

public string combineAssets(array $assets, string $localPath='')

Run the provided assets through the Asset Combiner

Parameters
  • array $assets - Collection of assets
  • string $localPath - Prefix all assets with this path (optional)

public void flushAssets()

Disables the use, and subequent broadcast, of assets. This is useful to call during an AJAX request to speed things up. This method works by specifically targeting the hasAssetsDefined method.

public string getAssetPath(string $fileName, string $assetPath=NULL)

Locates a file based on it's definition. If the file starts with a forward slash, it will be returned in context of the application public path, otherwise it will be returned in context of the asset path.

Parameters
  • string $fileName - File to load.
  • string $assetPath - Explicitly define an asset path.

public array getAssetPaths()

Returns an array of all registered asset paths.

public string getConfig(string $name=NULL, mixed $default=NULL)

Safe accessor for configuration values.

Parameters
  • string $name - Config name, supports array names like "field[key]"
  • mixed $default - Default value if nothing is found

public string getConfigPath(string $fileName, mixed $configPath=NULL)

Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.

Parameters
  • string $fileName - File to load.
  • mixed $configPath - Explicitly define a config path.

public string getViewPath(string $fileName, mixed $viewPath=NULL)

Locates a file based on its definition. The file name can be prefixed with a symbol (~|$) to return in context of the application or plugin base path, otherwise it will be returned in context of this object view path.

Parameters
  • string $fileName - File to load.
  • mixed $viewPath - Explicitly define a view path.

public array getViewPaths()

Returns the active view path locations.

public string guessConfigPath(string $suffix='')

Guess the package path for the called class.

Parameters
  • string $suffix - An extra path to attach to the end

public string guessConfigPathFrom(string $class, string $suffix='')

Guess the package path from a specified class.

Parameters
  • string $class - Class to guess path from.
  • string $suffix - An extra path to attach to the end

public string guessViewPath(string $suffix='', bool $isPublic=false)

Guess the package path for the called class.

Parameters
  • string $suffix - An extra path to attach to the end
  • bool $isPublic - Returns public path instead of an absolute one

public string guessViewPathFrom(string $class, string $suffix='', bool $isPublic=false)

Guess the package path from a specified class.

Parameters
  • string $class - Class to guess path from.
  • string $suffix - An extra path to attach to the end
  • bool $isPublic - Returns public path instead of an absolute one

public bool hasAssetsDefined()

Returns true if assets any have been added.

public string localMakeFileContents(string $filePath, array $extraParams=array())

Includes a file path using output buffering. Ensures that vars are available.

Parameters
  • string $filePath - Absolute path to the view file.
  • array $extraParams - Parameters that should be available to the view.

public string makeAssets(string $type=NULL)

Outputs <link> and <script> tags to load assets previously added with addJs and addCss method calls

Parameters
  • string $type - Return an asset collection of a given type (css, rss, js) or null for all.

public array|stdClass makeConfig(array $configFile=array(), array $requiredConfig=array())

Reads the contents of the supplied file and applies it to this object.

Parameters
  • array $configFile
  • array $requiredConfig

public stdClass makeConfigFromArray(array $configArray=array())

Makes a config object from an array, making the first level keys properties a new object. Property values are converted to camelCase and are not set if one already exists.

Parameters
  • array $configArray - Config array.

public string makeFileContents(string $filePath, array $extraParams=array())

Makes all views in context of the controller, not the behavior.

Parameters
  • string $filePath - Absolute path to the view file.
  • array $extraParams - Parameters that should be available to the view.

public Backend\Classes\FormWidgetBase makeFormWidget(string $class, mixed $fieldConfig=array(), array $widgetConfig=array())

Makes a form widget object with the supplied form field and widget configuration.

Parameters
  • string $class - Widget class name
  • mixed $fieldConfig - A field name, an array of config or a FormField object.
  • array $widgetConfig - An array of config.

public mixed makeLayout(string $name=NULL, array $params=array(), bool $throwException=true)

Render a layout.

Parameters
  • string $name - Specifies the layout name. If this parameter is omitted, the $layout property will be used.
  • array $params - Parameter variables to pass to the view.
  • bool $throwException - Throw an exception if the layout is not found

public string makeLayoutPartial(string $partial, array $params=array())

Renders a layout partial

Parameters
  • string $partial - The view to load.
  • array $params - Parameter variables to pass to the view.

public mixed makePartial(string $partial, array $params=array(), bool $throwException=true)

Render a partial file contents located in the views folder.

Parameters
  • string $partial - The view to load.
  • array $params - Parameter variables to pass to the view.
  • bool $throwException - Throw an exception if the partial is not found.

public string makeView(string $view)

Loads a view with the name specified. Applies layout if its name is provided by the parent object. The view file must be situated in the views directory, and has the extension "htm".

Parameters
  • string $view - Specifies the view name, without extension. Eg: "index".

public string makeViewContent(string $contents, string $layout=NULL)

Renders supplied contents inside a layout.

Parameters
  • string $contents - The inner contents as a string.
  • string $layout - Specifies the layout name.

public Backend\Classes\WidgetBase makeWidget(string $class, array $widgetConfig=array())

Makes a widget object with the supplied configuration file.

Parameters
  • string $class - Widget class name
  • array $widgetConfig - An array of config.

public stdClass mergeConfig(mixed $configA, mixed $configB)

Merges two configuration sources, either prepared or not, and returns them as a single configuration object.

Parameters
  • mixed $configA
  • mixed $configB

public void resetSession()

Resets all session data related to this widget.

public void setConfig(mixed $config, array $required=array())

Sets the configuration values

Parameters
  • mixed $config - Config object or array
  • array $required - Required config items

Show inherited public methods

Inherited public methods

Protected methods

protected bool controllerMethodExists(string $methodName)

Returns true in case if a specified method exists in the extended controller.

Parameters
  • string $methodName - Specifies the method name

protected string getAssetEntryBuildPath(array $asset)

Internal helper, attaches a build code to an asset path

Parameters
  • array $asset - Stored asset array

protected string getAssetScheme(string $asset)

Internal helper, get asset scheme

Parameters
  • string $asset - Specifies a path (URL) to the asset.

protected string getSession(string $key=NULL, string $default=NULL)

Retrieves a widget related key/value pair from session data.

Parameters
  • string $key - Unique key for the data store.
  • string $default - A default value to use when value is not found.

protected void handleViewException(Exception $e, int $obLevel)

Handle a view exception.

Parameters
  • Exception $e
  • int $obLevel

protected void hideAction(mixed $methodName)

Protects a public method from being available as an controller action. These methods could be defined in a controller to override a behavior default action. Such methods should be defined as public, to allow the behavior object to access it. By default public methods of a controller are considered as actions. To prevent this occurrence, methods should be hidden by using this method.

Parameters
  • mixed $methodName - Specifies a method name.

protected string makeSessionId()

Returns a unique session identifier for this widget and controller action.

protected void putSession(string $key, string $value)

Saves a widget related key/value pair in to session data.

Parameters
  • string $key - Unique key for the data store.
  • string $value - The value to store.

protected void removeDuplicates()

Removes duplicate assets from the entire collection.

Show inherited protected methods

Inherited protected methods