Skip to content

Commit 3d00d96

Browse files
committed
docs: use use keyword
1 parent fa236f7 commit 3d00d96

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

user_guide_src/source/tutorial/news_section.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ add some code to the controller and create a new view. Go back to the
166166

167167
.. literalinclude:: news_section/006.php
168168

169+
Don't forget add ``use CodeIgniter\Exceptions\PageNotFoundException;`` to import
170+
the ``PageNotFoundException`` class.
171+
169172
Instead of calling the ``getNews()`` method without a parameter, the
170173
``$slug`` variable is passed, so it will return the specific news item.
171174
The only thing left to do is create the corresponding view at

user_guide_src/source/tutorial/news_section/006.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Controllers;
44

55
use App\Models\NewsModel;
6+
use CodeIgniter\Exceptions\PageNotFoundException;
67

78
class News extends BaseController
89
{
@@ -15,7 +16,7 @@ public function view($slug = null)
1516
$data['news'] = $model->getNews($slug);
1617

1718
if (empty($data['news'])) {
18-
throw new \CodeIgniter\Exceptions\PageNotFoundException('Cannot find the news item: ' . $slug);
19+
throw new PageNotFoundException('Cannot find the news item: ' . $slug);
1920
}
2021

2122
$data['title'] = $data['news']['title'];

user_guide_src/source/tutorial/static_pages.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ in the ``Pages`` controller created above:
8989

9090
.. literalinclude:: static_pages/002.php
9191

92+
And add ``use CodeIgniter\Exceptions\PageNotFoundException;`` after the ``namespace`` line
93+
to import the ``PageNotFoundException`` class.
94+
9295
Now, when the requested page does exist, it is loaded, including the header and
9396
footer, and returned to the user. If a controller returns a string, it is
9497
displayed to the user.

user_guide_src/source/tutorial/static_pages/002.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace App\Controllers;
44

5+
use CodeIgniter\Exceptions\PageNotFoundException; // Add this line
6+
57
class Pages extends BaseController
68
{
79
// ...
@@ -10,7 +12,7 @@ public function view($page = 'home')
1012
{
1113
if (! is_file(APPPATH . 'Views/pages/' . $page . '.php')) {
1214
// Whoops, we don't have a page for that!
13-
throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
15+
throw new PageNotFoundException($page);
1416
}
1517

1618
$data['title'] = ucfirst($page); // Capitalize the first letter

0 commit comments

Comments
 (0)