Skip to content
This repository was archived by the owner on Sep 26, 2019. It is now read-only.

Commit 84b6d68

Browse files
author
Felix Arntz
committed
Introduce Admin_Page_Collection interface.
1 parent 255b4d4 commit 84b6d68

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/Admin_Page_Collection.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Admin_Page_Collection interface
4+
*
5+
* @package Leaves_And_Love\OOP_Admin_Pages
6+
* @since 1.0.0
7+
*/
8+
9+
namespace Leaves_And_Love\OOP_Admin_Pages;
10+
11+
use Leaves_And_Love\OOP_Admin_Pages\Exception\Admin_Page_Not_Found_Exception;
12+
13+
/**
14+
* Interface to manage admin page instances.
15+
*
16+
* @since 1.0.0
17+
*/
18+
interface Admin_Page_Collection {
19+
20+
/**
21+
* Registers the admin pages in the collection within the environment.
22+
*
23+
* @since 1.0.0
24+
*/
25+
public function register();
26+
27+
/**
28+
* Checks whether an admin page is part of the collection.
29+
*
30+
* @since 1.0.0
31+
*
32+
* @param string $slug Identifier of the admin page to check for.
33+
* @return bool True if the admin page is part of the collection, false otherwise.
34+
*/
35+
public function has_page( string $slug ) : bool;
36+
37+
/**
38+
* Gets an admin page instance that is part of the collection.
39+
*
40+
* @since 1.0.0
41+
*
42+
* @param string $slug Identifier of the admin page to get.
43+
* @return Admin_Page Admin page instance.
44+
*
45+
* @throws Admin_Page_Not_Found_Exception Thrown when the admin page is not found.
46+
*/
47+
public function get_page( string $slug ) : Admin_Page;
48+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Admin_Page_Not_Found_Exception class
4+
*
5+
* @package Leaves_And_Love\OOP_Admin_Pages\Exception
6+
* @since 1.0.0
7+
*/
8+
9+
namespace Leaves_And_Love\OOP_Admin_Pages\Exception;
10+
11+
use Exception;
12+
13+
/**
14+
* Exception thrown when an admin page is not found in a collection.
15+
*
16+
* @since 1.0.0
17+
*/
18+
class Admin_Page_Not_Found_Exception extends Exception {
19+
20+
}

0 commit comments

Comments
 (0)