Skip to content

Add possibility for reusable ReindexProvider classes (BC Break ⚠️)#666

Merged
alexander-schranz merged 4 commits intoPHP-CMSIG:0.13from
alexander-schranz:feature/reusable-reindex-providers
Mar 23, 2026
Merged

Add possibility for reusable ReindexProvider classes (BC Break ⚠️)#666
alexander-schranz merged 4 commits intoPHP-CMSIG:0.13from
alexander-schranz:feature/reusable-reindex-providers

Conversation

@alexander-schranz
Copy link
Copy Markdown
Member

@alexander-schranz alexander-schranz commented Mar 2, 2026

Currently it is not possible to create a reusable ReindexProvider as all ReindexProviders require to implement a static method public static function getIndex(): string we should get rid of them so people can create ReindexProviders which are reusable and just configurable by there constructor.

This also add possibility to wrap / decorate ReindexProviders easier, which we require for ODM (#81 #661).

BC Breaks

The ReindexProviderInterface and getIndex method is not longer static and the interface was renamed to StaticReindexProviderInterface as in a DynamicReindexProviderInterface without getIndexName method will be added in upcoming PR:

-class YourClass implements ReindexProviderInterface {
+class YourClass implements StaticReindexProviderInterface {
    // ...
    
-   public static function getIndex(): string
+   public function getIndexName(): string
    {
        return 'test';
    }
}

If you need to support 0.12 and 0.13 the same time you can implement both methods and keep using the deprecated ReindexProviderInterface until 0.14 or 1.0:

class YourClass implements ReindexProviderInterface {
    // ...
    
    public static function getIndex(): string
    {
        return 'index';
    }
    
+   public function getIndexName(): string
+   {
+        return self::getIndex();
+   }
}

fixes #615

@alexander-schranz alexander-schranz added features New feature or request DX Improves the developer experience Require BC Break Requires a BC Break and so new major version labels Mar 2, 2026
@alexander-schranz alexander-schranz force-pushed the feature/reusable-reindex-providers branch 2 times, most recently from dffe8cf to 48838a7 Compare March 2, 2026 18:52
@alexander-schranz alexander-schranz marked this pull request as ready for review March 2, 2026 19:35
@alexander-schranz alexander-schranz requested a review from Toflar March 2, 2026 19:36
@Toflar
Copy link
Copy Markdown
Member

Toflar commented Mar 3, 2026

What happened with the idea outlined in #615 (comment)? Not good anymore? 😊

@alexander-schranz
Copy link
Copy Markdown
Member Author

@Toflar thx for the hint forgot about that :)

@alexander-schranz alexander-schranz force-pushed the feature/reusable-reindex-providers branch 2 times, most recently from 059ad0c to a99a693 Compare March 20, 2026 07:58
@alexander-schranz alexander-schranz force-pushed the feature/reusable-reindex-providers branch from a99a693 to 00556f5 Compare March 23, 2026 09:24
@alexander-schranz alexander-schranz enabled auto-merge (squash) March 23, 2026 10:04
@alexander-schranz alexander-schranz merged commit 10ba326 into PHP-CMSIG:0.13 Mar 23, 2026
121 of 122 checks passed
@alexander-schranz alexander-schranz deleted the feature/reusable-reindex-providers branch April 9, 2026 06:52
Toflar pushed a commit to Toflar/cmsig-search that referenced this pull request Apr 27, 2026
…HP-CMSIG#666)

Currently it is not possible to create a reusable ReindexProvider as all
ReindexProviders require to implement a static method `public static
function getIndex(): string` we should get rid of them so people can
create ReindexProviders which are reusable and just configurable by
there constructor.

This also add possibility to wrap / decorate ReindexProviders easier,
which we require for ODM (PHP-CMSIG#81 PHP-CMSIG#661).

## BC Breaks

The `ReindexProviderInterface` and `getIndex` method is not longer
static and the interface was renamed to `StaticReindexProviderInterface`
as in a `DynamicReindexProviderInterface` without getIndexName method
will be added in upcoming PR:

```diff
-class YourClass implements ReindexProviderInterface {
+class YourClass implements StaticReindexProviderInterface {
    // ...

-   public static function getIndex(): string
+   public function getIndexName(): string
    {
        return 'test';
    }
}
```

If you need to support 0.12 and 0.13 the same time you can implement
both methods and keep using the deprecated ReindexProviderInterface
until 0.14 or 1.0:

```diff
class YourClass implements ReindexProviderInterface {
    // ...

    public static function getIndex(): string
    {
        return 'index';
    }

+   public function getIndexName(): string
+   {
+        return self::getIndex();
+   }
}
```

fixes PHP-CMSIG#615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DX Improves the developer experience features New feature or request Require BC Break Requires a BC Break and so new major version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants