我正在关注这个Drupal 8 模块开发 101教程。YouTube 视频的时间是 37:15 到 45:14。我不断收到此错误:
致命错误:第 11 行的 C:\Users\myName\Sites\devdesktop\drupal-8.0.5\modules\dino_roar\src\Controller\RoarController.php 中找不到类 'Drupal\dino_roar\DinoServices\HelloGenerator'
HelloGenerator.php
<?php
namespace Drupal\dino_roar\DinoServices;
class HelloGenerator
{
public function getHello($count){
return "Gotten Hello ".$count;
}
}
咆哮控制器.php
<?php
namespace Drupal\dino_roar\Controller;
//use Drupal\dino_roar\DinoServices\HelloGenerator;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class RoarController extends Controller
{
public function roar($count){
//$helloGenerator = new HelloGenerator();
$helloGenerator = $this->get('dino_roar.hello_generator');
$hello = $helloGenerator->getHello($count);
return new Response($hello);
//return new Response("Hello World ".$count);
}
}
恐龙吼.info.yml
name: Dino ROAR
type: module
description: "ROAR at you"
package: Custom
core: 8.x
dino_roar.routing.yml
dino_says:
path: /dino/says/{count}
defaults:
_controller: '\Drupal\dino_roar\Controller\RoarController::roar'
requirements:
_permission: 'access content'
dino_roar.services.yml
services:
dino_roar.hello_generator:
class: Drupal\dino_roar\DinoServices\HelloGenerator
致命错误指向 RoarController.php 文件中的这行代码: $helloGenerator = new HelloGenerator();
这是 Symfony 版本。我在这个窗口中找不到它说 1,2 或 3。