Languages.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * @package Grav\Common\Config
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Config;
  9. use Grav\Common\Data\Data;
  10. use Grav\Common\Utils;
  11. class Languages extends Data
  12. {
  13. /**
  14. * @var string|null
  15. */
  16. protected $checksum;
  17. /**
  18. * @var string|null
  19. */
  20. protected $modified;
  21. /**
  22. * @var string|null
  23. */
  24. protected $timestamp;
  25. public function checksum($checksum = null)
  26. {
  27. if ($checksum !== null) {
  28. $this->checksum = $checksum;
  29. }
  30. return $this->checksum;
  31. }
  32. public function modified($modified = null)
  33. {
  34. if ($modified !== null) {
  35. $this->modified = $modified;
  36. }
  37. return $this->modified;
  38. }
  39. public function timestamp($timestamp = null)
  40. {
  41. if ($timestamp !== null) {
  42. $this->timestamp = $timestamp;
  43. }
  44. return $this->timestamp;
  45. }
  46. public function reformat()
  47. {
  48. if (isset($this->items['plugins'])) {
  49. $this->items = array_merge_recursive($this->items, $this->items['plugins']);
  50. unset($this->items['plugins']);
  51. }
  52. }
  53. public function mergeRecursive(array $data)
  54. {
  55. $this->items = Utils::arrayMergeRecursiveUnique($this->items, $data);
  56. }
  57. public function flattenByLang($lang)
  58. {
  59. $language = $this->items[$lang];
  60. return Utils::arrayFlattenDotNotation($language);
  61. }
  62. public function unflatten($array)
  63. {
  64. return Utils::arrayUnflattenDotNotation($array);
  65. }
  66. }