Skip to content

Commit 9a15f48

Browse files
committed
define Controller Registry to manage instances of all REST API controllers
1 parent 695edaa commit 9a15f48

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace DotOrg\TryWordPress;
4+
5+
class Controller_Registry {
6+
7+
public function __construct( string $liberated_data_post_type, string $crawler_data_post_type ) {
8+
new Blogpost_Controller( $liberated_data_post_type );
9+
new Page_Controller( $liberated_data_post_type );
10+
}
11+
}

src/plugin/class-engine.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function __construct() {
1515
require 'class-liberate-controller.php';
1616
require 'class-blogpost-controller.php';
1717
require 'class-page-controller.php';
18+
require 'class-controller-registry.php';
1819
require 'class-storage.php';
1920
require 'class-subject.php';
2021
require 'class-subject-repo.php';
@@ -24,9 +25,7 @@ public function __construct() {
2425

2526
new Post_Type_UI( self::LIBERATED_DATA_POST_TYPE, self::CRAWLER_DATA_POST_TYPE, $transformer );
2627

27-
// REST API
28-
new Blogpost_Controller( self::LIBERATED_DATA_POST_TYPE );
29-
new Page_Controller( self::LIBERATED_DATA_POST_TYPE );
28+
new Controller_Registry( self::LIBERATED_DATA_POST_TYPE, self::CRAWLER_DATA_POST_TYPE );
3029

3130
new Storage( self::LIBERATED_DATA_POST_TYPE, self::CRAWLER_DATA_POST_TYPE );
3231

0 commit comments

Comments
 (0)