Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79739417
PhortuneMerchantEditor.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
Wed, Aug 28, 00:18
Size
3 KB
Mime Type
text/x-php
Expires
Fri, Aug 30, 00:18 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
20225018
Attached To
rPH Phabricator
PhortuneMerchantEditor.php
View Options
<?php
final
class
PhortuneMerchantEditor
extends
PhabricatorApplicationTransactionEditor
{
public
function
getEditorApplicationClass
()
{
return
'PhabricatorPhortuneApplication'
;
}
public
function
getEditorObjectsDescription
()
{
return
pht
(
'Phortune Merchants'
);
}
public
function
getTransactionTypes
()
{
$types
=
parent
::
getTransactionTypes
();
$types
[]
=
PhortuneMerchantTransaction
::
TYPE_NAME
;
$types
[]
=
PhortuneMerchantTransaction
::
TYPE_DESCRIPTION
;
$types
[]
=
PhortuneMerchantTransaction
::
TYPE_CONTACTINFO
;
$types
[]
=
PhortuneMerchantTransaction
::
TYPE_PICTURE
;
$types
[]
=
PhabricatorTransactions
::
TYPE_VIEW_POLICY
;
$types
[]
=
PhabricatorTransactions
::
TYPE_EDGE
;
return
$types
;
}
protected
function
getCustomTransactionOldValue
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
PhortuneMerchantTransaction
::
TYPE_NAME
:
return
$object
->
getName
();
case
PhortuneMerchantTransaction
::
TYPE_DESCRIPTION
:
return
$object
->
getDescription
();
case
PhortuneMerchantTransaction
::
TYPE_CONTACTINFO
:
return
$object
->
getContactInfo
();
case
PhortuneMerchantTransaction
::
TYPE_PICTURE
:
return
$object
->
getProfileImagePHID
();
}
return
parent
::
getCustomTransactionOldValue
(
$object
,
$xaction
);
}
protected
function
getCustomTransactionNewValue
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
PhortuneMerchantTransaction
::
TYPE_NAME
:
case
PhortuneMerchantTransaction
::
TYPE_DESCRIPTION
:
case
PhortuneMerchantTransaction
::
TYPE_CONTACTINFO
:
case
PhortuneMerchantTransaction
::
TYPE_PICTURE
:
return
$xaction
->
getNewValue
();
}
return
parent
::
getCustomTransactionNewValue
(
$object
,
$xaction
);
}
protected
function
applyCustomInternalTransaction
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
PhortuneMerchantTransaction
::
TYPE_NAME
:
$object
->
setName
(
$xaction
->
getNewValue
());
return
;
case
PhortuneMerchantTransaction
::
TYPE_DESCRIPTION
:
$object
->
setDescription
(
$xaction
->
getNewValue
());
return
;
case
PhortuneMerchantTransaction
::
TYPE_CONTACTINFO
:
$object
->
setContactInfo
(
$xaction
->
getNewValue
());
return
;
case
PhortuneMerchantTransaction
::
TYPE_PICTURE
:
$object
->
setProfileImagePHID
(
$xaction
->
getNewValue
());
return
;
}
return
parent
::
applyCustomInternalTransaction
(
$object
,
$xaction
);
}
protected
function
applyCustomExternalTransaction
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
PhortuneMerchantTransaction
::
TYPE_NAME
:
case
PhortuneMerchantTransaction
::
TYPE_DESCRIPTION
:
case
PhortuneMerchantTransaction
::
TYPE_CONTACTINFO
:
case
PhortuneMerchantTransaction
::
TYPE_PICTURE
:
return
;
}
return
parent
::
applyCustomExternalTransaction
(
$object
,
$xaction
);
}
protected
function
validateTransaction
(
PhabricatorLiskDAO
$object
,
$type
,
array
$xactions
)
{
$errors
=
parent
::
validateTransaction
(
$object
,
$type
,
$xactions
);
switch
(
$type
)
{
case
PhortuneMerchantTransaction
::
TYPE_NAME
:
$missing
=
$this
->
validateIsEmptyTextField
(
$object
->
getName
(),
$xactions
);
if
(
$missing
)
{
$error
=
new
PhabricatorApplicationTransactionValidationError
(
$type
,
pht
(
'Required'
),
pht
(
'Merchant name is required.'
),
nonempty
(
last
(
$xactions
),
null
));
$error
->
setIsMissingFieldError
(
true
);
$errors
[]
=
$error
;
}
break
;
}
return
$errors
;
}
}
Event Timeline
Log In to Comment