/administrator/components/com_zoo/framework/helpers/data.php

https://gitlab.com/vnsoftdev/amms · PHP · 47 lines · 12 code · 7 blank · 28 comment · 0 complexity · 769d4db7db84f2f5d2258738509a8374 MD5 · raw file

  1. <?php
  2. /**
  3. * @package com_zoo
  4. * @author YOOtheme http://www.yootheme.com
  5. * @copyright Copyright (C) YOOtheme GmbH
  6. * @license http://www.gnu.org/licenses/gpl.html GNU/GPL
  7. */
  8. /**
  9. * Helper to deal with generic data
  10. *
  11. * @package Framework.Helpers
  12. */
  13. class DataHelper extends AppHelper {
  14. /**
  15. * Class Constructor
  16. *
  17. * @param App $app A reference to the global App object
  18. */
  19. public function __construct($app) {
  20. parent::__construct($app);
  21. // load class
  22. $this->app->loader->register('AppData', 'classes:data.php');
  23. }
  24. /**
  25. * Create a data object
  26. *
  27. * @param mixed $data The data to load
  28. * @param string $format The data format (default: json)
  29. *
  30. * @return mixed The class representing the data
  31. *
  32. * @since 1.0.0
  33. */
  34. public function create($data = array(), $format = 'json') {
  35. // load data class
  36. $class = $format.'Data';
  37. $this->app->loader->register($class, 'data:'.strtolower($format).'.php');
  38. return new $class($data);
  39. }
  40. }