PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/trasweb/common/awaiters/trasweb/Critical.php

https://bitbucket.org/trasweb/trasweb-framework
PHP | 83 lines | 34 code | 16 blank | 33 comment | 6 complexity | b6e98985ca70c5c2c93a94e8738251a6 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. New Licence bsd:
  4. Copyright (c) <2012>, Manuel Jesus Canga Mu?oz
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without
  7. modification, are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions and the following disclaimer in the
  12. documentation and/or other materials provided with the distribution.
  13. * Neither the name of the Trasweb.net nor the
  14. names of its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  17. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. DISCLAIMED. IN NO EVENT SHALL Manuel Jesus Canga Mu?oz BE LIABLE FOR ANY
  20. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. namespace awaiters\trasweb\trasweb;
  28. /**
  29. Esta esperando siempre que surja un criitical.
  30. Si al final sucede, tratar de cargar la plantilla /common/views/maintenance.tpl
  31. Meta ahi su contenido, o mejor aun, crease su propio awaiter critical en su componente por defecto
  32. */
  33. class Critical extends \Awaiter{
  34. public function perform() {
  35. if(!empty($this->data) ) {
  36. $error = array(
  37. 'msg' => $this->data->msg,
  38. 'file' =>$this->data->file,
  39. 'line' => $this->data->line,
  40. 'function' => $this->data->function,
  41. 'class' => $this->data->class,
  42. 'condename' => $this->data->codeName
  43. );
  44. }else {
  45. $error = @error_get_last();
  46. }
  47. if(class_exists("\Log", false ) ) {
  48. \Log::trasweb("CRITICAL", print_r($error, true) );
  49. }else {
  50. @error_log("CRITICAL: ".print_r($error, true) );
  51. }
  52. if(!$this->params->component || ( defined("\SHOW_ERRORS") && ! \SHOW_ERRORS ) ) {
  53. ob_clean();
  54. }
  55. if(defined("\CRITICAL_MESSAGE") )
  56. $error['msg_maintenance']= \CRITICAL_MESSAGE;
  57. else
  58. $error['msg_maintenance'] = "We are in Maintenance, sorry";
  59. $error["out"] = "html";
  60. $maintenance = new \trasweb\messages($error);
  61. echo $maintenance->maintenance();
  62. die();
  63. }
  64. }