1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
<?php
/**
* Labels Helper.
*
* @package Silla.IO
* @subpackage Core\Helpers;
* @author Plamen Nikolov <plamen@athlonsofia.com>
* @copyright Copyright (c) 2015, Silla.io
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3.0 (GPLv3)
*/
namespace Core\Helpers;
use Core;
/**
* Labels Helper Class definition.
*/
class YAML
{
/**
* Gets a defined label.
*
* @param string $key Key of the array.
* @param string $type Name of array group.
* @param string $locale Locale code.
*
* @access public
* @static
* @uses Core\Config()
* @uses \Spyc
*
* @return array|null
*/
public static function get($key, $type = 'cms', $locale = '')
{
if (!$locale) {
$locale = Core\Registry()->get('locale');
}
$labels = \Spyc::YAMLLoad(Core\Config()->paths('labels') . $locale . DIRECTORY_SEPARATOR . $type . '.yaml');
return isset($labels[$key]) ? $labels[$key] : null;
}
/**
* Gets all labels for a defined type.
*
* @param string $type Name of the array group.
* @param string $locale Locale code.
*
* @access public
* @static
* @uses Config()
* @uses \Spyc
*
* @return array
*/
public static function getAll($type, $locale = '')
{
if (!$locale) {
$locale = Core\Registry()->get('locale');
}
return \Spyc::YAMLLoad(Core\Config()->paths('labels') . $locale . DIRECTORY_SEPARATOR . $type . '.yaml');
}
}