Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93632633
DifferentialCoreCustomField.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
Sat, Nov 30, 07:33
Size
3 KB
Mime Type
text/x-php
Expires
Mon, Dec 2, 07:33 (2 d)
Engine
blob
Format
Raw Data
Handle
22678030
Attached To
rPH Phabricator
DifferentialCoreCustomField.php
View Options
<?php
/**
* Base class for Differential fields with storage on the revision object
* itself. This mostly wraps reading/writing field values to and from the
* object.
*/
abstract
class
DifferentialCoreCustomField
extends
DifferentialCustomField
{
private
$value
;
private
$fieldError
;
abstract
protected
function
readValueFromRevision
(
DifferentialRevision
$revision
);
protected
function
writeValueToRevision
(
DifferentialRevision
$revision
,
$value
)
{
throw
new
PhabricatorCustomFieldImplementationIncompleteException
(
$this
);
}
protected
function
isCoreFieldRequired
()
{
return
false
;
}
protected
function
isCoreFieldValueEmpty
(
$value
)
{
if
(
is_array
(
$value
))
{
return
!
$value
;
}
return
!
strlen
(
trim
(
$value
));
}
protected
function
getCoreFieldRequiredErrorString
()
{
throw
new
PhabricatorCustomFieldImplementationIncompleteException
(
$this
);
}
public
function
validateApplicationTransactions
(
PhabricatorApplicationTransactionEditor
$editor
,
$type
,
array
$xactions
)
{
$this
->
setFieldError
(
null
);
$errors
=
parent
::
validateApplicationTransactions
(
$editor
,
$type
,
$xactions
);
$transaction
=
null
;
foreach
(
$xactions
as
$xaction
)
{
$value
=
$xaction
->
getNewValue
();
if
(
$this
->
isCoreFieldRequired
())
{
if
(
$this
->
isCoreFieldValueEmpty
(
$value
))
{
$error
=
new
PhabricatorApplicationTransactionValidationError
(
$type
,
pht
(
'Required'
),
$this
->
getCoreFieldRequiredErrorString
(),
$xaction
);
$error
->
setIsMissingFieldError
(
true
);
$errors
[]
=
$error
;
$this
->
setFieldError
(
pht
(
'Required'
));
}
}
}
return
$errors
;
}
public
function
canDisableField
()
{
return
false
;
}
public
function
shouldAppearInApplicationTransactions
()
{
return
true
;
}
public
function
shouldAppearInEditView
()
{
return
true
;
}
public
function
readValueFromObject
(
PhabricatorCustomFieldInterface
$object
)
{
if
(
$this
->
isCoreFieldRequired
())
{
$this
->
setFieldError
(
true
);
}
$this
->
setValue
(
$this
->
readValueFromRevision
(
$object
));
}
public
function
getOldValueForApplicationTransactions
()
{
return
$this
->
readValueFromRevision
(
$this
->
getObject
());
}
public
function
getNewValueForApplicationTransactions
()
{
return
$this
->
getValue
();
}
public
function
applyApplicationTransactionInternalEffects
(
PhabricatorApplicationTransaction
$xaction
)
{
$this
->
writeValueToRevision
(
$this
->
getObject
(),
$xaction
->
getNewValue
());
}
public
function
setFieldError
(
$field_error
)
{
$this
->
fieldError
=
$field_error
;
return
$this
;
}
public
function
getFieldError
()
{
return
$this
->
fieldError
;
}
public
function
setValue
(
$value
)
{
$this
->
value
=
$value
;
return
$this
;
}
public
function
getValue
()
{
return
$this
->
value
;
}
public
function
readValueFromCommitMessage
(
$value
)
{
$this
->
setValue
(
$value
);
return
$this
;
}
public
function
renderCommitMessageValue
(
array
$handles
)
{
return
$this
->
getValue
();
}
public
function
getConduitDictionaryValue
()
{
return
$this
->
getValue
();
}
}
Event Timeline
Log In to Comment