Core.php 838 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace PhpLife\Config\Sphinx;
  3. use PhpLife\Frame\Config;
  4. /**
  5. * Sphinx配置
  6. */
  7. class Core extends Config
  8. {
  9. protected static $dataFile = 'sphinx/core.json';
  10. protected static $data = array();
  11. /**
  12. * 获取配置信息,
  13. * 如果配置了$dataFile则读取后者中的数据
  14. * @param null $section
  15. * @param bool $is_pre
  16. * @return array|null|string
  17. */
  18. public static function getData($section = null, $is_pre = FALSE)
  19. {
  20. $class = get_called_class();
  21. $path = self::getPathByMode($class::$dataFile, $is_pre);
  22. $data = self::readFile($path);
  23. if (! is_null($section)) {
  24. if (isset($data[$section])) {
  25. return $data[$section];
  26. } else {
  27. return null;
  28. }
  29. }
  30. return $data;
  31. }
  32. }