Expirable_Items.php
1 year ago
Expirables.php
9 months ago
REST_Expirable_Items_Controller.php
1 year ago
Expirables.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class Google\Site_Kit\Core\Expirables\Expirables |
| 4 | * |
| 5 | * @package Google\Site_Kit\Core\Expirables |
| 6 | * @copyright 2024 Google LLC |
| 7 | * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 |
| 8 | * @link https://sitekit.withgoogle.com |
| 9 | */ |
| 10 | |
| 11 | namespace Google\Site_Kit\Core\Expirables; |
| 12 | |
| 13 | use Google\Site_Kit\Core\Expirables\Expirable_Items; |
| 14 | use Google\Site_Kit\Core\Expirables\REST_Expirable_Items_Controller; |
| 15 | use Google\Site_Kit\Context; |
| 16 | use Google\Site_Kit\Core\Storage\User_Options; |
| 17 | |
| 18 | /** |
| 19 | * Class for handling expirables. |
| 20 | * |
| 21 | * @since 1.128.0 |
| 22 | * @access private |
| 23 | * @ignore |
| 24 | */ |
| 25 | class Expirables { |
| 26 | |
| 27 | /** |
| 28 | * Expirable_Items instance. |
| 29 | * |
| 30 | * @since 1.128.0 |
| 31 | * @var Expirable_Items |
| 32 | */ |
| 33 | protected $expirable_items; |
| 34 | |
| 35 | /** |
| 36 | * REST_Expirable_Items_Controller instance. |
| 37 | * |
| 38 | * @since 1.128.0 |
| 39 | * @var REST_Expirable_Items_Controller |
| 40 | */ |
| 41 | protected $rest_controller; |
| 42 | |
| 43 | /** |
| 44 | * Constructor. |
| 45 | * |
| 46 | * @since 1.128.0 |
| 47 | * |
| 48 | * @param Context $context Plugin context. |
| 49 | * @param User_Options $user_options Optional. User option API. Default is a new instance. |
| 50 | */ |
| 51 | public function __construct( Context $context, ?User_Options $user_options = null ) { |
| 52 | $this->expirable_items = new Expirable_Items( $user_options ?: new User_Options( $context ) ); |
| 53 | $this->rest_controller = new REST_Expirable_Items_Controller( $this->expirable_items ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Gets the reference to the Expirable_Items instance. |
| 58 | * |
| 59 | * @since 1.128.0 |
| 60 | * |
| 61 | * @return Expirable_Items An instance of the Expirable_Items class. |
| 62 | */ |
| 63 | public function get_expirable_items() { |
| 64 | return $this->expirable_items; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Registers functionality through WordPress hooks. |
| 69 | * |
| 70 | * @since 1.128.0 |
| 71 | */ |
| 72 | public function register() { |
| 73 | $this->expirable_items->register(); |
| 74 | $this->rest_controller->register(); |
| 75 | } |
| 76 | } |
| 77 |