luya\console\commands\BlockController::generateViewFile PHP Method

generateViewFile() public method

Generate the view file for the block.
public generateViewFile ( string $blockClassName ) : string
$blockClassName string The name of the block class.
return string The rendered view file.
    public function generateViewFile($blockClassName)
    {
        sort($this->viewFileDoc);
        return $this->view->render('@luya/console/commands/views/block/create_block_view.php', ['blockClassName' => $blockClassName, 'phpdoc' => $this->viewFileDoc, 'luyaText' => $this->getGeneratorText('block/create')]);
    }

Usage Example

Example #1
0
    public function testBlockViewFileContent()
    {
        $ctrl = new BlockController('id', Yii::$app);
        $ctrl->viewFileDoc = ['$this->varValue(\'foo\');', '$this->varValue(\'foo\');', '$this->extraValue(\'foo\');', '$this->cfgValue(\'foo\');'];
        $view = <<<'EOT'
<?php
/**
 * View file for block: MySuperBlock 
 *
 * File has been created with `block/create` command on LUYA version 1.0.0-dev. 
 *
 * @param $this->cfgValue('foo');
 * @param $this->extraValue('foo');
 * @param $this->varValue('foo');
 * @param $this->varValue('foo');
 *
 * @var $this \luya\cms\base\PhpBlockView
 */
?>
EOT;
        $this->assertSame($view, $ctrl->generateViewFile('MySuperBlock'));
    }