Paragraphs Editor
CommandContextFactoryInterface.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7 /**
8  * Provides an interface for a command context factory.
9  *
10  * Context factories generate command context objects that contain all the
11  * context needed to uniquely identify editor instances.
12  */
14 
15  /**
16  * Creates a new command context object.
17  *
18  * @param string $field_config_id
19  * The id of the field instance being edited.
20  * @param mixed $entity_id
21  * The entity id of the entity that owns the field being edited.
22  * @param array $settings
23  * The field widget settings for the editor.
24  * @param string|null $widget_build_id
25  * A unique random string to identify an editor instance.
26  *
27  * @return \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface
28  * A command context object representing the context a command was executed
29  * in.
30  */
31  public function create($field_config_id, $entity_id, array $settings = [], $widget_build_id = NULL);
32 
33  /**
34  * Gets a command context object for an existing context.
35  *
36  * @param string $context_id
37  * The id of the context to get.
38  *
39  * @return \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface
40  * A command context object representing the context a command was executed
41  * in.
42  */
43  public function get($context_id);
44 
45  /**
46  * Rebuilds a template context from a template.
47  *
48  * Contexts need to be regenerated whenever edits are made to avoid caching
49  * issues.
50  *
51  * @param \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface $from
52  * The context to be regenerated.
53  *
54  * @return \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface
55  * The newly generated context.
56  */
57  public function regenerate(CommandContextInterface $from);
58 
59  /**
60  * Frees the context from persistent storage.
61  *
62  * @param \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface $context
63  * The context whose related storage will be freed.
64  */
65  public function free(CommandContextInterface $context);
66 
67  /**
68  * Gets the plugin manager for a certain plugin type.
69  *
70  * @param string $type
71  * The plugin type to get the plugin manager for.
72  *
73  * @return \Drupal\Component\Plugin\PluginManagerInterface
74  * The plugin manager associated with the plugin type or NULL if no such
75  * manager exists.
76  */
77  public function getPluginManager($type);
78 
79  /**
80  * Explodes a context string to return its parts.
81  *
82  * @return array
83  * An array in the form: [field_id, builid_id, entity_id].
84  */
85  public function parseContextString($context_string);
86 
87  /**
88  * Creates a bundle filter object.
89  *
90  * @param \Drupal\Core\Field\FieldConfigInterface $field_config
91  * The field definition to create the filter for.
92  *
93  * @return \Drupal\paragraphs_editor\EditorCommand\ParagraphBundleFilterInterface
94  * A filter object for the field definition.
95  */
96  public function createBundleFilter(FieldConfigInterface $field_config);
97 
98 }
create($field_config_id, $entity_id, array $settings=[], $widget_build_id=NULL)