Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F460965
PhabricatorEditEngineConfigurationDefaultsController.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
PhabricatorEditEngineConfigurationDefaultsController.php
View Options
<?php
final
class
PhabricatorEditEngineConfigurationDefaultsController
extends
PhabricatorEditEngineController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$engine_key
=
$request
->
getURIData
(
'engineKey'
);
$this
->
setEngineKey
(
$engine_key
);
$key
=
$request
->
getURIData
(
'key'
);
$viewer
=
$this
->
getViewer
();
$config
=
id
(
new
PhabricatorEditEngineConfigurationQuery
())
->
setViewer
(
$viewer
)
->
withEngineKeys
(
array
(
$engine_key
))
->
withIdentifiers
(
array
(
$key
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$config
)
{
return
id
(
new
Aphront404Response
());
}
$cancel_uri
=
"/transactions/editengine/{$engine_key}/view/{$key}/"
;
$engine
=
$config
->
getEngine
();
$fields
=
$engine
->
getFieldsForConfig
(
$config
);
foreach
(
$fields
as
$key
=>
$field
)
{
if
(!
$field
->
getIsDefaultable
())
{
unset
(
$fields
[
$key
]);
continue
;
}
}
foreach
(
$fields
as
$field
)
{
$field
->
setIsEditDefaults
(
true
);
}
if
(
$request
->
isFormPost
())
{
$xactions
=
array
();
foreach
(
$fields
as
$field
)
{
$field
->
readValueFromSubmit
(
$request
);
}
$type
=
PhabricatorEditEngineConfigurationTransaction
::
TYPE_DEFAULT
;
$xactions
=
array
();
foreach
(
$fields
as
$field
)
{
$new_value
=
$field
->
getValueForDefaults
();
$xactions
[]
=
id
(
new
PhabricatorEditEngineConfigurationTransaction
())
->
setTransactionType
(
$type
)
->
setMetadataValue
(
'field.key'
,
$field
->
getKey
())
->
setNewValue
(
$new_value
);
}
$editor
=
id
(
new
PhabricatorEditEngineConfigurationEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnMissingFields
(
true
)
->
setContinueOnNoEffect
(
true
);
$editor
->
applyTransactions
(
$config
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
$cancel_uri
);
}
$title
=
pht
(
'Edit Form Defaults'
);
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$viewer
);
foreach
(
$fields
as
$field
)
{
$field
->
appendToForm
(
$form
);
}
$form
->
appendControl
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
pht
(
'Save Defaults'
))
->
addCancelButton
(
$cancel_uri
));
$info
=
id
(
new
PHUIInfoView
())
->
setSeverity
(
PHUIInfoView
::
SEVERITY_NOTICE
)
->
setErrors
(
array
(
pht
(
'You are editing the default values for this form.'
),
));
$box
=
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
$title
)
->
setInfoView
(
$info
)
->
setForm
(
$form
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
pht
(
'Form %d'
,
$config
->
getID
()),
$cancel_uri
);
$crumbs
->
addTextCrumb
(
pht
(
'Edit Defaults'
));
return
$this
->
newPage
()
->
setTitle
(
$title
)
->
setCrumbs
(
$crumbs
)
->
appendChild
(
$box
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 5, 4:18 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72204
Default Alt Text
PhabricatorEditEngineConfigurationDefaultsController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment