com\setasign\SetaSite\BlockManager

SimpleBlockManager

File: /SetaSite/src/BlockManager/SimpleBlockManager.php

Class hierarchy

Summary

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 SimpleBlockManager::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 a unique blockName(for this page).

Parameters
$block : array{type: string, data: array}
 
$placeholder : string
 
$blockName : string
 
$renderOrder : int
 
$visibility : bool
 
$beforeBlockName : ?string
 
Exceptions

Throws UnknownBlockException

Throws \InvalidArgumentException

exportBlocks()

public SimpleBlockManager::exportBlocks (
void
): array

Returns all blocks which aren't from templates.

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 SimpleBlockManager::getBlockOverview (
array $placeholders
): array

You need to use setPlaceholders before you use this method.

Parameters
$placeholders : array
 

getBlockRenderOrder()

public SimpleBlockManager::getBlockRenderOrder (
void
): array

Returns all blocks in the render order

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 SimpleBlockManager::importBlocks (
array $blocks
): void
Parameters
$blocks : array
 
Exceptions

Throws UnknownBlockException

isValid()

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

Throws UnknownBlockException

moveBlock()

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

Moves the block to the target placeholder before a block.

If $beforeBlockName is null, the block will be moved to the last position.

Parameters
$blockName : string
 
$targetPlaceholder : string
 
$beforeBlockName : ?string
 
Exceptions

Throws UnknownBlockException

removeBlock()

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

Removes the block

Parameters
$blockName : string
 
Exceptions

Throws UnknownBlockException

removeBlocksFromAllPlaceholders()

Removes all blocks from all placeholders. It doesn't matter whether these placeholders exist in the template.

removeBlocksFromPlaceholder()

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

Removes all blocks from a placeholder.

Parameters
$placeholder : string
 

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 SimpleBlockManager::reorder (
string $placeholder,
array $newOutputOrder
): void
Parameters
$placeholder : string
 
$newOutputOrder : array
 
Exceptions

Throws UnknownBlockException

setBlockData()

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

Sets the blockData.

Parameters
$blockName : string
 
$blockData : array
 
Exceptions

Throws UnknownBlockException

setBlockName()

public SimpleBlockManager::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.

setData()

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

Sets all data

Only for internal use!

Parameters
$data : array[]
 
Exceptions

Throws \InvalidArgumentException

setReadOnly()

public SimpleBlockManager::setReadOnly (
void
): void

setRenderOrder()

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

Sets the render order.

Parameters
$blockName : string
 
$renderOrder : int
 
Exceptions

Throws UnknownBlockException

setVisibility()

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

Sets the visibility.

Parameters
$blockName : string
 
$visible : bool
 
Exceptions

Throws UnknownBlockException

sortBlockOverview()

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