Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92213859
PhabricatorProjectCreateController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 18, 09:37
Size
3 KB
Mime Type
text/x-php
Expires
Wed, Nov 20, 09:37 (2 d)
Engine
blob
Format
Raw Data
Handle
22395996
Attached To
rPH Phabricator
PhabricatorProjectCreateController.php
View Options
<?php
final
class
PhabricatorProjectCreateController
extends
PhabricatorProjectController
{
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$this
->
requireApplicationCapability
(
ProjectCapabilityCreateProjects
::
CAPABILITY
);
$project
=
PhabricatorProject
::
initializeNewProject
(
$user
);
$profile
=
new
PhabricatorProjectProfile
();
$e_name
=
true
;
$errors
=
array
();
if
(
$request
->
isFormPost
())
{
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorProjectTransaction
::
TYPE_NAME
)
->
setNewValue
(
$request
->
getStr
(
'name'
));
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_EDGE
)
->
setMetadataValue
(
'edge:type'
,
PhabricatorEdgeConfig
::
TYPE_PROJ_MEMBER
)
->
setNewValue
(
array
(
'+'
=>
array
(
$user
->
getPHID
()
=>
$user
->
getPHID
()),
));
$editor
=
id
(
new
PhabricatorProjectTransactionEditor
())
->
setActor
(
$user
)
->
setContinueOnNoEffect
(
true
)
->
setContentSourceFromRequest
(
$request
)
->
applyTransactions
(
$project
,
$xactions
);
// TODO: Deal with name collision exceptions more gracefully.
if
(!
$errors
)
{
$project
->
save
();
$profile
->
setProjectPHID
(
$project
->
getPHID
());
$profile
->
setBlurb
(
''
);
$profile
->
save
();
if
(
$request
->
isAjax
())
{
return
id
(
new
AphrontAjaxResponse
())
->
setContent
(
array
(
'phid'
=>
$project
->
getPHID
(),
'name'
=>
$project
->
getName
(),
));
}
else
{
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
'/project/view/'
.
$project
->
getID
().
'/'
);
}
}
}
$error_view
=
null
;
if
(
$errors
)
{
$error_view
=
new
AphrontErrorView
();
$error_view
->
setErrors
(
$errors
);
}
if
(
$request
->
isAjax
())
{
$form
=
new
PHUIFormLayoutView
();
}
else
{
$form
=
new
AphrontFormView
();
$form
->
setUser
(
$user
);
}
$form
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
pht
(
'Name'
))
->
setName
(
'name'
)
->
setValue
(
$project
->
getName
())
->
setError
(
$e_name
));
if
(
$request
->
isAjax
())
{
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$user
)
->
setWidth
(
AphrontDialogView
::
WIDTH_FORM
)
->
setTitle
(
pht
(
'Create a New Project'
))
->
appendChild
(
$error_view
)
->
appendChild
(
$form
)
->
addSubmitButton
(
pht
(
'Create Project'
))
->
addCancelButton
(
'/project/'
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
else
{
$form
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
pht
(
'Create'
))
->
addCancelButton
(
'/project/'
));
$crumbs
=
$this
->
buildApplicationCrumbs
(
$this
->
buildSideNavView
());
$crumbs
->
addTextCrumb
(
pht
(
'Create Project'
),
$this
->
getApplicationURI
().
'create/'
);
$form_box
=
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
pht
(
'Create New Project'
))
->
setFormErrors
(
$errors
)
->
setForm
(
$form
);
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$form_box
,
),
array
(
'title'
=>
pht
(
'Create New Project'
),
'device'
=>
true
,
));
}
}
}
Event Timeline
Log In to Comment