Skip to content

Fix CRUD operations for sentiment management#21

Merged
jjroelofs merged 5 commits into1.xfrom
fix/add-sentiment-button
Sep 11, 2025
Merged

Fix CRUD operations for sentiment management#21
jjroelofs merged 5 commits into1.xfrom
fix/add-sentiment-button

Conversation

@jjroelofs
Copy link
Copy Markdown
Contributor

Summary

Fixes missing "Add sentiment" button and resolves multiple CRUD issues in the analyze_ai_sentiments module. This PR ensures reliable sentiment management functionality matching the architecture of sibling modules.

Issues Resolved

Closes #20

Changes Made

🎯 Core CRUD Fixes

  • Add missing action links - Created analyze_ai_sentiments.links.action.yml to register "Add sentiment" button
  • Fix storage service architecture - Refactored AISentimentsAnalyzer to use storage service instead of hardcoded defaults
  • Fix form submission logic - Corrected SentimentsSettingsForm structure and data handling
  • Add default sentiment installation - Modified hook_install() to persist defaults to configuration

🛠️ Technical Improvements

  • Fix variable naming conflicts - Resolved foreach ($sentiments as $id => $sentiments) TypeErrors throughout codebase
  • Add data validation - Implemented structure validation with fallback to defaults
  • Improve error handling - Added safety checks for corrupted configuration data
  • Enhance dependency injection - Proper service injection in forms

📁 Files Changed

  • analyze_ai_sentiments.links.action.yml (new) - Action links for "Add sentiment" button
  • analyze_ai_sentiments.install - Added default sentiment installation
  • src/Form/AddSentimentsForm.php - Fixed DI and variable naming
  • src/Form/SentimentsSettingsForm.php - Fixed form structure and submission
  • src/Plugin/Analyze/AISentimentsAnalyzer.php - Use storage service consistently
  • src/Service/SentimentsStorageService.php - Enhanced validation and error handling

Test Plan

  • Settings page at /admin/config/analyze/sentiments loads without errors
  • "Add sentiment" button appears and navigates correctly
  • New sentiments can be added via form
  • Existing sentiments can be edited and changes persist
  • Default sentiments install correctly on fresh installation
  • Analysis page at /node/*/analyze works without TypeErrors
  • All CRUD operations work reliably
  • No regression in existing functionality

Architecture Notes

This PR standardizes the sentiment module to follow the same reliable storage service pattern used by the analyze_ai_content_marketing_audit module, ensuring consistency across the analyze module family.

Installation Impact

  • New installations: Defaults install automatically
  • Existing installations: Recommend reinstalling module to get default sentiments
  • No breaking changes: All existing functionality preserved

🤖 Generated with Claude Code

Jurriaan Roelofs and others added 5 commits September 11, 2025 15:49
Resolves missing "Add sentiment" button and fixes multiple CRUD issues:

- Add missing analyze_ai_sentiments.links.action.yml for "Add sentiment" button
- Fix AISentimentsAnalyzer to use storage service instead of hardcoded defaults
- Fix SentimentsSettingsForm data structure and form submission logic
- Add default sentiment installation to hook_install()
- Refactor storage service architecture for reliable CRUD operations
- Fix variable naming conflicts in foreach loops that caused TypeErrors
- Add data validation to prevent corrupted config issues

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change SentimentsSettingsForm from ConfigFormBase to FormBase
- Remove unused getEditableConfigNames() method
- Remove unused TypedConfigManagerInterface and ConfigFactoryInterface dependencies
- Simplify constructor and create() method
- Form now uses storage service exclusively instead of Drupal config system

This aligns with the custom storage service architecture and removes
the architectural inconsistency of extending ConfigFormBase while
not using parent form submission.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix undefined variable $sentiments -> $sentiment in AISentimentsAnalyzer
- Remove invalid parent::buildForm() call after switching from ConfigFormBase to FormBase
- Add proper form actions manually instead of relying on parent

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Shorten comment to comply with 80-character line limit.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jjroelofs jjroelofs merged commit b6ad117 into 1.x Sep 11, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing 'Add sentiment' button and CRUD issues in sentiment management

1 participant