com\setasign\SetaSite\BlockManager
PageBlockManager Class BlockManager
File: /SetaSite/src/BlockManager/PageBlockManager.php
An extended block manager with the option to declare blocks as final and use imported "fromTemplate" flag.
Class hierarchy
Summary
Methods
- __construct()
- addBlock()
- exportBlocks()
- exportBlocksWithoutOwnFinalBlocks()
- getBlock()
- getBlockData()
- getBlockOverview()
- getBlockRenderOrder()
- getFinalBlocks()
- getPlaceholder()
- getPlaceholderBlocks()
- hasBlockName()
- importBlocks()
- isFinalBlock()
- isFinalBlockBefore()
- isFinalPlaceholder()
- isValid()
- moveBlock()
- removeBlock()
- removeBlocksFromAllPlaceholders()
- removeBlocksFromPlaceholder()
- renameExistingBlocks()
- render()
- renderBlock()
- reorder()
- replaceFinalBlocksFromTemplate()
- resolveBlockManager()
- resolveName()
- setBlockData()
- setBlockName()
- setData()
- setFinal()
- setReadOnly()
- setRenderOrder()
- setVisibility()
- sortBlockOverview()
Constants
FINAL_BOTTOM
FINAL_NO
FINAL_TOP
FINAL_YES
Properties
$blockInstances
$blockParent
$factory
$pageSettings
Methods
__construct()
\com\setasign\SetaSite\Page\PageSettings $pageSettings,
\com\setasign\SetaSite\Block\BlockParent\BlockParentInterface $blockParent
Parameters
- $factory: \com\setasign\SetaSite\Block\BlockFactory
- $pageSettings: \com\setasign\SetaSite\Page\PageSettings
- $blockParent: \com\setasign\SetaSite\Block\BlockParent\BlockParentInterface
addBlock()
string $placeholder,
string $blockName,
int $renderOrder = 0,
bool $visibility = true,
?string $beforeBlockName = null
Adds a block to a specific placeholder with an unique blockName(for this page).
Parameters
- $block: array{type: string, data: array}
- $placeholder: string
- $blockName: string
- $renderOrder: int
- $visibility: bool
- $beforeBlockName: ?string
Cannot be a block fromTemplate!
Exceptions
Throws UnknownBlockException
Throws BlockFinalException
Throws \InvalidArgumentException
getBlock()
Returns the block object of $blockName
Parameters
- $blockName: string
Exceptions
Throws UnknownBlockException
getBlockData()
Returns an array with the relevant data for $blockName
Parameters
- $blockName: string
Exceptions
Throws UnknownBlockException
getBlockOverview()
You need to use setPlaceholders before you use this method.
Parameters
- $placeholders: array
Exceptions
Throws UnknownBlockException
getPlaceholder()
Returns the placeholder of the block
Parameters
- $blockName: string
Exceptions
Throws UnknownBlockException
getPlaceholderBlocks()
Returns the block names of all blocks in the given placeholder.
Parameters
- $placeholder: string
hasBlockName()
Checks whether the blockname exist.
Parameters
- $name: string
Name of the block.
- $placeholder: ?string
Check whether the blockname exists in the placeholder.
importBlocks()
isFinalBlock()
Checks whether the block is final.
Note: This is only true if the block is fromTemplate.
Parameters
- $blockName: string
Exceptions
Throws UnknownBlockException
isFinalBlockBefore()
Checks whether the position before $beforeBlockName is final.
If $beforeBlockName === null the last block of the placeholder will be checked - so it will check for FINAL_YES and FINAL_BOTTOM.
Note: This is only true if the block is fromTemplate.
Parameters
- $placeholder: string
- $beforeBlockName: string
Cannot be a block fromTemplate!
isFinalPlaceholder()
Checks whether the placeholder is final-yes.
Note: This is only true if the block is fromTemplate.
Parameters
- $placeholder: string
isValid()
moveBlock()
string $targetPlaceholder,
?string $beforeBlockName = null
Moves the block to the target placeholder before a block.
On move the block loses it's final state.
If $beforeBlockName is null, the block will be moved to the last position.
Parameters
- $blockName: string
- $targetPlaceholder: string
- $beforeBlockName: ?string
Exceptions
Throws UnknownBlockException
Throws BlockFinalException
removeBlock()
Removes the block
Parameters
- $blockName: string
Exceptions
Throws UnknownBlockException
Throws BlockFinalException
removeBlocksFromAllPlaceholders()
Removes all blocks from all placeholders. It doesn't matter whether these placeholders exist in the template.
renameExistingBlocks()
render()
Parameters
- $placeholders: array
- $params: array
Exceptions
renderBlock()
Parameters
- $blockName: string
- $params: array
Exceptions
Throws \com\setasign\SetaSite\Exception
Throws \com\setasign\SetaSite\Block\ForceResponseException
Throws \com\setasign\SetaSite\HttpErrorException
Throws UnknownBlockException
reorder()
Parameters
- $placeholder: string
- $newOutputOrder: array
Exceptions
Throws BlockFinalException If one of the reordered blocks is final and can't be moved.
Throws UnknownBlockException
replaceFinalBlocksFromTemplate()
resolveBlockManager()
Resolves a placeholder path without a block name
Parameters
- $name: string
Exceptions
Throws \com\setasign\SetaSite\Exception
Throws UnknownBlockException
resolveName()
Resolves the name of a block or placeholder and returns the blockManager and the name of the last element
Parameters
- $name: string
Exceptions
Throws \com\setasign\SetaSite\Exception
Throws UnknownBlockException
setBlockData()
Sets the blockData.
Parameters
- $blockName: string
- $blockData: array
Exceptions
Throws UnknownBlockException
Throws BlockFinalException If the block is final.
setBlockName()
Sets the blockname
Parameters
- $oldName: string
- $newName: string
Exceptions
Throws UnknownBlockException If $oldName is unknown or $newName is already existing.
Throws BlockFinalException If the block is final.
setData()
Sets all data
Only for internal use!
Parameters
- $data: array[]
Exceptions
Throws \InvalidArgumentException
setFinal()
Sets the final flag for a block.
Parameters
- $blockName: string
- $final: int
Exceptions
Throws UnknownBlockException
Throws BlockFinalException If the block is final.
setRenderOrder()
Sets the render order.
Parameters
- $blockName: string
- $renderOrder: int
Exceptions
Throws UnknownBlockException
Throws BlockFinalException If the block is final.
setVisibility()
Sets the visibility.
Parameters
- $blockName: string
- $visible: bool
Exceptions
Throws UnknownBlockException
Throws BlockFinalException If the block is final.
