Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Dec 14, 2023
2 parents cb86efa + ad0fb2c commit 99c67e8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
38 changes: 21 additions & 17 deletions user_guide_src/source/incoming/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -756,21 +756,22 @@ See :ref:`Auto Routing in Controllers <controller-auto-routing-improved>` for mo
Configuration Options
=====================

These options are available at the top of **app/Config/Routes.php**.
These options are available in the **app/Config/Routing.php** file.

Default Controller
------------------

For Site Root URI
^^^^^^^^^^^^^^^^^

When a user visits the root of your site (i.e., **example.com**) the controller to use is determined by the value set by
the ``setDefaultController()`` method, unless a route exists for it explicitly.
When a user visits the root of your site (i.e., **example.com**) the controller
to use is determined by the value set to the ``$defaultController`` property,
unless a route exists for it explicitly.

The default value for this is ``Home``
which matches the controller at **app/Controllers/Home.php**:
The default value for this is ``Home`` which matches the controller at
**app/Controllers/Home.php**::

.. literalinclude:: routing/047.php
public string $defaultController = 'Home';

For Directory URI
^^^^^^^^^^^^^^^^^
Expand All @@ -791,10 +792,10 @@ This works similar to the default controller setting, but is used to determine t
when a controller is found that matches the URI, but no segment exists for the method. The default value is
``index``.

In this example, if the user were to visit **example.com/products**, and a ``Products`` controller existed, the
``Products::getListAll()`` method would be executed:
In this example, if the user were to visit **example.com/products**, and a ``Products``
controller existed, the ``Products::getListAll()`` method would be executed::

.. literalinclude:: routing/048.php
public string $defaultMethod = 'listAll';

.. important:: You cannot access the controller with the URI of the default method name.
In the example above, you can access **example.com/products**, but if you access **example.com/products/listall**, it will be not found.
Expand Down Expand Up @@ -884,19 +885,22 @@ See :ref:`Auto Routing (Legacy) in Controllers <controller-auto-routing-legacy>`
Configuration Options (Legacy)
==============================

These options are available at the top of **app/Config/Routes.php**.
These options are available in the **app/Config/Routing.php** file.

Default Controller (Legacy)
---------------------------

For Site Root URI (Legacy)
^^^^^^^^^^^^^^^^^^^^^^^^^^

When a user visits the root of your site (i.e., example.com) the controller to use is determined by the value set by
the ``setDefaultController()`` method, unless a route exists for it explicitly. The default value for this is ``Home``
which matches the controller at **app/Controllers/Home.php**:
When a user visits the root of your site (i.e., **example.com**) the controller
to use is determined by the value set to the ``$defaultController`` property,
unless a route exists for it explicitly.

.. literalinclude:: routing/047.php
The default value for this is ``Home`` which matches the controller at
**app/Controllers/Home.php**::

public string $defaultController = 'Home';

For Directory URI (Legacy)
^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -914,10 +918,10 @@ This works similar to the default controller setting, but is used to determine t
when a controller is found that matches the URI, but no segment exists for the method. The default value is
``index``.

In this example, if the user were to visit **example.com/products**, and a ``Products`` controller existed, the
``Products::listAll()`` method would be executed:
In this example, if the user were to visit **example.com/products**, and a ``Products``
controller existed, the ``Products::listAll()`` method would be executed::

.. literalinclude:: routing/048.php
public string $defaultMethod = 'listAll';

Confirming Routes
*****************
Expand Down
4 changes: 0 additions & 4 deletions user_guide_src/source/incoming/routing/047.php

This file was deleted.

3 changes: 0 additions & 3 deletions user_guide_src/source/incoming/routing/048.php

This file was deleted.

12 changes: 6 additions & 6 deletions user_guide_src/source/libraries/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ To try your form, visit your site using a URL similar to this one::
example.com/index.php/form/

If you submit the form you should simply see the form reload. That's
because you haven't set up any validation rules in ``$this->validate()`` yet.
because you haven't set up any validation rules in :ref:`controller-validatedata` yet.

The ``validate()`` method is a method in the Controller. It uses
the **Validation class** inside. See :ref:`controllers-validating-data`.
The ``validateData()`` method is a method in the Controller. It uses
the **Validation class** inside. See :ref:`controller-validatedata`.

.. note:: Since you haven't told the ``validate()`` method to validate anything
yet, it **returns false** (boolean false) **by default**. The ``validate()``
.. note:: Since you haven't told the ``validateData()`` method to validate anything
yet, it **returns false** (boolean false) **by default**. The ``validateData()``
method only returns true if it has successfully applied your rules without
any of them failing.

Expand Down Expand Up @@ -189,7 +189,7 @@ It loads the form helper used by your view files.

The controller has one method: ``index()``. This method returns
the **signup** view to show the form when a non-POST request comes. Otherwise, it
uses the Controller-provided ``validate()`` method. It also runs the validation routine.
uses the Controller-provided :ref:`controller-validatedata` method. It also runs the validation routine.
Based on whether the validation was successful it either presents the
form or the success page.

Expand Down
8 changes: 6 additions & 2 deletions user_guide_src/source/libraries/validation/001.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ public function index()
return view('signup');
}

$rules = [];
$rules = [
// @TODO
];

if (! $this->validate($rules)) {
$data = $this->request->getPost(array_keys($rules));

if (! $this->validateData($data, $rules)) {
return view('signup');
}

Expand Down

0 comments on commit 99c67e8

Please sign in to comment.