| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPGraphQL\Type\ObjectType; |
| 4 |
|
| 5 |
use WPGraphQL\Model\Menu as MenuModel; |
| 6 |
|
| 7 |
class Menu { |
| 8 |
|
| 9 |
/** |
| 10 |
* Register the Menu object type |
| 11 |
* |
| 12 |
* @return void |
| 13 |
*/ |
| 14 |
public static function register_type() { |
| 15 |
register_graphql_object_type( |
| 16 |
'Menu', |
| 17 |
[ |
| 18 |
'description' => static function () { |
| 19 |
return __( 'Collections of navigation links. Menus can be assigned to designated locations and used to build site navigation structures.', 'wp-graphql' ); |
| 20 |
}, |
| 21 |
'interfaces' => [ 'Node', 'DatabaseIdentifier' ], |
| 22 |
'model' => MenuModel::class, |
| 23 |
'fields' => static function () { |
| 24 |
return [ |
| 25 |
'id' => [ |
| 26 |
'description' => static function () { |
| 27 |
return __( 'The globally unique identifier of the nav menu object.', 'wp-graphql' ); |
| 28 |
}, |
| 29 |
], |
| 30 |
'count' => [ |
| 31 |
'type' => 'Int', |
| 32 |
'description' => static function () { |
| 33 |
return __( 'The number of items in the menu', 'wp-graphql' ); |
| 34 |
}, |
| 35 |
], |
| 36 |
'menuId' => [ |
| 37 |
'type' => 'Int', |
| 38 |
'description' => static function () { |
| 39 |
return __( 'WP ID of the nav menu.', 'wp-graphql' ); |
| 40 |
}, |
| 41 |
'deprecationReason' => static function () { |
| 42 |
return __( 'Deprecated in favor of the databaseId field', 'wp-graphql' ); |
| 43 |
}, |
| 44 |
], |
| 45 |
'name' => [ |
| 46 |
'type' => 'String', |
| 47 |
'description' => static function () { |
| 48 |
return __( 'Display name of the menu.', 'wp-graphql' ); |
| 49 |
}, |
| 50 |
], |
| 51 |
'slug' => [ |
| 52 |
'type' => 'String', |
| 53 |
'description' => static function () { |
| 54 |
return __( 'The url friendly name of the menu.', 'wp-graphql' ); |
| 55 |
}, |
| 56 |
], |
| 57 |
'isRestricted' => [ |
| 58 |
'type' => 'Boolean', |
| 59 |
'description' => static function () { |
| 60 |
return __( 'Whether the object is restricted from the current viewer', 'wp-graphql' ); |
| 61 |
}, |
| 62 |
], |
| 63 |
'locations' => [ |
| 64 |
'type' => [ |
| 65 |
'list_of' => 'MenuLocationEnum', |
| 66 |
], |
| 67 |
'description' => static function () { |
| 68 |
return __( 'The locations a menu is assigned to', 'wp-graphql' ); |
| 69 |
}, |
| 70 |
], |
| 71 |
]; |
| 72 |
}, |
| 73 |
] |
| 74 |
); |
| 75 |
} |
| 76 |
} |
| 77 |
|