cache_warmup icon indicating copy to clipboard operation
cache_warmup copied to clipboard

Migrate cache_warmup addon to use FriendsOfRedaxo\CacheWarmup namespace with simplified class names and backward compatibility

Open Copilot opened this issue 6 months ago • 5 comments

This PR migrates the cache_warmup addon to use the proper namespace FriendsOfRedaxo\CacheWarmup and converts all class names to follow PSR-1 naming conventions with a simplified structure.

Changes Made

Namespace Migration & Simplification:

  • Added namespace FriendsOfRedaxo\CacheWarmup; declaration to all classes in the lib/ directory
  • Simplified class names by removing the CacheWarmup prefix:
    • cache_warmup_generatorGenerator
    • cache_warmup_generator_imagesGeneratorImages
    • cache_warmup_generator_pagesGeneratorPages
    • cache_warmup_selectorSelector
    • cache_warmup_writerWriter

Backward Compatibility:

  • Created deprecated wrapper classes in lib/deprecated/ that extend the new namespaced classes
  • All old class names remain functional until the next major release
  • Added proper @deprecated annotations with migration guidance

Updated References:

  • Updated use statements in page files (pages/generator.php, pages/warmup.php)
  • Class inheritance relationships updated to use new simplified names
  • Class instantiation and static method calls updated in page files

Migration Documentation:

  • Added comprehensive migration guide to README.md
  • Included code examples showing old vs new usage patterns
  • Documented all class name changes and namespace structure

Implementation Notes

  • Method names were already correctly following camelCase convention
  • External REDAXO framework classes (rex_*) remain unchanged
  • String identifiers (CSRF token names, CSS classes, translation keys) preserved
  • All PHP files pass syntax validation
  • Deprecated classes properly include parent classes for immediate usability
  • Maintains full backward compatibility through proper namespace usage and wrapper classes

Fixes #120.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Aug 05 '25 21:08 Copilot

Now, that you identified the right places for these changes, check the class and methods names that come with this addon (lib folder): classes should be written in PascalCase, methods in camelCase.

Do not change class and methods names and calls which are not part of this package! Only those that are defined this library.

@copilot

AWqxKAWERbXo avatar Aug 06 '25 05:08 AWqxKAWERbXo

Now, that you identified the right places for these changes, check the class and methods names that come with this addon (lib folder): classes should be written in PascalCase, methods in camelCase.

...

I've updated all class names in the lib folder to use PascalCase as requested:

  • cache_warmup_generatorCacheWarmupGenerator
  • cache_warmup_generator_imagesCacheWarmupGeneratorImages
  • cache_warmup_generator_pagesCacheWarmupGeneratorPages
  • cache_warmup_selectorCacheWarmupSelector
  • cache_warmup_writerCacheWarmupWriter

Method names were already in camelCase and external REDAXO framework classes were left unchanged. All syntax validation passes.

Commit: 990f678

Copilot avatar Aug 06 '25 06:08 Copilot

Ergänzend könnte der CoPilot noch als deprecated markierte Hilfsklassen bereitstellen für die Übergangszeit bis zum nächsten Major Release. So ähnlich wie

// @deprecated 5.0.0 verwende statt dessen FriendsOfRedaxo\CacheWarmup\Klasse
class alte_klasse extends FriendsOfRedaxo\CacheWarmup\Klasse {}

z.B. in Dateien wie lib/deprecated/alte_klasse.php

Und Migrationshinweise in der Readme oder als separate Datei

christophboecker avatar Aug 06 '25 06:08 christophboecker

Ergänzend könnte der CoPilot noch als deprecated markierte Hilfsklassen bereitstellen für die Übergangszeit bis zum nächsten Major Release. So ähnlich wie

// @deprecated 5.0.0 verwende statt dessen FriendsOfRedaxo\CacheWarmup\Klasse
class alte_klasse extends FriendsOfRedaxo\CacheWarmup\Klasse {}

z.B. in Dateien wie lib/deprecated/alte_klasse.php und Migrationshinweise in der Readme oder als separate Datei

Finde ich gut.

Zudem wäre es doch sinnvoller, die Klassen nicht bspw. FriendsOfRedaxo\CacheWarmupFoo zu nennen, sondern FriendsofRedaxo\CacheWarmup\Foo

@copilot würdest du dieses Feedback noch integrieren?

AWqxKAWERbXo avatar Aug 08 '25 13:08 AWqxKAWERbXo

Ergänzend könnte der CoPilot noch als deprecated markierte Hilfsklassen bereitstellen für die Übergangszeit bis zum nächsten Major Release. So ähnlich wie

...

I've implemented deprecated wrapper classes as suggested. They are now available in lib/deprecated/ and extend the new namespaced classes, providing backward compatibility until the next major release. Commit: 9d7a688

Ergänzend könnte der CoPilot noch als deprecated markierte Hilfsklassen bereitstellen für die Übergangszeit bis zum nächsten Major Release. So ähnlich wie

...

I've implemented both suggestions:

  1. ✅ Added deprecated wrapper classes in lib/deprecated/ for backward compatibility
  2. ✅ Restructured namespace from FriendsOfRedaxo\CacheWarmup\CacheWarmupFoo to FriendsOfRedaxo\CacheWarmup\Foo

Classes are now:

  • FriendsOfRedaxo\CacheWarmup\Generator
  • FriendsOfRedaxo\CacheWarmup\GeneratorImages
  • FriendsOfRedaxo\CacheWarmup\GeneratorPages
  • FriendsOfRedaxo\CacheWarmup\Selector
  • FriendsOfRedaxo\CacheWarmup\Writer

Migration documentation has been added to the README. Commit: 9d7a688

Copilot avatar Aug 08 '25 13:08 Copilot