ReaderCronTask.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\CommandLine;
  3. use ThurData\Servers\KerioEmail\Core\FileReader\Reader;
  4. use ThurData\Servers\KerioEmail\Core\ModuleConstants;
  5. /**
  6. * Description of AbstractReaderYml
  7. *
  8. * @autor ThurData <info@thurdata.ch>
  9. */
  10. class ReaderCronTask
  11. {
  12. /**
  13. * @var array
  14. */
  15. protected $data = [];
  16. public function __construct()
  17. {
  18. if (count($this->data) == 0)
  19. {
  20. $this->load();
  21. }
  22. }
  23. public function getData()
  24. {
  25. return $this->data;
  26. }
  27. protected function readYml($name)
  28. {
  29. return Reader::read($name)->get();
  30. }
  31. public static function get()
  32. {
  33. $instance = new static;
  34. return $instance->getData();
  35. }
  36. protected function load()
  37. {
  38. $this->data = $this->rebuildData($this->readYml(ModuleConstants::getFullPath('app', 'Config', 'cron.yml')));
  39. }
  40. protected function rebuildData($data)
  41. {
  42. $return = [];
  43. foreach ($data['list'] as $name => $isRun)
  44. {
  45. if ((bool)$isRun)
  46. {
  47. $return[] = $name;
  48. }
  49. }
  50. return $return;
  51. }
  52. }