Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F547328
DrydockBlueprintEditController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DrydockBlueprintEditController.php
View Options
<?php
final
class
DrydockBlueprintEditController
extends
DrydockBlueprintController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$engine
=
id
(
new
DrydockBlueprintEditEngine
())
->
setController
(
$this
);
$id
=
$request
->
getURIData
(
'id'
);
if
(!
$id
)
{
$this
->
requireApplicationCapability
(
DrydockCreateBlueprintsCapability
::
CAPABILITY
);
$type
=
$request
->
getStr
(
'blueprintType'
);
$impl
=
DrydockBlueprintImplementation
::
getNamedImplementation
(
$type
);
if
(!
$impl
||
!
$impl
->
isEnabled
())
{
return
$this
->
buildTypeSelectionResponse
();
}
$engine
->
addContextParameter
(
'blueprintType'
,
$type
)
->
setBlueprintImplementation
(
$impl
);
}
return
$engine
->
buildResponse
();
}
private
function
buildTypeSelectionResponse
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$this
->
getViewer
();
$implementations
=
DrydockBlueprintImplementation
::
getAllBlueprintImplementations
();
$errors
=
array
();
$e_blueprint
=
null
;
if
(
$request
->
isFormPost
())
{
$class
=
$request
->
getStr
(
'blueprintType'
);
if
(!
isset
(
$implementations
[
$class
]))
{
$e_blueprint
=
pht
(
'Required'
);
$errors
[]
=
pht
(
'You must choose a blueprint type.'
);
}
}
$control
=
id
(
new
AphrontFormRadioButtonControl
())
->
setName
(
'blueprintType'
)
->
setLabel
(
pht
(
'Blueprint Type'
))
->
setError
(
$e_blueprint
);
foreach
(
$implementations
as
$implementation_name
=>
$implementation
)
{
$disabled
=
!
$implementation
->
isEnabled
();
$impl_icon
=
$implementation
->
getBlueprintIcon
();
$impl_name
=
$implementation
->
getBlueprintName
();
$impl_icon
=
id
(
new
PHUIIconView
())
->
setIcon
(
$impl_icon
,
'lightgreytext'
);
$control
->
addButton
(
$implementation_name
,
array
(
$impl_icon
,
' '
,
$impl_name
),
array
(
pht
(
'Provides: %s'
,
$implementation
->
getType
()),
phutil_tag
(
'br'
),
phutil_tag
(
'br'
),
$implementation
->
getDescription
(),
),
$disabled
?
'disabled'
:
null
,
$disabled
);
}
$title
=
pht
(
'Create New Blueprint'
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
pht
(
'New Blueprint'
));
$crumbs
->
setBorder
(
true
);
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$viewer
)
->
appendChild
(
$control
)
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
addCancelButton
(
$this
->
getApplicationURI
(
'blueprint/'
))
->
setValue
(
pht
(
'Continue'
)));
$box
=
id
(
new
PHUIObjectBoxView
())
->
setFormErrors
(
$errors
)
->
setHeaderText
(
$title
)
->
setBackground
(
PHUIObjectBoxView
::
WHITE_CONFIG
)
->
setForm
(
$form
);
$view
=
id
(
new
PHUITwoColumnView
())
->
setFooter
(
$box
);
return
$this
->
newPage
()
->
setTitle
(
$title
)
->
setCrumbs
(
$crumbs
)
->
appendChild
(
$view
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:31 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
103131
Default Alt Text
DrydockBlueprintEditController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment