LonelyMonkeyController.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/error_service_test/src/Controller/LonelyMonkeyController.php
  2. 8.9.x core/modules/system/tests/modules/error_service_test/src/Controller/LonelyMonkeyController.php
  3. 10 core/modules/system/tests/modules/error_service_test/src/Controller/LonelyMonkeyController.php

Namespace

Drupal\error_service_test\Controller

File

core/modules/system/tests/modules/error_service_test/src/Controller/LonelyMonkeyController.php

View source
<?php

declare (strict_types=1);
namespace Drupal\error_service_test\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\error_service_test\LonelyMonkeyClass;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a controller which calls out to a service with missing dependencies.
 */
class LonelyMonkeyController extends ControllerBase implements ContainerInjectionInterface {
    
    /**
     * The lonely monkey class.
     */
    protected LonelyMonkeyClass $class;
    public function __construct(LonelyMonkeyClass $class) {
        $this->class = $class;
    }
    public function testBrokenClass() {
        return [
            '#markup' => $this->t('This should be broken.'),
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container) {
        return new static($container->get('broken_class_with_missing_dependency'));
    }

}

Classes

Title Deprecated Summary
LonelyMonkeyController Provides a controller which calls out to a service with missing dependencies.

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