PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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/**
10 * Helper to deal with generic data
11 * 
12 * @package Framework.Helpers
13 */
14class DataHelper extends AppHelper {
15
16	/**
17	 * Class Constructor
18	 * 
19	 * @param App $app A reference to the global App object
20	 */
21	public function __construct($app) {
22		parent::__construct($app);
23
24		// load class
25		$this->app->loader->register('AppData', 'classes:data.php');
26	}
27
28	/**
29	 * Create a data object
30	 * 
31	 * @param mixed $data The data to load
32	 * @param string $format The data format (default: json)
33	 * 
34	 * @return mixed The class representing the data
35	 * 
36	 * @since 1.0.0
37	 */
38	public function create($data = array(), $format = 'json') {
39		
40		// load data class
41		$class = $format.'Data';
42		$this->app->loader->register($class, 'data:'.strtolower($format).'.php');
43
44		return new $class($data);
45	}
46	
47}