【发布时间】:2016-08-25 13:28:30
【问题描述】:
我在创建自定义块时遇到了问题。同一模块内还有其他块,可以添加并且工作正常。
这是代码(文件名是 /modules/custom/custom_blocks/Plugin/Block/ 中的 TourLink.php):
<?php
/**
* Provides a block that links to /tour
*
* @Block(
* id = "tour_link",
* admin_label = @Translation("Tour Link"),
* )
*/
namespace Drupal\custom_blocks\Plugin\Block;
use Drupal\Core\Block\BlockBase;
class TourLink extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$output = '
<span>test</span>
';
return array(
'#type' => 'markup',
'#markup' => $output,
);
}
}
提前致谢!
【问题讨论】:
-
类注释位于类声明之前的文档块的末尾(参见Annotations)。我不确定,但也许这真的很重要。
-
谢谢,但事实并非如此。