Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wxh_internal_api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
杨培培
wxh_internal_api
Commits
04db65a1
Commit
04db65a1
authored
Jun 28, 2017
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 API 集的请求实例,每个API集将只有一个实例
parent
70a0059b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
Client.php
src/base/Client.php
+23
-7
No files found.
src/base/Client.php
View file @
04db65a1
...
...
@@ -9,7 +9,7 @@
namespace
internalApi\base
;
abstract
class
Client
class
Client
{
public
$debug
=
false
;
...
...
@@ -22,23 +22,39 @@ abstract class Client
protected
static
$instance
=
[];
protected
static
$config
=
[];
/**
* 获取 API 集的客户端实例
* 每个 API 集有一个实例用于签名和请求处理
*
* @return static
*/
protected
static
function
getInstance
()
{
$
className
=
static
::
class
;
$
name
=
self
::
name
()
;
if
(
!
isset
(
self
::
$instance
[
$
classN
ame
]))
{
self
::
$instance
[
$
className
]
=
new
$className
(
);
if
(
!
isset
(
self
::
$instance
[
$
n
ame
]))
{
self
::
$instance
[
$
name
]
=
new
self
(
$name
);
}
return
self
::
$instance
[
$
classN
ame
];
return
self
::
$instance
[
$
n
ame
];
}
public
function
__construct
()
/**
* 获取 API 集的名称
*
* 如 internalApi\ucenter\Member 则名称为 ucenter
*
* @return bool|string
*/
public
static
function
name
()
{
$className
=
static
::
class
;
$subName
=
strstr
(
$className
,
'\\'
);
$name
=
substr
(
$subName
,
1
,
strpos
(
$subName
,
'\\'
,
1
)
-
1
);
return
substr
(
$subName
,
1
,
strpos
(
$subName
,
'\\'
,
1
)
-
1
);
}
public
function
__construct
(
$name
)
{
if
(
isset
(
static
::
$config
[
$name
]))
{
foreach
(
static
::
$config
[
$name
]
as
$k
=>
$v
)
{
if
(
$this
->
$k
===
null
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment