PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/src/object/procedure/AbstractProcedure.class.php

https://bitbucket.org/stk2k/charcoalphp2.1
PHP | 117 lines | 69 code | 15 blank | 33 comment | 3 complexity | 3e5e6ceeb9c3daea500434d3680a3ca0 MD5 | raw file
  1. <?php
  2. /**
  3. * base class for procedure
  4. *
  5. * PHP version 5
  6. *
  7. * @package objects.procedures
  8. * @author CharcoalPHP Development Team
  9. * @copyright 2008 stk2k, sazysoft
  10. */
  11. abstract class Charcoal_AbstractProcedure extends Charcoal_CharcoalComponent implements Charcoal_IProcedure
  12. {
  13. const TAG = 'abstract_procedure';
  14. protected $task_manager;
  15. protected $forward_target;
  16. protected $modules;
  17. protected $events;
  18. protected $debug_mode;
  19. protected $log_enabled;
  20. protected $log_level;
  21. protected $log_loggers;
  22. /**
  23. * Initialize instance
  24. *
  25. * @param array $config configuration data
  26. */
  27. public function configure( $config )
  28. {
  29. parent::configure( $config );
  30. $config = new Charcoal_HashMap($config);
  31. $this->task_manager = us( $config->getString( 'task_manager', '' ) );
  32. $this->forward_target = us( $config->getString( 'forward_target', '' ) );
  33. $this->modules = uv( $config->getArray( 'modules', array() ) );
  34. $this->events = uv( $config->getArray( 'events', array() ) );
  35. $this->debug_mode = ub( $config->getBoolean( 'debug_mode', FALSE ) );
  36. $this->log_enabled = ub( $config->getBoolean( 'log_enabled' ) );
  37. $this->log_level = us( $config->getString( 'log_level' ) );
  38. $this->log_loggers = uv( $config->getArray( 'log_loggers' ) );
  39. // eventsに記載しているイベントのモジュールも読み込む
  40. if ( is_array($this->events) ){
  41. foreach( $this->events as $event ){
  42. $pos = strpos( $event, "@" );
  43. if ( $pos !== FALSE ){
  44. $this->modules[] = substr( $event, $pos );
  45. }
  46. }
  47. }
  48. if ( $this->getSandbox()->isDebug() )
  49. {
  50. log_info( "system, debug, config", "task_manager:" . $this->task_manager, self::TAG );
  51. log_info( "system, debug, config", "forward_target:" . $this->forward_target, self::TAG );
  52. log_info( "system, debug, config", "modules:" . print_r($this->modules,true), self::TAG );
  53. log_info( "system, debug, config", "events:" . print_r($this->events,true), self::TAG );
  54. log_info( "system, debug, config", "debug_mode" . $this->debug_mode, self::TAG );
  55. log_info( "system, debug, config", "log_enabled" . $this->log_enabled, self::TAG );
  56. log_info( "system, debug, config", "log_level" . $this->log_level, self::TAG );
  57. log_info( "system, debug, config", "log_loggers" . print_r($this->log_loggers,true), self::TAG );
  58. }
  59. }
  60. /*
  61. * returns TRUE if this procedure is debug mode
  62. */
  63. public function isDebugMode()
  64. {
  65. return $this->debug_mode;
  66. }
  67. /*
  68. * returns TRUE if logger is enabled
  69. */
  70. public function isLoggerEnabled()
  71. {
  72. return $this->log_enabled;
  73. }
  74. /*
  75. * returns log level
  76. */
  77. public function getLogLevel()
  78. {
  79. return $this->log_level;
  80. }
  81. /*
  82. * returns loggers
  83. */
  84. public function getLoggers()
  85. {
  86. return $this->log_loggers;
  87. }
  88. /*
  89. * 転送先があるか
  90. */
  91. public function hasForwardTarget()
  92. {
  93. return strlen($this->forward_target) > 0;
  94. }
  95. /*
  96. * 転送先を取得
  97. */
  98. public function getForwardTarget()
  99. {
  100. return new Charcoal_ObjectPath( $this->forward_target );
  101. }
  102. }