Change Details
| src/Pluf/Shortcuts.php |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | * Get an object by SQL or raise a 404 error. |
| 48 | * |
| 49 | * Usage: |
| 50 | * <pre> |
| 51 | * $obj = Pluf_Shortcuts_GetOneOr404('MyApp_Model', |
| 52 | * 'path=%s AND status=%s', |
| 53 | * array('welcome', 1)); |
| 54 | * </pre> |
| 55 | * |
| 56 | * @param string Model |
| 57 | * @param string Base SQL request |
| 58 | * @param string Parameters for the base SQL |
| 59 | * @return Object The found object |
| 60 | */ |
| 61 | function Pluf_Shortcuts_GetOneOr404($object, $bsql, $psql) |
| 62 | { |
| 63 | $sql = new Pluf_SQL($bsql, $psql); |
| 64 | $item = Pluf::factory($object)->getOne(array('filter' => $sql->gen())); |
| 65 | if ($item != null) { |
| 66 | return $item; |
| 67 | } |
| 68 | throw new Pluf_HTTP_Error404(); |
| 69 | } |
| 70 | |
| 71 | /** |
| 47 | 72 | * Render a template file and an array as a reponse. |
| 48 | 73 | * |
| 49 | 74 | * If a none null request object is given, the context used will |
Download the corresponding diff file