1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-16 01:54:28 +02:00

Menus: Implementation

This commit is contained in:
Awilum
2018-12-24 22:54:05 +03:00
parent 179b40d766
commit b8ef201173

38
flextype/Menus.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
/**
* @package Flextype
*
* @author Sergey Romanenko <awilum@yandex.ru>
* @link http://flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use Flextype\Component\Filesystem\Filesystem;
class Menus
{
/**
* Get menu
*
* Menu::get('menu-name');
*
* @access public
* @param string $menu_name Menu name
* @return array
*/
public static function get(string $menu_name)
{
$menu_path = PATH['menus'] . '/' . $menu_name . '.yaml';
if (Filesystem::fileExists($menu_path)) {
return YamlParser::decode(Filesystem::getFileContent($menu_path));
} else {
throw new \RuntimeException("Menu {$menu_name} does not exist.");
}
}
}