class MockMenuBlock
Same name in other branches
- 8.9.x core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock
- 10 core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock
- 11.x core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock
Mock implementation of a menu block plugin used by Plugin API unit tests.
Hierarchy
- class \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock
Expanded class hierarchy of MockMenuBlock
See also
\Drupal\plugin_test\Plugin\MockBlockManager
File
-
core/
modules/ system/ tests/ modules/ plugin_test/ src/ Plugin/ plugin_test/ mock_block/ MockMenuBlock.php, line 10
Namespace
Drupal\plugin_test\Plugin\plugin_test\mock_blockView source
class MockMenuBlock {
/**
* The title to display when rendering this block instance.
*
* @var string
*/
protected $title;
/**
* The number of menu levels deep to render.
*
* @var int
*/
protected $depth;
public function __construct($title = '', $depth = 0) {
$this->title = $title;
$this->depth = $depth;
}
/**
* Returns the content to display.
*/
public function getContent() {
// Since this is a mock object, we just return some HTML of the desired
// nesting level. For depth=2, this returns:
// '<ul><li>1<ul><li>1.1</li></ul></li></ul>'.
$content = '';
for ($i = 0; $i < $this->depth; $i++) {
$content .= '<ul><li>' . implode('.', array_fill(0, $i + 1, '1'));
}
for ($i = 0; $i < $this->depth; $i++) {
$content .= '</li></ul>';
}
return $content;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
MockMenuBlock::$depth | protected | property | The number of menu levels deep to render. |
MockMenuBlock::$title | protected | property | The title to display when rendering this block instance. |
MockMenuBlock::getContent | public | function | Returns the content to display. |
MockMenuBlock::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.