PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.0
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.0
6.2.1 6.2.0 6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / libraries / framework / Exceptions / ModelNotFoundException.php
kirki / libraries / framework / Exceptions Last commit date
AuthorizationException.php 1 month ago InvalidCastException.php 1 month ago InvalidDateFormatException.php 1 week ago InvalidMiddlewareException.php 1 month ago InvalidRoutActionException.php 1 month ago InvalidValidationRuleException.php 1 month ago MassAssignmentException.php 1 month ago ModelNotFoundException.php 1 month ago MultipleRecordsFoundException.php 1 month ago NotFoundException.php 1 month ago QueryException.php 1 month ago RecordNotFoundException.php 1 month ago UniqueConstraintViolationException.php 1 month ago ValidationException.php 1 month ago
ModelNotFoundException.php
112 lines
1 <?php
2
3 /**
4 * Exception thrown when a model (database record) is not found.
5 *
6 * @package Framework
7 * @subpackage Exceptions
8 * @since 1.0.0
9 */
10 namespace Kirki\Framework\Exceptions;
11
12 \defined('ABSPATH') || exit;
13 use Kirki\Framework\Supports\Arr;
14 use function Kirki\Framework\message;
15 class ModelNotFoundException extends NotFoundException
16 {
17 /**
18 * The model class name being queried.
19 *
20 * @var string
21 *
22 * @since 1.0.0
23 */
24 protected $model;
25 /**
26 * The IDs or route keys that were searched for.
27 *
28 * @var mixed
29 *
30 * @since 1.0.0
31 */
32 protected $ids;
33 /**
34 * Create a new ModelNotFoundException instance.
35 *
36 * @param string $model The model class name.
37 * @param mixed $ids The ID(s) or route key(s) searched for.
38 *
39 * @return void
40 *
41 * @since 1.0.0
42 */
43 public function __construct($model, $ids = [])
44 {
45 $this->model = $model;
46 $this->ids = $ids;
47 $this->prepare_message();
48 }
49 /**
50 * Set the model class name for the exception.
51 *
52 * @param string $model The model class name.
53 *
54 * @return void
55 *
56 * @since 1.0.0
57 */
58 public function set_model($model)
59 {
60 $this->model = $model;
61 $this->prepare_message();
62 }
63 /**
64 * Set the IDs or route keys that were searched for.
65 *
66 * @param mixed $ids The ID(s) or route key(s).
67 *
68 * @return void
69 *
70 * @since 1.0.0
71 */
72 public function set_ids($ids)
73 {
74 $this->ids = $ids;
75 $this->prepare_message();
76 }
77 /**
78 * Get the model class name.
79 *
80 * @return string
81 *
82 * @since 1.0.0
83 */
84 public function get_model()
85 {
86 return $this->model;
87 }
88 /**
89 * Get the ID(s) or route key(s).
90 *
91 * @return mixed
92 *
93 * @since 1.0.0
94 */
95 public function get_ids()
96 {
97 return $this->ids;
98 }
99 /**
100 * Prepare the exception message using the model and ids.
101 *
102 * @return void
103 *
104 * @since 1.0.0
105 */
106 protected function prepare_message()
107 {
108 $ids = Arr::wrap($this->ids);
109 $this->message = message('model.not_found', $this->model, \implode(', ', $ids));
110 }
111 }
112