Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106873586
PhabricatorEditEngineAPIMethod.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
Tue, Apr 1, 21:26
Size
5 KB
Mime Type
text/x-php
Expires
Thu, Apr 3, 21:26 (2 d)
Engine
blob
Format
Raw Data
Handle
25294210
Attached To
rPH Phabricator
PhabricatorEditEngineAPIMethod.php
View Options
<?php
abstract
class
PhabricatorEditEngineAPIMethod
extends
ConduitAPIMethod
{
abstract
public
function
newEditEngine
();
public
function
getApplication
()
{
$engine
=
$this
->
newEditEngine
();
$class
=
$engine
->
getEngineApplicationClass
();
return
PhabricatorApplication
::
getByClass
(
$class
);
}
public
function
getMethodStatus
()
{
return
self
::
METHOD_STATUS_UNSTABLE
;
}
public
function
getMethodStatusDescription
()
{
return
pht
(
'ApplicationEditor methods are highly unstable.'
);
}
final
protected
function
defineParamTypes
()
{
return
array
(
'transactions'
=>
'list<map<string, wild>>'
,
'objectIdentifier'
=>
'optional id|phid|string'
,
);
}
final
protected
function
defineReturnType
()
{
return
'map<string, wild>'
;
}
final
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$engine
=
$this
->
newEditEngine
()
->
setViewer
(
$request
->
getUser
());
return
$engine
->
buildConduitResponse
(
$request
);
}
final
public
function
getMethodDescription
()
{
$viewer
=
$this
->
getViewer
();
$engine
=
$this
->
newEditEngine
()
->
setViewer
(
$viewer
);
$types
=
$engine
->
getConduitEditTypes
();
$out
=
array
();
$out
[]
=
pht
(
<<<EOTEXT
This is a standard **ApplicationEditor** method which allows you to create and
modify objects by applying transactions.
Each transaction applies one change to the object. For example, to create an
object with a specific title or change the title of an existing object you might
start by building a transaction like this:
```lang=json, name=Example Single Transaction
{
"type": "title",
"value": "New Object Title"
}
```
By passing a list of transactions in the `transactions` parameter, you can
apply a sequence of edits. For example, you'll often pass a value like this to
create an object with several field values or apply changes to multiple fields:
```lang=json, name=Example Transaction List
[
{
"type": "title",
"value": "New Object Title"
},
{
"type": "body",
"value": "New body text for the object."
},
{
"type": "projects.add",
"value": ["PHID-PROJ-1111", "PHID-PROJ-2222"]
}
]
```
Exactly which types of edits are available depends on the object you're editing.
Creating Objects
----------------
To create an object, pass a list of `transactions` but leave `objectIdentifier`
empty. This will create a new object with the initial field values you
specify.
Editing Objects
---------------
To edit an object, pass a list of `transactions` and specify an object to
apply them to with `objectIdentifier`. This will apply the changes to the
object.
You may pass an ID (like `123`), PHID (like `PHID-WXYZ-abcdef...`), or
monogram (like `T123`, for objects which have monograms).
Return Type
-----------
WARNING: The structure of the return value from these methods is likely to
change as ApplicationEditor evolves.
Return values look something like this for now:
```lang=json, name=Example Return Value
{
"object": {
"phid": "PHID-XXXX-1111"
},
"transactions": [
{
"phid": "PHID-YYYY-1111",
},
{
"phid": "PHID-YYYY-2222",
}
]
}
```
The `object` key contains information about the object which was created or
edited.
The `transactions` key contains information about the transactions which were
actually applied. For many reasons, the transactions which actually apply may
be greater or fewer in number than the transactions you provided, or may differ
in their nature in other ways.
Edit Types
==========
This API method supports these edit types:
EOTEXT
);
$key
=
pht
(
'Key'
);
$summary
=
pht
(
'Summary'
);
$description
=
pht
(
'Description'
);
$head_type
=
pht
(
'Type'
);
$table
=
array
();
$table
[]
=
"| {$key} | {$summary} |"
;
$table
[]
=
'|--------|----------------|'
;
foreach
(
$types
as
$type
)
{
$edit_type
=
$type
->
getEditType
();
$edit_summary
=
$type
->
getSummary
();
$table
[]
=
"| `{$edit_type}` | {$edit_summary} |"
;
}
$out
[]
=
implode
(
"
\n
"
,
$table
);
foreach
(
$types
as
$type
)
{
$section
=
array
();
$section
[]
=
pht
(
'Edit Type: %s'
,
$type
->
getEditType
());
$section
[]
=
'---------'
;
$section
[]
=
null
;
$section
[]
=
$type
->
getDescription
();
$section
[]
=
null
;
$section
[]
=
pht
(
'This edit generates transactions of type `%s` internally.'
,
$type
->
getTransactionType
());
$section
[]
=
null
;
$type_description
=
pht
(
'Use `%s` to select this edit type.'
,
$type
->
getEditType
());
$value_type
=
$type
->
getValueType
();
if
(!
strlen
(
$value_type
))
{
$value_type
=
'?'
;
}
$value_description
=
$type
->
getValueDescription
();
$table
=
array
();
$table
[]
=
"| {$key} | {$head_type} | {$description} |"
;
$table
[]
=
'|--------|--------------|----------------|'
;
$table
[]
=
"| `type` | `const` | {$type_description} |"
;
$table
[]
=
"| `value` | `{$value_type}` | {$value_description} |"
;
$section
[]
=
implode
(
"
\n
"
,
$table
);
$out
[]
=
implode
(
"
\n
"
,
$section
);
}
$out
=
implode
(
"
\n\n
"
,
$out
);
return
$out
;
}
}
Event Timeline
Log In to Comment