/** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { /** @var static $backend */ $backend = parent::create($container, $configuration, $plugin_id, $plugin_definition); /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */ $module_handler = $container->get('module_handler'); $backend->setModuleHandler($module_handler); /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */ $config_factory = $container->get('config.factory'); $backend->setConfigFactory($config_factory); /** @var \Drupal\search_api\DataType\DataTypePluginManager $data_type_plugin_manager */ $data_type_plugin_manager = $container->get('plugin.manager.search_api.data_type'); $backend->setDataTypePluginManager($data_type_plugin_manager); /** @var \Drupal\Core\Logger\LoggerChannelInterface $logger */ $logger = $container->get('logger.factory')->get('search_api_db'); $backend->setLogger($logger); /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $keyvalue_factory */ $keyvalue_factory = $container->get('keyvalue'); $backend->setKeyValueStore($keyvalue_factory->get(self::INDEXES_KEY_VALUE_STORE_ID)); return $backend; }
/** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { /** @var static $backend */ $backend = parent::create($container, $configuration, $plugin_id, $plugin_definition); /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */ $module_handler = $container->get('module_handler'); $backend->setModuleHandler($module_handler); /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */ $config_factory = $container->get('config.factory'); $backend->setConfigFactory($config_factory); /** @var \Drupal\search_api\DataType\DataTypePluginManager $data_type_plugin_manager */ $data_type_plugin_manager = $container->get('plugin.manager.search_api.data_type'); $backend->setDataTypePluginManager($data_type_plugin_manager); /** @var \Drupal\Core\Logger\LoggerChannelInterface $logger */ $logger = $container->get('logger.factory')->get('search_api_db'); $backend->setLogger($logger); /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $keyvalue_factory */ $keyvalue_factory = $container->get('keyvalue'); $backend->setKeyValueStore($keyvalue_factory->get(self::INDEXES_KEY_VALUE_STORE_ID)); // For a new backend plugin, the database might not be set yet. In that case // we of course also don't need a DBMS compatibility handler. if ($backend->getDatabase()) { /** @var \Drupal\search_api_db\DatabaseCompatibility\DatabaseCompatibilityHandlerInterface $dbms_compatibility_handler */ $dbms_compatibility_handler = $container->get('search_api_db.database_compatibility'); // Make sure that we actually provide a handler for the right database, // otherwise fall back to the generic handler. if ($dbms_compatibility_handler->getDatabase() != $backend->getDatabase()) { /** @var \Drupal\Component\Transliteration\TransliterationInterface $transliterator */ $transliterator = $container->get('transliteration'); $dbms_compatibility_handler = new GenericDatabase($backend->getDatabase(), $transliterator); } $backend->setDbmsCompatibilityHandler($dbms_compatibility_handler); } return $backend; }