Paragraphs Editor
Main Page
Namespaces
Classes
Files
File List
SchemaController.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Drupal\paragraphs_editor\Controller
;
4
5
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
6
use
Drupal\Core\Field\FieldConfigInterface
;
7
use
Drupal\paragraphs_editor\EditorCommand\CommandContextFactoryInterface
;
8
use
Symfony\Component\DependencyInjection\ContainerInterface
;
9
use
Symfony\Component\HttpFoundation\JsonResponse
;
10
11
/**
12
* Provides an endpoint for serving paragraphs editor schema definitions.
13
*/
14
class
SchemaController
implements
ContainerInjectionInterface {
15
16
/**
17
* Context factory containing the bundle lookup information.
18
*
19
* @var \Drupal\paragraphs_editor\EditorCommand\CommandContextFactoryInterface
20
*/
21
protected
$contextFactory
;
22
23
/**
24
* Creates a SchemaController object.
25
*
26
* @param \Drupal\paragraphs_editor\EditorCommand\CommandContextFactoryInterface $context_factory
27
* The context factory to lookup schemas with.
28
*
29
* @constructor
30
*/
31
public
function
__construct
(
CommandContextFactoryInterface
$context_factory) {
32
$this->contextFactory = $context_factory;
33
}
34
35
/**
36
* {@inheritdoc}
37
*/
38
public
static
function
create
(ContainerInterface $container) {
39
return
new
static
(
40
$container->get(
'paragraphs_editor.command.context_factory'
)
41
);
42
}
43
44
/**
45
* Endpoint for retrieving paragraphs editor schema information.
46
*
47
* @param \Drupal\Core\Field\FieldConfigInterface $field_config
48
* The field configuration to lookup the schema for.
49
*
50
* @return \Symfony\Component\HttpFoundation\JsonResponse
51
* A JSON response containing a widget binder schema model.
52
*/
53
public
function
get
(FieldConfigInterface $field_config) {
54
$bundle_filter = $this->contextFactory->createBundleFilter($field_config);
55
return
new
JsonResponse([
56
[
57
'type'
=>
'schema'
,
58
'id'
=> $field_config->id(),
59
'attributes'
=> [
60
'allowed'
=> $bundle_filter->getAllowedBundles(),
61
],
62
],
63
]);
64
}
65
66
}
FieldConfigInterface
Drupal\paragraphs_editor\Controller\SchemaController\create
static create(ContainerInterface $container)
Definition:
SchemaController.php:38
ContainerInjectionInterface
JsonResponse
Drupal\paragraphs_editor\EditorCommand\CommandContextFactoryInterface
Definition:
CommandContextFactoryInterface.php:13
Drupal\paragraphs_editor\Controller\SchemaController\__construct
__construct(CommandContextFactoryInterface $context_factory)
Definition:
SchemaController.php:31
Drupal\paragraphs_editor\Controller
Definition:
EditorCommandController.php:3
CommandContextFactoryInterface
Drupal\paragraphs_editor\Controller\SchemaController\$contextFactory
$contextFactory
Definition:
SchemaController.php:21
ContainerInterface
Drupal\paragraphs_editor\Controller\SchemaController
Definition:
SchemaController.php:14
src
Controller
SchemaController.php
Generated by
1.8.11