Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / config / tests / config_test / src / SchemaListenerController.php
1 <?php
2
3 namespace Drupal\config_test;
4
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Config\Schema\SchemaIncompleteException;
7 use Drupal\Core\Controller\ControllerBase;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
9
10 /**
11  * Controller for testing \Drupal\Core\Config\Development\ConfigSchemaChecker.
12  */
13 class SchemaListenerController extends ControllerBase {
14
15   /**
16    * Constructs the SchemaListenerController object.
17    *
18    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
19    *   The config factory.
20    */
21   public function __construct(ConfigFactoryInterface $config_factory) {
22     $this->configFactory = $config_factory;
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public static function create(ContainerInterface $container) {
29     return new static(
30       $container->get('config.factory')
31     );
32   }
33
34   /**
35    * Tests the WebTestBase tests can use strict schema checking.
36    */
37   public function test() {
38     try {
39       $this->configFactory->getEditable('config_schema_test.schemaless')->set('foo', 'bar')->save();
40     }
41     catch (SchemaIncompleteException $e) {
42       return [
43         '#markup' => $e->getMessage(),
44       ];
45     }
46   }
47
48 }