Skip to content

Commit 318a670

Browse files
committed
minor #21423 Add new DayPointType and TimePointType Doctrine type (wkania)
This PR was merged into the 7.4 branch. Discussion ---------- Add new DayPointType and TimePointType Doctrine type Fixes #21402 Commits ------- da3870e [DoctrineBridge] Add new DayPointType and TimePointType Doctrine type
2 parents c218ef2 + da3870e commit 318a670

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

components/clock.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,17 @@ Storing DatePoints in the Database
271271
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272272

273273
If you :doc:`use Doctrine </doctrine>` to work with databases, consider using the
274-
``date_point`` Doctrine type, which converts to/from ``DatePoint`` objects automatically::
274+
new Doctrine types:
275+
276+
======================= ====================== =====
277+
DatePoint Doctrine type Extends Doctrine type Class
278+
======================= ====================== =====
279+
``date_point`` ``datetime_immutable`` :class:`Symfony\\Bridge\\Doctrine\\Types\\DatePointType`
280+
``day_point`` ``date_immutable`` :class:`Symfony\\Bridge\\Doctrine\\Types\\DayPointType`
281+
``time_point`` ``time_immutable`` :class:`Symfony\\Bridge\\Doctrine\\Types\\TimePointType`
282+
======================= ====================== =====
283+
284+
They convert to/from ``DatePoint`` objects automatically::
275285

276286
// src/Entity/Product.php
277287
namespace App\Entity;
@@ -282,21 +292,31 @@ If you :doc:`use Doctrine </doctrine>` to work with databases, consider using th
282292
#[ORM\Entity]
283293
class Product
284294
{
285-
// if you don't define the Doctrine type explicitly, Symfony will autodetect it:
295+
// if you don't define the Doctrine type explicitly, Symfony will autodetect 'date_point':
286296
#[ORM\Column]
287297
private DatePoint $createdAt;
288298

289299
// if you prefer to define the Doctrine type explicitly:
290300
#[ORM\Column(type: 'date_point')]
291301
private DatePoint $updatedAt;
292302

303+
#[ORM\Column(type: 'day_point')]
304+
public DatePoint $birthday;
305+
306+
#[ORM\Column(type: 'time_point')]
307+
public DatePoint $openAt;
308+
293309
// ...
294310
}
295311

296312
.. versionadded:: 7.3
297313

298314
The ``DatePointType`` was introduced in Symfony 7.3.
299315

316+
.. versionadded:: 7.4
317+
318+
The ``DayPointType`` and ``TimePointType`` were introduced in Symfony 7.4.
319+
300320
.. _clock_writing-tests:
301321

302322
Writing Time-Sensitive Tests

0 commit comments

Comments
 (0)