SchemaListenerController.php

Same filename in other branches
  1. 8.9.x core/modules/config/tests/config_test/src/SchemaListenerController.php
  2. 10 core/modules/config/tests/config_test/src/SchemaListenerController.php
  3. 11.x core/modules/config/tests/config_test/src/SchemaListenerController.php

Namespace

Drupal\config_test

File

core/modules/config/tests/config_test/src/SchemaListenerController.php

View source
<?php

namespace Drupal\config_test;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\Schema\SchemaIncompleteException;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Controller for testing \Drupal\Core\Config\Development\ConfigSchemaChecker.
 */
class SchemaListenerController extends ControllerBase {
    
    /**
     * Constructs the SchemaListenerController object.
     *
     * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
     *   The config factory.
     */
    public function __construct(ConfigFactoryInterface $config_factory) {
        $this->configFactory = $config_factory;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container) {
        return new static($container->get('config.factory'));
    }
    
    /**
     * Tests the BrowserTestBase tests can use strict schema checking.
     */
    public function test() {
        try {
            $this->configFactory
                ->getEditable('config_schema_test.schemaless')
                ->set('foo', 'bar')
                ->save();
        } catch (SchemaIncompleteException $e) {
            return [
                '#markup' => $e->getMessage(),
            ];
        }
    }

}

Classes

Title Deprecated Summary
SchemaListenerController Controller for testing \Drupal\Core\Config\Development\ConfigSchemaChecker.

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