Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F35337071
PhabricatorConduitController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
3 KB
Subscribers
None
PhabricatorConduitController.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
abstract
class
PhabricatorConduitController
extends
PhabricatorController
{
private
$filter
;
protected
$showSideNav
;
public
function
buildStandardPageResponse
(
$view
,
array
$data
)
{
$page
=
$this
->
buildStandardPageView
();
$page
->
setApplicationName
(
'Conduit'
);
$page
->
setBaseURI
(
'/conduit/'
);
$page
->
setTitle
(
idx
(
$data
,
'title'
));
$page
->
setGlyph
(
"
\x
E2
\x
87
\x
B5"
);
if
(
$this
->
showSideNav
())
{
$nav
=
new
AphrontSideNavFilterView
();
$nav
->
setBaseURI
(
new
PhutilURI
(
'/conduit/'
));
$method_filters
=
$this
->
getMethodFilters
();
foreach
(
$method_filters
as
$group
=>
$methods
)
{
$nav
->
addLabel
(
$group
);
foreach
(
$methods
as
$method
)
{
$method_name
=
$method
[
'full_name'
];
$display_name
=
$method_name
;
switch
(
$method
[
'status'
])
{
case
ConduitAPIMethod
::
METHOD_STATUS_DEPRECATED
:
$display_name
=
'('
.
$display_name
.
')'
;
break
;
}
$nav
->
addFilter
(
'method/'
.
$method_name
,
$display_name
);
}
$nav
->
addSpacer
();
}
$nav
->
selectFilter
(
$this
->
getFilter
());
$nav
->
appendChild
(
$view
);
$body
=
$nav
;
}
else
{
$body
=
$view
;
}
$page
->
appendChild
(
$body
);
$response
=
new
AphrontWebpageResponse
();
return
$response
->
setContent
(
$page
->
render
());
}
private
function
getFilter
()
{
return
$this
->
filter
;
}
protected
function
setFilter
(
$filter
)
{
$this
->
filter
=
$filter
;
return
$this
;
}
private
function
showSideNav
()
{
return
$this
->
showSideNav
!==
false
;
}
protected
function
setShowSideNav
(
$show_side_nav
)
{
$this
->
showSideNav
=
$show_side_nav
;
return
$this
;
}
protected
function
getAllMethodImplementationClasses
()
{
$classes
=
id
(
new
PhutilSymbolLoader
())
->
setAncestorClass
(
'ConduitAPIMethod'
)
->
setType
(
'class'
)
->
setConcreteOnly
(
true
)
->
selectSymbolsWithoutLoading
();
return
array_values
(
ipull
(
$classes
,
'name'
));
}
protected
function
getMethodFilters
()
{
$classes
=
$this
->
getAllMethodImplementationClasses
();
$method_names
=
array
();
foreach
(
$classes
as
$method_class
)
{
$method_name
=
ConduitAPIMethod
::
getAPIMethodNameFromClassName
(
$method_class
);
$group_name
=
head
(
explode
(
'.'
,
$method_name
));
$method_object
=
newv
(
$method_class
,
array
());
$status
=
$method_object
->
getMethodStatus
();
$key
=
sprintf
(
'%02d %s %s'
,
$this
->
getOrderForMethodStatus
(
$status
),
$group_name
,
$method_name
);
$method_names
[
$key
]
=
array
(
'full_name'
=>
$method_name
,
'group_name'
=>
$group_name
,
'status'
=>
$status
,
'description'
=>
$method_object
->
getMethodDescription
(),
);
}
ksort
(
$method_names
);
$method_names
=
igroup
(
$method_names
,
'group_name'
);
ksort
(
$method_names
);
return
$method_names
;
}
private
function
getOrderForMethodStatus
(
$status
)
{
$map
=
array
(
ConduitAPIMethod
::
METHOD_STATUS_STABLE
=>
0
,
ConduitAPIMethod
::
METHOD_STATUS_UNSTABLE
=>
1
,
ConduitAPIMethod
::
METHOD_STATUS_DEPRECATED
=>
2
,
);
return
idx
(
$map
,
$status
,
0
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 6, 8:13 AM (10 h, 38 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f0/48/81ca5bd8fdb2ad9abe50adbe2abe
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment