WriteYaml.php 924 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Typemill\Models;
  3. class WriteYaml extends Write
  4. {
  5. /**
  6. * Get the a yaml file.
  7. * @param string $fileName is the name of the Yaml Folder.
  8. * @param string $yamlFileName is the name of the Yaml File.
  9. */
  10. public function getYaml($folderName, $yamlFileName)
  11. {
  12. $yaml = $this->getFile($folderName, $yamlFileName);
  13. if($yaml)
  14. {
  15. return \Symfony\Component\Yaml\Yaml::parse($yaml);
  16. }
  17. return false;
  18. }
  19. /**
  20. * Writes a yaml file.
  21. * @param string $fileName is the name of the Yaml Folder.
  22. * @param string $yamlFileName is the name of the Yaml File.
  23. * @param array $contentArray is the content as an array.
  24. */
  25. public function updateYaml($folderName, $yamlFileName, $contentArray)
  26. {
  27. $yaml = \Symfony\Component\Yaml\Yaml::dump($contentArray,6);
  28. if($this->writeFile($folderName, $yamlFileName, $yaml))
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. }