mirror of
https://github.com/flextype/flextype.git
synced 2025-08-16 01:54:28 +02:00
Menus: Implementation
This commit is contained in:
38
flextype/Menus.php
Normal file
38
flextype/Menus.php
Normal 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.");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user