Browse Source

guess resource name

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
5a15ac240a
2 changed files with 9 additions and 3 deletions
  1. 7
    1
      src/Utils/LuBusiness.php
  2. 2
    2
      src/Utils/LuDataAccess.php

+ 7
- 1
src/Utils/LuBusiness.php View File

@@ -110,7 +110,7 @@ abstract class LuBusiness {
110 110
     {
111 111
         $data = static::getDataAccess()->getById($id);
112 112
         if (is_null($data))
113
-            self::notFound();
113
+            self::notFound(static::getResourceName() . " not found");
114 114
         return $data;
115 115
     }
116 116
 
@@ -134,4 +134,10 @@ abstract class LuBusiness {
134 134
     {
135 135
         return static::getDataAccess()->getAll($page, $perPage);
136 136
     }
137
+
138
+    public static function getResourceName()
139
+    {
140
+        $class = preg_replace('/([^\\\\]*)Business$/', '${1}', get_called_class());
141
+        return $class;
142
+    }
137 143
 }

+ 2
- 2
src/Utils/LuDataAccess.php View File

@@ -107,7 +107,7 @@ abstract class LuDataAccess {
107 107
     /**
108 108
      * @return LuModel
109 109
      */
110
-    private static function getModel()
110
+    protected static function getModel()
111 111
     {
112 112
         return null;
113 113
     }
@@ -115,7 +115,7 @@ abstract class LuDataAccess {
115 115
     /**
116 116
      * @return array
117 117
      */
118
-    private static function getOrderBy()
118
+    protected static function getOrderBy()
119 119
     {
120 120
         return array();
121 121
     }

Loading…
Cancel
Save