Advertisement
Guest User

rec

a guest
Oct 24th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Flight::map('recursiveRemoval',function(&$array, $rKey){
  2. if(is_array($array))
  3. {
  4. foreach($array as $key=>&$arrayElement)
  5. {
  6. if(is_array($arrayElement))
  7. {
  8. Flight::recursiveRemoval($arrayElement, $rKey);
  9. }
  10. else
  11. {
  12. if($key == $rKey)
  13. {
  14. unset($array[$rKey]);
  15. }
  16. }
  17. }
  18. }
  19. });
  20.  
  21.  
  22. $tmp = array('text','name');
  23.  
  24. Flight::recursiveRemoval($tmp, 'text');
  25.  
  26.  
  27.  
  28. ///info
  29.  
  30. Overriding
  31.  
  32. Flight allows you to override its default functionality to suit your own needs, without having to modify any code.
  33.  
  34. For example, when Flight cannot match a URL to a route, it invokes the notFound method which sends a generic HTTP 404 response. You can override this behavior by using the map method:
  35.  
  36. Flight::map('notFound', function(){
  37. // Display custom 404 page
  38. include 'errors/404.html';
  39. });
  40. Flight also allows you to replace core components of the framework. For example you can replace the default Router class with your own custom class:
  41.  
  42. // Register your custom class
  43. Flight::register('router', 'MyRouter');
  44.  
  45. // When Flight loads the Router instance, it will load your class
  46. $myrouter = Flight::router();
  47. Framework methods like map and register however cannot be overridden. You will get an error if you try to do so.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement