diff --git a/lib/Config/Initializer.php b/lib/Config/Initializer.php index df683ab78c..2a87d903cd 100644 --- a/lib/Config/Initializer.php +++ b/lib/Config/Initializer.php @@ -120,8 +120,12 @@ class Initializer { } try { + // legacy router $this->setupRouter(); + // new api (will replace legacy router completely) $this->setupAPI(); + + $this->setupFrontRouter(); $this->setupPages(); } catch(\Exception $e) { $this->handleFailedInitialization($e); @@ -187,8 +191,12 @@ class Initializer { } function setupAPI() { - $API = new \MailPoet\API\API(); - $API->init(); + + } + + function setupFrontRouter() { + $router = new Router\Front(); + $router->init(); } function runQueueSupervisor() { diff --git a/lib/Cron/CronHelper.php b/lib/Cron/CronHelper.php index 60c35b539f..72b1a4ea4f 100644 --- a/lib/Cron/CronHelper.php +++ b/lib/Cron/CronHelper.php @@ -1,8 +1,8 @@ $token); - $url = API::buildRequest( - QueueAPI::ENDPOINT, - QueueAPI::ACTION_RUN, + $url = FrontRouter::buildRequest( + QueueEndpoint::ENDPOINT, + QueueEndpoint::ACTION_RUN, $data ); $args = array( diff --git a/lib/Newsletter/Links/Links.php b/lib/Newsletter/Links/Links.php index 9846eb02a6..f7066f9476 100644 --- a/lib/Newsletter/Links/Links.php +++ b/lib/Newsletter/Links/Links.php @@ -1,8 +1,8 @@ $queue_id, 'hash' => $hash ); - $API_action = ($matches[2][$index] === self::DATA_TAG_CLICK) ? - TrackAPI::ACTION_CLICK : - TrackAPI::ACTION_OPEN; - $link = API::buildRequest( - TrackAPI::ENDPOINT, - $API_action, + $router_action = ($matches[2][$index] === self::DATA_TAG_CLICK) ? + TrackEndpoint::ACTION_CLICK : + TrackEndpoint::ACTION_OPEN; + $link = FrontRouter::buildRequest( + TrackEndpoint::ENDPOINT, + $router_action, $data ); $content = str_replace($match, $link, $content); diff --git a/lib/Newsletter/Url.php b/lib/Newsletter/Url.php index c71c627e91..18e52fa34c 100644 --- a/lib/Newsletter/Url.php +++ b/lib/Newsletter/Url.php @@ -1,8 +1,8 @@ endpoint); + $endpoint = ucfirst($this->endpoint); if(!$this->api_request) return; if(!$this->endpoint || !class_exists($endpoint)) { - self::terminateRequest(self::RESPONSE_ERROR, __('Invalid API endpoint.')); + self::terminateRequest(self::RESPONSE_ERROR, __('Invalid Router endpoint.')); } $this->callEndpoint( $endpoint, @@ -43,7 +42,7 @@ class API { function callEndpoint($endpoint, $action, $data) { if(!method_exists($endpoint, $action)) { - self::terminateRequest(self::RESPONSE_ERROR, __('Invalid API action.')); + self::terminateRequest(self::RESPONSE_ERROR, __('Invalid Router action.')); } call_user_func( array( diff --git a/lib/API/Endpoints/Queue.php b/lib/Router/Queue.php similarity index 86% rename from lib/API/Endpoints/Queue.php rename to lib/Router/Queue.php index 736e83d554..36740d5273 100644 --- a/lib/API/Endpoints/Queue.php +++ b/lib/Router/Queue.php @@ -1,5 +1,5 @@