class Controller extends BlockController implements UsesFeatureInterface (View source)

The controller for the Auto-Nav block.

Traits

Trait ApplicationAwareTrait A trait used with ApplicationAwareInterface

Properties

protected Application $app from  ApplicationAwareTrait
protected string[] $helpers
protected array $sets

The values to be sent to views.

from  AbstractController
protected string|null $action

The action to be performed.

from  AbstractController
protected Request|null $request

The current request instance.

from  AbstractController
protected array|null $parameters

The action parameters.

from  AbstractController
$headerItems from  BlockController
$blockViewRenderOverride from  BlockController
protected $record from  BlockController
protected $block from  BlockController
protected $bID from  BlockController
protected $btDescription from  BlockController
protected $btName from  BlockController
protected $btHandle from  BlockController
protected $btIsInternal from  BlockController
protected $btSupportsInlineAdd from  BlockController
protected $btIgnorePageThemeGridFrameworkContainer from  BlockController
protected $btSupportsInlineEdit from  BlockController
protected $btCopyWhenPropagate from  BlockController
protected $btIncludeAll from  BlockController
protected int $btInterfaceWidth
protected int $btInterfaceHeight
protected $btHasRendered from  BlockController
protected bool $btCacheBlockRecord
protected bool $btCacheBlockOutput
protected int $btCacheBlockOutputLifetime
protected bool $btCacheBlockOutputOnPost
protected bool $btCacheBlockOutputForRegisteredUsers
protected $bActionCID from  BlockController
protected string[] $btExportPageColumns
protected $btExportFileColumns from  BlockController
protected $btExportPageTypeColumns from  BlockController
protected $btExportPageFeedColumns from  BlockController
protected $btExportFileFolderColumns from  BlockController
protected string $btWrapperClass
protected $btDefaultSet from  BlockController
protected $identifier from  BlockController
protected string $btTable
protected $btID from  BlockController
static internal $btTitleFormats from  BlockController
protected bool $supportSavingNullValues

Set this to true if the data sent to the save/performSave methods can contain NULL values that should be persisted.

from  BlockController
Page|null $collection
NavItem[] $navArray
int[] $cParentIDArray
string $displayPages
int|null $displayPagesCID
int $displayPagesIncludeSelf
string $displaySubPages
string $displaySubPageLevels
int $displaySubPageLevelsNum
string $orderBy
int $displayUnavailablePages
bool $haveRetrievedSelf
bool $haveRetrievedSelfPlus1
bool $displayUnapproved
bool $ignoreExcludeNav
int|null $cParentID
protected int|null $homePageID
protected bool $includeParentItem
protected int|null $cID

Methods

setApplication(Application $app)

Setter method for the application

__construct(BlockType $obj = null)

Instantiates the block controller.

Request
getRequest()

Get the current request instance.

setRequest(Request $request)

Set the current request instance.

requireAsset()

Add an asset required in views.

addHeaderItem(string $item)

Adds an item to the view's header. This item will then be automatically printed out before the section of the page.

addFooterItem(string $item)

Adds an item to the view's footer. This item will then be automatically printed out before the section of the page.

set(string $key, mixed $val)

Set a value to be sent to the view.

array
getSets()

Get the values to be sent to views.

bool
shouldRunControllerTask()

Should the action be executed? Override this method to answer something different than true.

array
getHelperObjects()

Get the the helpers that will be be automatically sent to Views as variables.

mixed
get(string|null $key = null, mixed $defaultValue = null)

Get the whole $_GET array or a specific querystring value.

getTask() deprecated

No description

string|null
getAction()

Get the action to be performed.

array|null
getParameters()

Get the action parameters.

on_start()

Override this method to perform controller initializations.

on_before_render()

Override this method to do something right before the view is rendered.

isPost() deprecated

No description

mixed
post($field = false, mixed $defaultValue = null)

Get the whole $_POST array or a specific posted value.

redirect() deprecated

Redirect the clients to a specific URL/page (specify path(s) as argument(s) of this function).

RedirectResponse
buildRedirect(array|string|UrlInterface $destination, int $httpResponseCode = Response::HTTP_FOUND)

Build a response that redirects clients to a specific URL/page (specify path(s) as argument(s) of $args).

runTask(mixed $action, mixed $parameters) deprecated

No description

mixed
runAction(string $action, array $parameters = [])

Perform an action of this controller (if shouldRunControllerTask returns true).

mixed
request(string|null $key = null)

Get the whole $_REQUEST array or a specific requested value.

executeCommand(mixed $command)

Dispatches a command to the command bus.

dispatchBatch(Batch $batch)

No description

getBlockTypeInSetName()

No description

getIdentifier()

No description

mixed
install(string $path)

Installs the current block's DB xml file. If a block needs to do more than this, this should be overridden.

render(string $view)

Renders a view in the block's folder.

ErrorList|bool
validate($args)

Used to validate a blocks data before saving to the database Generally should return an empty ErrorList if valid Custom Packages may return a boolean value

getBlockControllerData()

No description

performSave(array $args, bool $loadExisting = false)

Persist the block options.

void
save(array<string,mixed> $args)

No description

cacheBlockRecord()

No description

getPermissionsObject() deprecated

No description

getBlockTypeDefaultSet()

No description

getPermissionObject()

Gets the permissions object for this controller's block.

duplicate($newBID)

Automatically run when a block is duplicated. This most likely happens when a block is edited: a block is first duplicated, and then presented to the user to make changes.

__wakeup()

No description

setBlockObject($b)

Sets the block object for this controller.

load()

Loads the BlockRecord class based on its attribute names.

export(SimpleXMLElement $blockNode)

No description

import($page, $arHandle, SimpleXMLElement $blockNode)

No description

array<string,mixed>
getImportData(SimpleXMLElement $blockNode, Page $page)

No description

importAdditionalData($b, $blockNode)

No description

setPassThruBlockController(PageController $controller)

No description

int|null
getBlockTypeID()

No description

getPassThruActionAndParameters($parameters)

No description

getActionURL($task)

Creates a URL that can be posted or navigated to that, when done so, will automatically run the corresponding method inside the block's controller.

isValidControllerTask($method, $parameters = [])

No description

cacheBlockOutput()

No description

cacheBlockOutputOnPost()

No description

getCollectionObject()

No description

field($fieldName)

No description

getBlockObject()

Gets the generic Block object attached to this controller's instance.

void
delete()

Automatically run when a block is deleted. This removes the special data from the block's specific database table. If a block needs to do more than this this method should be overridden.

outputAutoHeaderItems()

No description

registerViewAssets($outputContent = '')

No description

setupAndRun($method)

No description

getAreaObject()

Gets the Area object attached to this controller's instance.

setAreaObject($a)

No description

uninstall()

No description

string
getBlockTypeName()

No description

int
getInterfaceWidth()

Returns the width of the block type's interface when presented in page.

int
getInterfaceHeight()

Returns the height of the block type's interface when presented in page.

string
getBlockTypeDescription()

No description

getBlockTypeHelp()

Returns HTML that will be shown when a user wants help for a given block type.

isCopiedWhenPropagated()

No description

bool
includeAll()

Returns whether this block type is included in all versions. Default is false - block types are typically versioned but sometimes it makes sense not to do so.

bool
isBlockTypeInternal()

Returns whether this block type is internal to Concrete. If it's internal it's not displayed in the front end interface. Examples include the LibraryFile block.

bool
supportsInlineEdit()

if a the current BlockType supports inline edit or not.

bool
supportsInlineAdd()

if a the current BlockType supports inline add or not.

bool
ignorePageThemeGridFrameworkContainer()

If true, container classes will not be wrapped around this block type in edit mode (if the theme in question supports a grid framework.

getJavaScriptStrings()

Returns a key/value array of strings that is used to translate items when used in javascript.

array
getRequiredFeatures()

No description

array
getContent()

No description

array
getChildPages(Page $c)

No description

getNavItems(bool $ignore_exclude_nav = false)

New and improved version of "generateNav()" function.

array
generateNav()

This function is used by the getNavItems() method to generate the raw "pre-processed" nav items array.

int
getParentParentID()

heh. probably should've gone the simpler route and named this getGrandparentID().

int|null
getParentAtLevel(int $level)

No description

void
populateParentIDArray(int $cID)

Pupulates the $cParentIDArray instance property.

void
getNavigationArray(int $cParentID, string $orderBy, int $currentLevel)

No description

mixed
excludeFromNavViaAttribute(Page $c)

No description

action_preview_pane()

No description

bool|null
shouldIncludeParentItem()

No description

void
setIncludeParentItem(bool $includeParentItem)

No description

bool
displayPage(Page $tc)

No description

Details

setApplication(Application $app)

Setter method for the application

Parameters

Application $app

__construct(BlockType $obj = null)

Instantiates the block controller.

Parameters

BlockType $obj

|Block $obj

Request getRequest()

Get the current request instance.

Return Value

Request

setRequest(Request $request)

Set the current request instance.

Parameters

Request $request

requireAsset()

Add an asset required in views.

This function accept the same parameters as the requireAsset method of the ResponseAssetGroup.

See also

ResponseAssetGroup::requireAsset

addHeaderItem(string $item)

Adds an item to the view's header. This item will then be automatically printed out before the section of the page.

Parameters

string $item

addFooterItem(string $item)

Adds an item to the view's footer. This item will then be automatically printed out before the section of the page.

Parameters

string $item

set(string $key, mixed $val)

Set a value to be sent to the view.

Parameters

string $key

The name of the value

mixed $val

The value

array getSets()

Get the values to be sent to views.

Return Value

array

bool shouldRunControllerTask()

Should the action be executed? Override this method to answer something different than true.

Return Value

bool

array getHelperObjects()

Get the the helpers that will be be automatically sent to Views as variables.

Array keys are the variable names, array values are the helper instances.

Return Value

array

mixed get(string|null $key = null, mixed $defaultValue = null)

Get the whole $_GET array or a specific querystring value.

Parameters

string|null $key

set to null to get the whole $_GET array, or a string to get a specific value in the controller sets or from the querystring parameters

mixed $defaultValue

what to return if $key is specified but it does not exist neither in the sets nor in the querystring

Return Value

mixed

getTask() deprecated

deprecated use the getAction() method

No description

string|null getAction()

Get the action to be performed.

Return Value

string|null

array|null getParameters()

Get the action parameters.

Return Value

array|null

on_start()

Override this method to perform controller initializations.

on_before_render()

Override this method to do something right before the view is rendered.

For instance, you can call $this->set('variableName', $variableValue) to send the view additional sets.

isPost() deprecated

deprecated Use $this->getRequest()->isPost();

No description

mixed post($field = false, mixed $defaultValue = null)

Get the whole $_POST array or a specific posted value.

Parameters

$field
mixed $defaultValue

what to return if $key is specified but it does not exist in the $_POST

Return Value

mixed

redirect() deprecated

deprecated you should return a Response instance from your methods

Redirect the clients to a specific URL/page (specify path(s) as argument(s) of this function).

RedirectResponse buildRedirect(array|string|UrlInterface $destination, int $httpResponseCode = Response::HTTP_FOUND)

Build a response that redirects clients to a specific URL/page (specify path(s) as argument(s) of $args).

Parameters

array|string|UrlInterface $destination

use an Url object to specify the destination URL, or a string/array of strings to build the URL with the resolver

int $httpResponseCode

the HTTP response code

Return Value

RedirectResponse

runTask(mixed $action, mixed $parameters) deprecated

deprecated use the runAction method

No description

Parameters

mixed $action
mixed $parameters

mixed runAction(string $action, array $parameters = [])

Perform an action of this controller (if shouldRunControllerTask returns true).

Parameters

string $action

the action to be performed

array $parameters

the action parameters

Return Value

mixed

in case the action is executed, you'll receive the result of the action, or NULL otherwise

mixed request(string|null $key = null)

Get the whole $_REQUEST array or a specific requested value.

Parameters

string|null $key

set to null to get the whole $_REQUEST array, or a string to get a specific value in $_GET or in $_POST

Return Value

mixed

executeCommand(mixed $command)

Dispatches a command to the command bus.

Parameters

mixed $command

dispatchBatch(Batch $batch)

No description

Parameters

Batch $batch

getBlockTypeInSetName()

No description

getBlockTypeExportPageColumns()

No description

getIdentifier()

No description

getBlockTypeWrapperClass()

No description

mixed install(string $path)

Installs the current block's DB xml file. If a block needs to do more than this, this should be overridden.


public function install($path) {
    $this->doMySpecialInstallMethod();
    $this->doSecondSpecialInstallMethod();
    parent::install($path);
}
```.

There are several different possible return values:
 Returns FALSE if $btTable is set but no db.xml file exists.
 Otherwise returns object with two properties: ->result (a boolean), and ->message (a string).
 If ->result is true, the installation was successful
 (although the db.xml file might only have one field declared which will cause C5 to have problems later on, so you you will want to check for that separately).
 If ->result is false, the installation failed and you can check ->message for the explanation
 (usually -- sometimes ->message will be blank, in which case there's either a malformed db.xml file or an "unknown database error").
See concrete/models/block_types.php::doInstallBlockType() for usage example.

Parameters

string $path

Return Value

mixed

boolean or object having ->result (boolean) and ->message (string) properties

render(string $view)

Renders a view in the block's folder.


public function view() { // The view() method is automatically run when a block is viewed
    $this->render("other_special_view"); // don't use .php
}
```.

Parameters

string $view

ErrorList|bool validate($args)

Used to validate a blocks data before saving to the database Generally should return an empty ErrorList if valid Custom Packages may return a boolean value

Parameters

$args array|string|null

Return Value

ErrorList|bool

getBlockControllerData()

No description

protected performSave(array $args, bool $loadExisting = false)

Persist the block options.

Parameters

array $args

An array that contains the block options

bool $loadExisting

Shall we initialize the record to be saved with the current data?

void save(array<string,mixed> $args)

No description

Parameters

array<string,mixed> $args

Return Value

void

cacheBlockRecord()

No description

getPermissionsObject() deprecated

deprecated

No description

getBlockTypeDefaultSet()

No description

getPermissionObject()

Gets the permissions object for this controller's block.

BlockRecord duplicate($newBID)

Automatically run when a block is duplicated. This most likely happens when a block is edited: a block is first duplicated, and then presented to the user to make changes.

Parameters

$newBID

Return Value

BlockRecord

| null $newInstance

__wakeup()

No description

setBlockObject($b)

Sets the block object for this controller.

Parameters

$b

protected load()

Loads the BlockRecord class based on its attribute names.

export(SimpleXMLElement $blockNode)

No description

Parameters

SimpleXMLElement $blockNode

getBlockTypeDatabaseTable()

No description

import($page, $arHandle, SimpleXMLElement $blockNode)

No description

Parameters

$page
$arHandle
SimpleXMLElement $blockNode

protected array<string,mixed> getImportData(SimpleXMLElement $blockNode, Page $page)

No description

Parameters

SimpleXMLElement $blockNode
Page $page

Return Value

array<string,mixed>

protected importAdditionalData($b, $blockNode)

No description

Parameters

$b
$blockNode

setPassThruBlockController(PageController $controller)

No description

Parameters

PageController $controller

validateAddBlockPassThruAction(Checker $ap, BlockType $bt)

No description

Parameters

Checker $ap
BlockType $bt

validateEditBlockPassThruAction(Block $b)

No description

Parameters

Block $b

validateComposerAddBlockPassThruAction(Type $type)

No description

Parameters

Type $type

int|null getBlockTypeID()

No description

Return Value

int|null

validateComposerEditBlockPassThruAction(Block $b)

No description

Parameters

Block $b

getPassThruActionAndParameters($parameters)

No description

Parameters

$parameters

UrlImmutable|null getActionURL($task)

Creates a URL that can be posted or navigated to that, when done so, will automatically run the corresponding method inside the block's controller.

It can also be used to perform system operations, accordingly to the current action.

Parameters

$task

Return Value

UrlImmutable|null

Return NULL in case of problems

isValidControllerTask($method, $parameters = [])

No description

Parameters

$method
$parameters

cacheBlockOutput()

No description

cacheBlockOutputForRegisteredUsers()

No description

cacheBlockOutputOnPost()

No description

getBlockTypeCacheOutputLifetime()

No description

getCollectionObject()

No description

field($fieldName)

No description

Parameters

$fieldName

Block getBlockObject()

Gets the generic Block object attached to this controller's instance.

Return Value

Block $b

void delete()

Automatically run when a block is deleted. This removes the special data from the block's specific database table. If a block needs to do more than this this method should be overridden.

Return Value

void

outputAutoHeaderItems()

No description

registerViewAssets($outputContent = '')

No description

Parameters

$outputContent

setupAndRun($method)

No description

Parameters

$method

Area getAreaObject()

Gets the Area object attached to this controller's instance.

Return Value

Area $a

setAreaObject($a)

No description

Parameters

$a

uninstall()

No description

Make block's uninstallable

string getBlockTypeName()

No description

Return Value

string $btName

int getInterfaceWidth()

Returns the width of the block type's interface when presented in page.

Return Value

int

int getInterfaceHeight()

Returns the height of the block type's interface when presented in page.

Return Value

int

string getBlockTypeDescription()

No description

Return Value

string

getBlockTypeHelp()

Returns HTML that will be shown when a user wants help for a given block type.

isCopiedWhenPropagated()

No description

bool includeAll()

Returns whether this block type is included in all versions. Default is false - block types are typically versioned but sometimes it makes sense not to do so.

Return Value

bool

bool isBlockTypeInternal()

Returns whether this block type is internal to Concrete. If it's internal it's not displayed in the front end interface. Examples include the LibraryFile block.

Return Value

bool

bool supportsInlineEdit()

if a the current BlockType supports inline edit or not.

Return Value

bool

bool supportsInlineAdd()

if a the current BlockType supports inline add or not.

Return Value

bool

bool ignorePageThemeGridFrameworkContainer()

If true, container classes will not be wrapped around this block type in edit mode (if the theme in question supports a grid framework.

Return Value

bool

getJavaScriptStrings()

Returns a key/value array of strings that is used to translate items when used in javascript.

array getRequiredFeatures()

No description

Return Value

array

Feature handles

array getContent()

No description

Return Value

array

array getChildPages(Page $c)

No description

Parameters

Page $c

Return Value

array

stdClass[] getNavItems(bool $ignore_exclude_nav = false)

New and improved version of "generateNav()" function.

Use this unless you need to maintain backwards compatibility with older custom templates.

Pass in TRUE for the $ignore_exclude_nav arg if you don't want to exclude any pages (for both the "exclude_nav" and "exclude_subpages_from_nav" attribute). This is useful for breadcrumb nav menus, for example.

Historical note: this must stay a function that gets called by the view templates (as opposed to just having the view() method set the variables) because we need to maintain the generateNav() function for backwards compatibility with older custom templates... and that function unfortunately has side-effects so it cannot be called more than once per request (otherwise there will be duplicate items in the nav menu).

Parameters

bool $ignore_exclude_nav

Return Value

stdClass[]

array generateNav()

This function is used by the getNavItems() method to generate the raw "pre-processed" nav items array.

It also must exist as a separate function to preserve backwards-compatibility with older autonav templates. Warning: this function has side-effects -- if this gets called twice, items will be duplicated in the nav structure!

Return Value

array

Exceptions

Exception
Exception
BindingResolutionException

int getParentParentID()

heh. probably should've gone the simpler route and named this getGrandparentID().

Return Value

int

int|null getParentAtLevel(int $level)

No description

Parameters

int $level

Return Value

int|null

void populateParentIDArray(int $cID)

Pupulates the $cParentIDArray instance property.

Parameters

int $cID

the collection id

Return Value

void

void getNavigationArray(int $cParentID, string $orderBy, int $currentLevel)

No description

Parameters

int $cParentID
string $orderBy
int $currentLevel

Return Value

void

Exceptions

BindingResolutionException
Exception
Exception

mixed excludeFromNavViaAttribute(Page $c)

No description

Parameters

Page $c

Return Value

mixed

Response action_preview_pane()

No description

Return Value

Response

Exceptions

UserMessageException
BindingResolutionException

bool|null shouldIncludeParentItem()

No description

Return Value

bool|null

void setIncludeParentItem(bool $includeParentItem)

No description

Parameters

bool $includeParentItem

Return Value

void

protected bool displayPage(Page $tc)

No description

Parameters

Page $tc

Return Value

bool