Browse Source

guess resource name

tags/0.1.0
Robin Thoni 8 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
     {
110
     {
111
         $data = static::getDataAccess()->getById($id);
111
         $data = static::getDataAccess()->getById($id);
112
         if (is_null($data))
112
         if (is_null($data))
113
-            self::notFound();
113
+            self::notFound(static::getResourceName() . " not found");
114
         return $data;
114
         return $data;
115
     }
115
     }
116
 
116
 
134
     {
134
     {
135
         return static::getDataAccess()->getAll($page, $perPage);
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
     /**
107
     /**
108
      * @return LuModel
108
      * @return LuModel
109
      */
109
      */
110
-    private static function getModel()
110
+    protected static function getModel()
111
     {
111
     {
112
         return null;
112
         return null;
113
     }
113
     }
115
     /**
115
     /**
116
      * @return array
116
      * @return array
117
      */
117
      */
118
-    private static function getOrderBy()
118
+    protected static function getOrderBy()
119
     {
119
     {
120
         return array();
120
         return array();
121
     }
121
     }

Loading…
Cancel
Save