33namespace Drupal \islandora_mirador \Plugin \IslandoraMiradorPlugin ;
44
55use Drupal \islandora_mirador \IslandoraMiradorPluginPluginBase ;
6+ use Drupal \Core \Config \ConfigFactoryInterface ;
7+ use Drupal \Core \Plugin \ContainerFactoryPluginInterface ;
8+ use Symfony \Component \DependencyInjection \ContainerInterface ;
69
710/**
811 * Plugin implementation of the islandora_mirador.
1316 * description = @Translation("Mirador text overlay plugin for text selection and accessibility.")
1417 * )
1518 */
16- class TextOverlay extends IslandoraMiradorPluginPluginBase {
19+ class TextOverlay extends IslandoraMiradorPluginPluginBase implements ContainerFactoryPluginInterface {
20+ /**
21+ * The config factory.
22+ *
23+ * @var \Drupal\Core\Config\ConfigFactoryInterface
24+ */
25+ protected $ configFactory ;
26+
27+ /**
28+ * Constructs a TextOverlay object.
29+ *
30+ * @param array $configuration
31+ * A configuration array containing information about the plugin instance.
32+ * @param string $plugin_id
33+ * The plugin_id for the plugin instance.
34+ * @param mixed $plugin_definition
35+ * The plugin implementation definition.
36+ * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
37+ * The config factory.
38+ */
39+ public function __construct (array $ configuration , $ plugin_id , $ plugin_definition , ConfigFactoryInterface $ config_factory ) {
40+ parent ::__construct ($ configuration , $ plugin_id , $ plugin_definition );
41+ $ this ->configFactory = $ config_factory ;
42+ }
1743
1844 /**
1945 * {@inheritdoc}
2046 */
47+ public static function create (ContainerInterface $ container , array $ configuration , $ plugin_id , $ plugin_definition ) {
48+ return new static (
49+ $ configuration ,
50+ $ plugin_id ,
51+ $ plugin_definition ,
52+ $ container ->get ('config.factory ' )
53+ );
54+ }
55+
56+ /**
57+ * {@InheritDoc}
58+ */
2159 public function windowConfigAlter (array &$ windowConfig ) {
2260 // Get the config to check if this plugin is enabled.
23- $ config = \Drupal::service ('config.factory ' )
24- ->get ('islandora_mirador.settings ' );
61+ $ config = $ this ->configFactory ->get ('islandora_mirador.settings ' );
2562 $ enabled_plugins = $ config ->get ('mirador_enabled_plugins ' );
26-
63+
2764 if (!empty ($ enabled_plugins ['textOverlayPlugin ' ])) {
2865 // Enabled config - checkbox is checked.
2966 $ windowConfig ['textOverlay ' ] = [
@@ -41,4 +78,4 @@ public function windowConfigAlter(array &$windowConfig) {
4178 }
4279 }
4380
44- }
81+ }
0 commit comments