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

Constants

FINAL_BOTTOM

public const PageBlockManager::FINAL_BOTTOM = 3

FINAL_NO

public const PageBlockManager::FINAL_NO = 0

FINAL_TOP

public const PageBlockManager::FINAL_TOP = 2

FINAL_YES

public const PageBlockManager::FINAL_YES = 1

Properties

$blockParent

$blocks

protected array SimpleBlockManager::$blocks = array()

$factory

$order

protected array[] SimpleBlockManager::$order = array()

$pageSettings

$readOnly

protected bool SimpleBlockManager::$readOnly = false

Methods

addBlock()

public PageBlockManager::addBlock (
array{type: string, data: array} $block,
string $placeholder,
string $blockName,
int $renderOrder = 0,
bool $visibility = true,
?string $beforeBlockName = null
): void

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

exportBlocks()

public SimpleBlockManager::exportBlocks (
void
): array

Returns all blocks which aren't from templates.

exportBlocksWithoutOwnFinalBlocks()

getBlock()

Returns the block object of $blockName

Parameters
$blockName : string
 
Exceptions

Throws UnknownBlockException

getBlockData()

public SimpleBlockManager::getBlockData (
string $blockName
): array

Returns an array with the relevant data for $blockName

Parameters
$blockName : string
 
Exceptions

Throws UnknownBlockException

getBlockOverview()

public PageBlockManager::getBlockOverview (
array $placeholders
): array

You need to use setPlaceholders before you use this method.

Parameters
$placeholders : array
 
Exceptions

Throws UnknownBlockException

getBlockRenderOrder()

public SimpleBlockManager::getBlockRenderOrder (
void
): array

Returns all blocks in the render order

getFinalBlocks()

public PageBlockManager::getFinalBlocks (
void
): array

getPlaceholder()

public SimpleBlockManager::getPlaceholder (
string $blockName
): string

Returns the placeholder of the block

Parameters
$blockName : string
 
Exceptions

Throws UnknownBlockException

getPlaceholderBlocks()

public SimpleBlockManager::getPlaceholderBlocks (
string $placeholder
): array

Returns the block names of all blocks in the given placeholder.

Parameters
$placeholder : string
 

hasBlockName()

public SimpleBlockManager::hasBlockName (
string $name,
?string $placeholder = null
): bool

Checks whether the blockname exist.

Parameters
$name : string

Name of the block.

$placeholder : ?string

Check whether the blockname exists in the placeholder.

importBlocks()

public PageBlockManager::importBlocks (
array $blocks
): void
Parameters
$blocks : array
 
Exceptions

Throws BlockFinalException

Throws UnknownBlockException

isFinalBlock()

public PageBlockManager::isFinalBlock (
string $blockName
): bool

Checks whether the block is final.

Note: This is only true if the block is fromTemplate.

Parameters
$blockName : string
 
Exceptions

Throws UnknownBlockException

isFinalBlockBefore()

public PageBlockManager::isFinalBlockBefore (
string $placeholder,
string $beforeBlockName
): bool

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()

public PageBlockManager::isFinalPlaceholder (
string $placeholder
): bool

Checks whether the placeholder is final-yes.

Note: This is only true if the block is fromTemplate.

Parameters
$placeholder : string
 

isValid()

public SimpleBlockManager::isValid (
?array &$result = array ( )
): bool
Parameters
$result : ?array
 
Exceptions

Throws UnknownBlockException

moveBlock()

public PageBlockManager::moveBlock (
string $blockName,
string $targetPlaceholder,
?string $beforeBlockName = null
): void

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()

public PageBlockManager::removeBlock (
string $blockName
): void

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.

removeBlocksFromPlaceholder()

public PageBlockManager::removeBlocksFromPlaceholder (
string $placeholder
): void

Removes all blocks from a placeholder.

Parameters
$placeholder : string
 

renameExistingBlocks()

private PageBlockManager::renameExistingBlocks (
string $blockName
): ?string
Parameters
$blockName : string
 
Exceptions

Throws BlockFinalException

Throws UnknownBlockException

render()

public SimpleBlockManager::render (
array $placeholders,
array $params
): array
Parameters
$placeholders : array
 
$params : array
 
Exceptions

Throws \com\setasign\SetaSite\Block\ForceResponseException

Throws \com\setasign\SetaSite\HttpErrorException

renderBlock()

protected SimpleBlockManager::renderBlock (
string $blockName,
array $params
): string
Parameters
$blockName : string
 
$params : array
 
Exceptions

Throws \com\setasign\SetaSite\Exception

Throws \com\setasign\SetaSite\Block\ForceResponseException

Throws \com\setasign\SetaSite\HttpErrorException

Throws UnknownBlockException

Throws \com\setasign\SetaSite\Block\BlockRenderException

reorder()

public PageBlockManager::reorder (
string $placeholder,
array $newOutputOrder
): void
Parameters
$placeholder : string
 
$newOutputOrder : array
 
Exceptions

Throws BlockFinalException If one of the reordered blocks is final and can't be moved.

Throws UnknownBlockException

replaceFinalBlocksFromTemplate()

public PageBlockManager::replaceFinalBlocksFromTemplate (
array $templateBlocks
): void
Parameters
$templateBlocks : array
 
Exceptions

Throws BlockFinalException

Throws UnknownBlockException

resolveName()

public PageBlockManager::resolveName (
string $name
): array

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()

public PageBlockManager::setBlockData (
string $blockName,
array $blockData
): void

Sets the blockData.

Parameters
$blockName : string
 
$blockData : array
 
Exceptions

Throws UnknownBlockException

Throws BlockFinalException If the block is final.

setBlockName()

public PageBlockManager::setBlockName (
string $oldName,
string $newName
): void

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()

public SimpleBlockManager::setData (
array[] $data
): void

Sets all data

Only for internal use!

Parameters
$data : array[]
 
Exceptions

Throws \InvalidArgumentException

setFinal()

public PageBlockManager::setFinal (
string $blockName,
int $final
): void

Sets the final flag for a block.

Parameters
$blockName : string
 
$final : int
 
Exceptions

Throws UnknownBlockException

Throws BlockFinalException If the block is final.

setReadOnly()

public PageBlockManager::setReadOnly (
void
): void

setRenderOrder()

public PageBlockManager::setRenderOrder (
string $blockName,
int $renderOrder
): void

Sets the render order.

Parameters
$blockName : string
 
$renderOrder : int
 
Exceptions

Throws UnknownBlockException

Throws BlockFinalException If the block is final.

setVisibility()

public PageBlockManager::setVisibility (
string $blockName,
bool $visible
): void

Sets the visibility.

Parameters
$blockName : string
 
$visible : bool
 
Exceptions

Throws UnknownBlockException

Throws BlockFinalException If the block is final.

sortBlockOverview()

protected SimpleBlockManager::sortBlockOverview (
string $placeholderA,
string $placeholderB
): int
Parameters
$placeholderA : string
 
$placeholderB : string