Skip to content

Commit 29e496d

Browse files
authored
Merge pull request #8057 from cakephp/5.next-uuid
Docs for UUID config DI.
2 parents 8dd8e06 + 4289e44 commit 29e496d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

en/appendices/5-3-migration-guide.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,10 @@ TestSuite
124124

125125
- ``assertRedirectBack()`` added to assert a successful redirect has been made to the same previous URL.
126126
- ``assertRedirectBackToReferer()`` added to assert a successful redirect has been made to the referer URL.
127+
128+
Utility
129+
-------
130+
131+
- ``Text::uuid()`` now supports configurable UUID generation. You can set a custom
132+
UUID generator using ``Configure::write('Text.uuidGenerator', $closure)`` to
133+
integrate your own UUID generation strategy or third-party libraries.

en/core-libraries/text.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ UUID is a 128-bit string in the format of
9797

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

100+
.. versionadded:: 5.3.0
101+
You can now configure a custom UUID generator using dependency injection.
102+
103+
Starting from CakePHP 5.3.0, you can configure a custom UUID generator by
104+
setting a closure in your configuration::
105+
106+
// In your config/app.php or config/bootstrap.php
107+
use Cake\Core\Configure;
108+
109+
Configure::write('Text.uuidGenerator', function () {
110+
// Return your custom UUID string
111+
return \MyUuidLibrary::generate();
112+
});
113+
114+
This allows you to integrate your own UUID generation strategy or use
115+
third-party UUID libraries. When a custom generator is configured, it will
116+
be used instead of the default UUID generation method.
117+
100118
Simple String Parsing
101119
=====================
102120

0 commit comments

Comments
 (0)