<?php
/**
 * Contract for a menu source adapter.
 *
 * @package MenuVerse
 */

namespace WPXero\MenuVerse\Menus;

defined( 'ABSPATH' ) || exit;

/**
 * A menu source adapts one of WordPress' menu stores to the normalized tree
 * every MenuVerse module consumes. MenuVerse deliberately ships no menu store
 * of its own.
 */
interface Menu_Source {

	/**
	 * Returns the source identifier used in REST routes and settings.
	 *
	 * @return string
	 */
	public function id();

	/**
	 * Returns the translated source label.
	 *
	 * @return string
	 */
	public function label();

	/**
	 * Lists the menus available from this source.
	 *
	 * @return array[] Each entry has id, name, count and locations keys.
	 */
	public function list_menus();

	/**
	 * Determines whether a menu exists in this source.
	 *
	 * @param int|string $menu_id Menu identifier.
	 * @return bool
	 */
	public function exists( $menu_id );

	/**
	 * Returns the normalized tree for a menu.
	 *
	 * @param int|string $menu_id Menu identifier.
	 * @return Menu_Tree|null
	 */
	public function get_tree( $menu_id );
}
