Skip to content
Snippets Groups Projects
Commit d01b2ba5 authored by Artem  Dmitriiev's avatar Artem Dmitriiev
Browse files

Merge branch '1756-make-xi-ai-helper-compatible-with-drupal-10' into 'main'

dxp/issues#1756 Make XI AI Helper compatible with Drupal 10

See merge request !12
parents 30f60776 b51e4713
1 merge request!12dxp/issues#1756 Make XI AI Helper compatible with Drupal 10
Pipeline #258742 passed
......@@ -12,7 +12,7 @@
"require": {
"cweagans/composer-patches": "^2",
"drupal/ai": "^1.0",
"drupal/core": "^11.1",
"drupal/core": ">=10.4",
"1x-contrib-modules/xi_html_markdown": "^1.0"
},
"extra": {
......
......@@ -9,7 +9,6 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\OpenModalDialogCommand;
use Drupal\Core\Ajax\SettingsCommand;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
......@@ -39,6 +38,8 @@ class AiContentSuggestions {
* The current user.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The module handler.
*/
public function __construct(
#[Autowire(service: 'ai.provider')]
......
name: Ai Helper
type: module
description: 'Provides custom AI module helper functions.'
core_version_requirement: ^11.1
core_version_requirement: ^10.4 || ^11.1
dependencies:
- ai:ai
- xi_html_markdown:xi_html_markdown
......@@ -5,6 +5,14 @@
* Contains functions and hooks for xi_ai_helper module.
*/
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\WidgetInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Hook\Attribute\LegacyHook;
use Drupal\xi_ai_helper\Hook\AiContentSuggestions;
use Drupal\xi_ai_helper\Hook\AiSearch;
use Drupal\xi_ai_helper\Hook\LocalTasks;
/**
* Implements hook_theme_suggestion().
*/
......@@ -17,3 +25,43 @@ function xi_ai_helper_theme() {
],
];
}
/**
* Implements field_widget_third_party_settings_form().
*/
#[LegacyHook]
function xi_ai_helper_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, array $form, FormStateInterface $form_state) {
return \Drupal::service(AiContentSuggestions::class)->fieldWidgetThirdPartySettingsForm($plugin, $field_definition, $form_mode, $form, $form_state);
}
/**
* Implements field_widget_complete_form_alter().
*/
#[LegacyHook]
function xi_ai_helper_field_widget_complete_form_alter(array &$field_widget_complete_form, FormStateInterface $form_state, array $context) {
\Drupal::service(AiContentSuggestions::class)->fieldWidgetCompleteFormAlter($field_widget_complete_form, $form_state, $context);
}
/**
* Implements field_widget_single_element_form_alter().
*/
#[LegacyHook]
function xi_ai_helper_field_widget_single_element_form_alter(array &$element, FormStateInterface $form_state, array $context) {
\Drupal::service(AiContentSuggestions::class)->walkThroughMetatagProperties($element, $form_state, $context);
}
/**
* Implements embedding_strategy_info_alter().
*/
#[LegacyHook]
function xi_ai_helper_embedding_strategy_info_alter(array &$definitions) {
\Drupal::service(AiSearch::class)->embeddingStrategyInfoAlter($definitions);
}
/**
* Implements hook_local_tasks_alter().
*/
#[LegacyHook]
function xi_ai_helper_local_tasks_alter(&$local_tasks) {
\Drupal::service(LocalTasks::class)->localTasksAlter($local_tasks);
}
......@@ -10,3 +10,12 @@ services:
arguments: ['@module_handler']
tags:
- { name: event_subscriber }
Drupal\xi_ai_helper\Hook\AiContentSuggestions:
class: Drupal\xi_ai_helper\Hook\AiContentSuggestions
autowire: true
Drupal\xi_ai_helper\Hook\AiSearch:
class: Drupal\xi_ai_helper\Hook\AiSearch
autowire: true
Drupal\xi_ai_helper\Hook\LocalTasks:
class: Drupal\xi_ai_helper\Hook\LocalTasks
autowire: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment