Controller
class Controller extends BlockController implements FileTrackableInterface, UsesFeatureInterface (View source)
Traits
Trait ApplicationAwareTrait A trait used with ApplicationAwareInterface
Properties
protected Application | $app | from ApplicationAwareTrait | |
protected | $helpers | from BlockController | |
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 | $btInterfaceWidth | ||
protected | $btInterfaceHeight | ||
protected | $btHasRendered | from BlockController | |
protected | $btCacheBlockRecord | ||
protected | $btCacheBlockOutput | from BlockController | |
protected | $btCacheBlockOutputLifetime | from BlockController | |
protected | $btCacheBlockOutputOnPost | from BlockController | |
protected | $btCacheBlockOutputForRegisteredUsers | from BlockController | |
protected | $bActionCID | from BlockController | |
protected | $btExportPageColumns | from BlockController | |
protected | $btExportFileColumns | ||
protected | $btExportPageTypeColumns | from BlockController | |
protected | $btExportPageFeedColumns | from BlockController | |
protected | $btExportFileFolderColumns | from BlockController | |
protected | $btWrapperClass | from BlockController | |
protected | $btDefaultSet | from BlockController | |
protected | $identifier | from BlockController | |
protected | $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 |
protected | $btExportTables | ||
protected int | $includeDownloadLink | ||
private Connection|null | $connection | ||
private Number|null | $numbers | ||
private ResolverManager|null | $urls |
Methods
Adds an item to the view's header. This item will then be automatically printed out before the
section of the page.Adds an item to the view's footer. This item will then be automatically printed out before the section of the page.
Should the action be executed? Override this method to answer something different than true.
Get the the helpers that will be be automatically sent to Views as variables.
Get the whole $_GET array or a specific querystring value.
Override this method to do something right before the view is rendered.
Get the whole $_POST array or a specific posted value.
Redirect the clients to a specific URL/page (specify path(s) as argument(s) of this function).
Build a response that redirects clients to a specific URL/page (specify path(s) as argument(s) of $args).
Perform an action of this controller (if shouldRunControllerTask returns true).
Get the whole $_REQUEST array or a specific requested value.
Installs the current block's DB xml file. If a block needs to do more than this, this should be overridden.
Validate the given request We check the the file exists and that the user has permissions, then we validate display choices.
Persist the block options.
Handle saving entries and display choices
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.
No description
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.
Gets the generic Block object attached to this controller's instance.
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.
Gets the Area object attached to this controller's instance.
Returns the name of the block type.
Returns the width of the block type's interface when presented in page.
Returns the height of the block type's interface when presented in page.
Returns the description of the block type.
Returns HTML that will be shown when a user wants help for a given block type.
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.
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.
if a the current BlockType supports inline edit or not.
if a the current BlockType supports inline add or not.
If true, container classes will not be wrapped around this block type in edit mode (if the theme in question supports a grid framework.
Returns a key/value array of strings that is used to translate items when used in javascript.
Return a list of features used by this block
Controller method for the view template
Controller method for the add template
Controller method for the edit template
Process an inputted json into a proper json object
Validate a given entry for saving Add errors to the error list to signal a validation failure.
Fetch entries associated with this block and output properly formatted arrays
Format a given entry row into the expected order and populate file details
Get the display options to show in the edit interface per image Override this method to easily add more options to the interface
Memoized database instance
Memoized database instance
Memoized url resolver
Loop over display choices for a given entry and validate them
Validate a given display choice Add errors to the error list to signal a validation failure.
Validate text display choices Add errors to the error list to signal a validation failure.
Validate select display choices Add errors to the error list to signal a validation failure.
No description
Details
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.
This function accept the same parameters as the requireAsset method of the ResponseAssetGroup.
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.
Array keys are the variable names, array values are the helper instances.
mixed
get(string|null $key = null, mixed $defaultValue = null)
Get the whole $_GET array or a specific querystring value.
getTask()
deprecated
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.
For instance, you can call $this->set('variableName', $variableValue) to send the view additional sets.
isPost()
deprecated
deprecated
No description
mixed
post($field = false, mixed $defaultValue = null)
Get the whole $_POST array or a specific posted value.
redirect()
deprecated
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
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
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.
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
}
```.
ErrorList|bool
validate($args)
Validate the given request We check the the file exists and that the user has permissions, then we validate display choices.
getBlockControllerData()
No description
protected
performSave(array $args, bool $loadExisting = false)
Persist the block options.
void
save(array<string,mixed> $args)
Handle saving entries and display choices
If validation for a display choice passes, it can be saved to the database. In order for a choice to be valid it must have a type that has a validator method and a key that exists in the getDisplayChoices method output.
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.
__wakeup()
No description
setBlockObject($b)
Sets the block object for this controller.
protected
load()
Loads the BlockRecord class based on its attribute names.
export(SimpleXMLElement $blockNode)
No description
getBlockTypeDatabaseTable()
No description
import($page, $arHandle, SimpleXMLElement $blockNode)
No description
protected array<string,mixed>
getImportData(SimpleXMLElement $blockNode, Page $page)
No description
importAdditionalData($b, $blockNode)
No description
setPassThruBlockController(PageController $controller)
No description
validateEditBlockPassThruAction(Block $b)
No description
validateComposerAddBlockPassThruAction(Type $type)
No description
int|null
getBlockTypeID()
No description
validateComposerEditBlockPassThruAction(Block $b)
No description
getPassThruActionAndParameters($parameters)
No description
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.
isValidControllerTask($method, $parameters = [])
No description
cacheBlockOutput()
No description
cacheBlockOutputForRegisteredUsers()
No description
cacheBlockOutputOnPost()
No description
getBlockTypeCacheOutputLifetime()
No description
getCollectionObject()
No description
field($fieldName)
No description
Block
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
Area
getAreaObject()
Gets the Area object attached to this controller's instance.
setAreaObject($a)
No description
uninstall()
No description
string
getBlockTypeName()
Returns the name of the block type.
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()
Returns the description of the block type.
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()
Return a list of features used by this block
view()
Controller method for the view template
add()
Controller method for the add template
edit()
Controller method for the edit template
protected array
processJson(array $args)
Process an inputted json into a proper json object
protected void
validateEntry(array $entry, ErrorList $errors)
Validate a given entry for saving Add errors to the error list to signal a validation failure.
private Generator
getEntries()
Fetch entries associated with this block and output properly formatted arrays
protected array
formatEntry(array $entry)
Format a given entry row into the expected order and populate file details
protected array
getDisplayChoices()
Get the display options to show in the edit interface per image Override this method to easily add more options to the interface
Note: You still need to manage validating and saving these values
private Connection
database()
Memoized database instance
private Number
numbersHelper()
Memoized database instance
private ResolverManager
urlResolver()
Memoized url resolver
protected void
validateDisplayChoices(array $entry, File $file, ErrorList $errors)
Loop over display choices for a given entry and validate them
protected void
validateDisplayChoice(File $file, string $key, array $choice, ErrorList $errors)
Validate a given display choice Add errors to the error list to signal a validation failure.
protected void
validateTextDisplayChoice(File $file, string $key, array $choice, array $expectedChoice, ErrorList $errors)
Validate text display choices Add errors to the error list to signal a validation failure.
protected void
validateSelectDisplayChoice(File $file, string $key, array $choice, array $expectedChoice, ErrorList $errors)
Validate select display choices Add errors to the error list to signal a validation failure.
array
getUsedFiles()
No description