0
我最近選擇了一個客戶的舊項目。它最初是使用Zend框架開發的,這對我來說是一個新的框架。我試圖修改正確的文件,但他們有三個版本的API。如何從Zend路由中告知API版本
在module.config他們的路線:
'api.rest.social-credential' => array(
'type' => 'Segment',
'options' => array(
'route' => '/social-credential[/:social_credential_id]',
'scheme' => 'http',
'defaults' => array(
'controller' => 'Api\\V1\\Rest\\SocialCredential\\Controller',
),
),
),
對我來說,這意味着我應該看是V1或Api\\V1\\Rest\\SocialCredential\\Controller
然而,通過代碼看,看到服務器如何響應時,控制器它顯然正在運行v3。
兩個控制器的定義如下: V1
'Api\\V1\\Rest\\SocialCredential\\Controller' => array(
'listener' => 'Api\\V1\\Rest\\SocialCredential\\SocialCredentialResource',
'route_name' => 'api.rest.social-credential',
'route_identifier_name' => 'social_credential_id',
'collection_name' => 'social_credential',
'entity_http_methods' => array(
0 => 'PATCH',
),
'collection_http_methods' => array(),
'collection_query_whitelist' => array(),
'page_size' => '25',
'page_size_param' => '',
'entity_class' => 'Api\\V1\\Rest\\SocialCredential\\SocialCredentialEntity',
'collection_class' => 'Api\\V1\\Rest\\SocialCredential\\SocialCredentialCollection',
'service_name' => 'SocialCredential',
),
V3
'Api\\V3\\Rest\\SocialCredential\\Controller' => array(
'listener' => 'Api\\V3\\Rest\\SocialCredential\\SocialCredentialResource',
'route_name' => 'api.rest.social-credential',
'route_identifier_name' => 'social_credential_id',
'collection_name' => 'social_credential',
'entity_http_methods' => array(
0 => 'PATCH',
1 => 'DELETE',
),
'collection_http_methods' => array(),
'collection_query_whitelist' => array(),
'page_size' => '25',
'page_size_param' => '',
'entity_class' => 'Api\\V3\\Rest\\SocialCredential\\SocialCredentialEntity',
'collection_class' => 'Api\\V3\\Rest\\SocialCredential\\SocialCredentialCollection',
'service_name' => 'SocialCredential',
),
我,這讓我相信,V3理應那麼這等目標的module.config發現什麼定義存在。要麼我錯過了一些東西,要麼我不瞭解Zend路由如何工作。請問有人可以點亮一下嗎?