Skip to content

Docs for UUID config DI. #8057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 5.next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions en/appendices/5-3-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,10 @@ TestSuite

- ``assertRedirectBack()`` added to assert a successful redirect has been made to the same previous URL.
- ``assertRedirectBackToReferer()`` added to assert a successful redirect has been made to the referer URL.

Utility
-------

- ``Text::uuid()`` now supports configurable UUID generation. You can set a custom
UUID generator using ``Configure::write('Text.uuidGenerator', $closure)`` to
integrate your own UUID generation strategy or third-party libraries.
18 changes: 18 additions & 0 deletions en/core-libraries/text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ UUID is a 128-bit string in the format of

Text::uuid(); // 485fc381-e790-47a3-9794-1337c0a8fe68

.. versionadded:: 5.3.0
You can now configure a custom UUID generator using dependency injection.

Starting from CakePHP 5.3.0, you can configure a custom UUID generator by
setting a closure in your configuration::

// In your config/app.php or config/bootstrap.php
use Cake\Core\Configure;

Configure::write('Text.uuidGenerator', function () {
// Return your custom UUID string
return \MyUuidLibrary::generate();
});

This allows you to integrate your own UUID generation strategy or use
third-party UUID libraries. When a custom generator is configured, it will
be used instead of the default UUID generation method.

Simple String Parsing
=====================

Expand Down
Loading