ErrorControl.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace ZN\Foundations\Traits;
  3. trait ErrorControlTrait
  4. {
  5. /* Error Değişkeni
  6. *
  7. * Dosya işlemlerinde oluşan hata bilgilerini
  8. * tutması için oluşturulmuştur.
  9. *
  10. */
  11. protected $error;
  12. //----------------------------------------------------------------------------------------------------
  13. // Protected Success
  14. //----------------------------------------------------------------------------------------------------
  15. //
  16. // Oluşan başarı bilgisi
  17. //
  18. // @var string
  19. //
  20. //----------------------------------------------------------------------------------------------------
  21. protected $success;
  22. /******************************************************************************************
  23. * ERROR *
  24. *******************************************************************************************
  25. | Genel Kullanım: Dizin işlemlerinde oluşan hata bilgilerini tutması için oluşturulmuştur.|
  26. | |
  27. | Parametreler: Herhangi bir parametresi yoktur. |
  28. | |
  29. ******************************************************************************************/
  30. public function error()
  31. {
  32. if( isset($this->error) )
  33. {
  34. return $this->error;
  35. }
  36. elseif( $error = \Errors::get(str_ireplace(STATIC_ACCESS, '', __CLASS__)) )
  37. {
  38. return $error;
  39. }
  40. else
  41. {
  42. return false;
  43. }
  44. }
  45. //----------------------------------------------------------------------------------------------------
  46. // Success
  47. //----------------------------------------------------------------------------------------------------
  48. //
  49. // @param void
  50. // @return string
  51. //
  52. //----------------------------------------------------------------------------------------------------
  53. public function success()
  54. {
  55. if( empty($this->error) && ! \Errors::get(str_ireplace(STATIC_ACCESS, '', __CLASS__)) )
  56. {
  57. if( ! empty($this->success) )
  58. {
  59. return $this->success;
  60. }
  61. else
  62. {
  63. return lang('Success', 'success');
  64. }
  65. }
  66. else
  67. {
  68. return false;
  69. }
  70. }
  71. }