aboutsummaryrefslogtreecommitdiff
path: root/app/class/Route.php
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2019-11-04 23:31:31 +0100
committern-peugnet <n.peugnet@free.fr>2019-11-05 19:06:40 +0100
commite802d5204b96d645ec3d40b81b4a8bdc6e0ee675 (patch)
tree8e6db5e36ad8f247b442583e1e9e5da2934f4b52 /app/class/Route.php
parentf1f63f556c41c99d45cd610186b0982383eff375 (diff)
downloadwcms-e802d5204b96d645ec3d40b81b4a8bdc6e0ee675.tar.gz
wcms-e802d5204b96d645ec3d40b81b4a8bdc6e0ee675.zip
refactor: switch to psr-4 autoloading
Diffstat (limited to 'app/class/Route.php')
-rw-r--r--app/class/Route.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/app/class/Route.php b/app/class/Route.php
new file mode 100644
index 0000000..4f2a6de
--- /dev/null
+++ b/app/class/Route.php
@@ -0,0 +1,86 @@
+<?php
+
+namespace Wcms;
+
+class Route
+{
+ protected $id = null;
+ protected $aff = null;
+ protected $action = null;
+ protected $redirect = null;
+
+ const AFF = ['read', 'edit', 'admin', 'media'];
+
+ public function __construct($vars)
+ {
+ $this->hydrate($vars);
+ }
+
+ public function hydrate($vars)
+ {
+ foreach ($vars as $var => $value) {
+ $method = 'set' . $var;
+ if (method_exists($this, $method)) {
+ $this->$method($value);
+ }
+ }
+ }
+
+ public function toarray()
+ {
+ $array = [];
+ if (!empty($this->id)) {
+ $array[] = 'page';
+ }
+ if (!empty($this->aff)) {
+ $array[] = 'aff='.$this->aff;
+ }
+ if (!empty($this->action)) {
+ $array[] = 'action=' . $this->action;
+ }
+ if (!empty($this->redirect)) {
+ $array[] = $this->redirect;
+ }
+
+
+ return $array;
+ }
+
+ function tostring()
+ {
+ return implode(' ', $this->toarray());
+ }
+
+
+
+ public function setid($id)
+ {
+ $this->id = $id;
+ }
+
+ public function setaff($aff)
+ {
+ $this->aff = $aff;
+
+ }
+
+ public function setaction($action)
+ {
+ $this->action = $action;
+ }
+
+ public function setredirect($redirect)
+ {
+ $this->redirect = $redirect;
+ }
+
+ public function id()
+ {
+ return $this->id;
+ }
+}
+
+
+
+
+?> \ No newline at end of file