Skip to content

Commit a3e9aec

Browse files
committed
Merge branch '5.x' into 5.next
2 parents 6def0b2 + fbe5b68 commit a3e9aec

21 files changed

Lines changed: 86 additions & 62 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM debian:bookworm
22

3-
ENV DEBIAN_FRONTEND noninteractive
3+
ENV DEBIAN_FRONTEND=noninteractive
44

55
LABEL Description="This image is used to create an environment to contribute to the cakephp/docs"
66

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ View
129129
----
130130

131131
- ``FormHelper::deleteLink()`` has been added as convenience wrapper for delete links in
132-
templates using ``DELETE`` method.
132+
templates using ``DELETE`` method.
133133
- ``HtmlHelper::importmap()`` was added. This method allows you to define
134134
import maps for your JavaScript files.
135135
- ``FormHelper`` now uses the ``containerClass`` template to apply a class to

en/development/testing.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,17 @@ name::
733733
In the above example, both fixtures would be loaded from
734734
``tests/Fixture/Blog/``.
735735

736+
You can also directly include fixtures by FQCN::
737+
738+
public function getFixtures(): array
739+
{
740+
return [
741+
UsersFixture::class,
742+
ArticlesFixture::class,
743+
];
744+
}
745+
746+
736747
Fixture Factories
737748
-----------------
738749

en/orm/database-basics.rst

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -540,40 +540,39 @@ implement the following methods:
540540
* ``marshal``: Marshals flat data into PHP objects.
541541

542542
To fulfill the basic interface, extend :php:class:`Cake\\Database\\Type`.
543-
For example if we wanted to add a JSON type, we could make the following type
543+
For example if we wanted to add a PointMutation type, we could make the following type
544544
class::
545545

546-
// in src/Database/Type/JsonType.php
546+
// in src/Database/Type/PointMutationType.php
547547

548548
namespace App\Database\Type;
549549

550550
use Cake\Database\Driver;
551551
use Cake\Database\Type\BaseType;
552552
use PDO;
553553

554-
class JsonType extends BaseType
554+
class PointMutationType extends BaseType
555555
{
556556
public function toPHP(mixed $value, Driver $driver): mixed
557557
{
558558
if ($value === null) {
559559
return null;
560560
}
561561

562-
return json_decode($value, true);
563-
}
562+
return $this->pmDecode($valu
564563

565564
public function marshal(mixed $value): mixed
566565
{
567566
if (is_array($value) || $value === null) {
568567
return $value;
569568
}
570569

571-
return json_decode($value, true);
570+
return $this->pmDecode($value);
572571
}
573572

574573
public function toDatabase(mixed $value, Driver $driver): mixed
575574
{
576-
return json_encode($value);
575+
return sprintf('%d%s>%s', $value['position'], $value['from'], $value['to']);
577576
}
578577

579578
public function toStatement(mixed $value, Driver $driver): int
@@ -584,6 +583,19 @@ class::
584583

585584
return PDO::PARAM_STR;
586585
}
586+
587+
protected function pmDecode(mixed $value): mixed
588+
{
589+
if (preg_match('/^(\d+)([a-zA-Z])>([a-zA-Z])$/', $value, $matches)) {
590+
return [
591+
'position' => (int) $matches[1],
592+
'from' => $matches[2],
593+
'to' => $matches[3]
594+
];
595+
}
596+
597+
return null;
598+
}
587599
}
588600

589601
By default the ``toStatement()`` method will treat values as strings which will
@@ -597,7 +609,8 @@ the type mapping. During our application bootstrap we should do the following::
597609

598610
use Cake\Database\TypeFactory;
599611

600-
TypeFactory::map('json', \App\Database\Type\JsonType::class);
612+
TypeFactory::map('point_mutation', \App\Database\Type\PointMutationType:class);
613+
601614

602615
We then have two ways to use our datatype in our models.
603616

@@ -606,27 +619,27 @@ We then have two ways to use our datatype in our models.
606619
and define the SQL column type and reflection logic.
607620

608621
Overwriting the reflected schema with our custom type will enable CakePHP's
609-
database layer to automatically convert JSON data when creating queries. In your
610-
Table's :ref:`initialize() method <saving-complex-types>` add the
622+
database layer to automatically convert PointMutation data when creating queries. In your
623+
Table's :ref:`getSchema() method <saving-complex-types>` add the
624+
611625
following::
612626

613627
class WidgetsTable extends Table
614628
{
615629
public function initialize(array $config): void
616630
{
617-
parent::initialize($config);
631+
return parent::getSchema()->setColumnType('mutation', 'point_mutation');
618632

619-
$this->getSchema()->setColumnType('widget_prefs', 'json');
620633
}
621634
}
622635

623636
Implementing ``ColumnSchemaAwareInterface`` gives you more control over
624637
custom datatypes. This avoids overwriting schema definitions if your
625638
datatype has an unambiguous SQL column definition. For example, we could have
626-
our JSON type be used anytime a ``TEXT`` column with a specific comment is
639+
our PointMutation type be used anytime a ``TEXT`` column with a specific comment is
627640
used::
628641

629-
// in src/Database/Type/JsonType.php
642+
// in src/Database/Type/PointMutationType.php
630643

631644
namespace App\Database\Type;
632645

@@ -636,7 +649,7 @@ used::
636649
use Cake\Database\Schema\TableSchemaInterface;
637650
use PDO;
638651

639-
class JsonType extends BaseType
652+
class PointMutationType extends BaseType
640653
implements ColumnSchemaAwareInterface
641654
{
642655
// other methods from earlier
@@ -691,8 +704,8 @@ no value for the current database driver:
691704
Mapping Custom Datatypes to SQL Expressions
692705
-------------------------------------------
693706

694-
The previous example maps a custom datatype for a 'json' column type which is
695-
easily represented as a string in a SQL statement. Complex SQL data
707+
The previous example maps a custom datatype for a 'point_mutation' column type
708+
which is easily represented as a string in a SQL statement. Complex SQL data
696709
types cannot be represented as strings/integers in SQL queries. When working
697710
with these datatypes your Type class needs to implement the
698711
``Cake\Database\Type\ExpressionTypeInterface`` interface. This interface lets

en/orm/deleting-data.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Deleting Data
66
.. php:class:: Table
77
:noindex:
88

9-
.. php:method:: delete(Entity $entity, $options = [])
9+
.. php:method:: delete(EntityInterface $entity, array $options = [])
1010
1111
Once you've loaded an entity you can delete it by calling the originating
1212
table's delete method::
@@ -65,7 +65,7 @@ these options enabled would be::
6565
Bulk Deletes
6666
------------
6767

68-
.. php:method:: deleteMany($entities, $options = [])
68+
.. php:method:: deleteMany(iterable $entities, array $options = [])
6969
7070
If you have an array of entities you want to delete you can use ``deleteMany()``
7171
to delete them in a single transaction::
@@ -86,7 +86,7 @@ In these cases it is more performant to use a bulk-delete to remove many rows at
8686
once::
8787

8888
// Delete all the spam
89-
function destroySpam()
89+
public function destroySpam()
9090
{
9191
return $this->deleteAll(['is_spam' => true]);
9292
}
@@ -103,7 +103,7 @@ function returns the number of deleted records as an integer.
103103
Strict Deletes
104104
--------------
105105

106-
.. php:method:: deleteOrFail($entity, $options = [])
106+
.. php:method:: deleteOrFail(EntityInterface $entity, array $options = [])
107107
108108
Using this method will throw an
109109
:php:exc:`Cake\\ORM\\Exception\\PersistenceFailedException` if:

en/orm/saving-data.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ would not normally be able to.
11361136
Strict Saving
11371137
=============
11381138

1139-
.. php:method:: saveOrFail($entity, $options = [])
1139+
.. php:method:: saveOrFail(EntityInterface $entity, array $options = [])
11401140
11411141
Using this method will throw an
11421142
:php:exc:`Cake\\ORM\\Exception\\PersistenceFailedException` if:
@@ -1222,7 +1222,7 @@ Instead, assign the primary key and then patch in the remaining entity data::
12221222
Saving Multiple Entities
12231223
========================
12241224

1225-
.. php:method:: saveMany($entities, $options = [])
1225+
.. php:method:: saveMany(iterable $entities, array $options = [])
12261226
12271227
Using this method you can save multiple entities atomically. ``$entities`` can
12281228
be an array of entities created using ``newEntities()`` / ``patchEntities()``.

en/orm/table-objects.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ Behaviors, can use this hook to add in validation methods.
269269
buildRules
270270
----------
271271

272-
.. php:method:: buildRules(EventInterface $event, RulesChecker $rules)
272+
.. php:method:: buildRules(RulesChecker $rules): RulesChecker
273273
274274
The ``Model.buildRules`` event is fired after a rules instance has been
275-
created and after the table's ``buildRules()`` method has been called.
275+
created and after the ``Table::buildRules()`` method has been called.
276276

277277
beforeRules
278278
-----------

en/views/helpers/form.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ use::
15961596
Creating Date & Time Related Controls
15971597
-------------------------------------
15981598

1599-
.. php:method:: dateTime($fieldName, $options = [])
1599+
.. php:method:: dateTime(string $fieldName, array $options = [])
16001600
16011601
* ``$fieldName`` - A string that will be used as a prefix for the HTML ``name``
16021602
attribute of the ``select`` elements.
@@ -1630,7 +1630,7 @@ Output:
16301630
Creating Date Controls
16311631
~~~~~~~~~~~~~~~~~~~~~~
16321632

1633-
.. php:method:: date($fieldName, $options = [])
1633+
.. php:method:: date(string $fieldName, array $options = [])
16341634
16351635
* ``$fieldName`` - A field name that will be used as a prefix for the HTML
16361636
``name`` attribute of the ``select`` elements.
@@ -1652,7 +1652,7 @@ Output:
16521652
Creating Time Controls
16531653
~~~~~~~~~~~~~~~~~~~~~~
16541654

1655-
.. php:method:: time($fieldName, $options = [])
1655+
.. php:method:: time(string $fieldName, array $options = [])
16561656
16571657
* ``$fieldName`` - A field name that will be used as a prefix for the HTML
16581658
``name`` attribute of the ``select`` elements.
@@ -2333,7 +2333,7 @@ Generating Entire Forms
23332333
Creating Multiple Controls
23342334
--------------------------
23352335

2336-
.. php:method:: controls(array $fields = [], $options = [])
2336+
.. php:method:: controls(array $fields = [], array $options = [])
23372337
23382338
* ``$fields`` - An array of fields to generate. Allows setting
23392339
custom types, labels and other options for each specified field.

en/views/helpers/html.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ and also wanted to include **webroot/js/Blog.plugins.js**, you would::
532532
Creating Inline Javascript Blocks
533533
---------------------------------
534534

535-
.. php:method:: scriptBlock($code, $options = [])
535+
.. php:method:: scriptBlock(string $code, array $options = [])
536536
537537
To generate Javascript blocks from PHP view code, you can use one of the script
538538
block methods. Scripts can either be output in place, or buffered into a block::
@@ -543,7 +543,7 @@ block methods. Scripts can either be output in place, or buffered into a block::
543543
// Buffer a script block to be output later.
544544
$this->Html->scriptBlock('alert("hi")', ['block' => true]);
545545

546-
.. php:method:: scriptStart($options = [])
546+
.. php:method:: scriptStart(array $options = [])
547547
.. php:method:: scriptEnd()
548548
549549
You can use the ``scriptStart()`` method to create a capturing block that will

es/orm/deleting-data.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Deleting Data
66
.. php:class:: Table
77
:noindex:
88

9-
.. php:method:: delete(Entity $entity, $options = [])
9+
.. php:method:: delete(EntityInterface $entity, array $options = [])
1010
1111
.. note::
1212
La documentación no es compatible actualmente con el idioma español en esta página.

0 commit comments

Comments
 (0)