function MockMenuBlock::getContent

Same name in other branches
  1. 9 core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock::getContent()
  2. 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::getContent()
  3. 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::getContent()

Returns the content to display.

File

core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php, line 34

Class

MockMenuBlock
Mock implementation of a menu block plugin used by Plugin API unit tests.

Namespace

Drupal\plugin_test\Plugin\plugin_test\mock_block

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.