Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97880353
PholioMock.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, Jan 7, 03:17
Size
3 KB
Mime Type
text/x-php
Expires
Thu, Jan 9, 03:17 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23427315
Attached To
rPH Phabricator
PholioMock.php
View Options
<?php
/**
* @group pholio
*/
final
class
PholioMock
extends
PholioDAO
implements
PhabricatorMarkupInterface
,
PhabricatorPolicyInterface
,
PhabricatorSubscribableInterface
,
PhabricatorTokenReceiverInterface
,
PhabricatorApplicationTransactionInterface
{
const
MARKUP_FIELD_DESCRIPTION
=
'markup:description'
;
protected
$authorPHID
;
protected
$viewPolicy
;
protected
$name
;
protected
$originalName
;
protected
$description
;
protected
$coverPHID
;
protected
$mailKey
;
private
$images
;
private
$coverFile
;
public
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
)
+
parent
::
getConfiguration
();
}
public
function
generatePHID
()
{
return
PhabricatorPHID
::
generateNewPHID
(
'MOCK'
);
}
public
function
save
()
{
if
(!
$this
->
getMailKey
())
{
$this
->
setMailKey
(
Filesystem
::
readRandomCharacters
(
20
));
}
return
parent
::
save
();
}
public
function
attachImages
(
array
$images
)
{
assert_instances_of
(
$images
,
'PholioImage'
);
$this
->
images
=
$images
;
return
$this
;
}
public
function
getImages
()
{
if
(
$this
->
images
===
null
)
{
throw
new
Exception
(
"Call attachImages() before getImages()!"
);
}
return
$this
->
images
;
}
public
function
attachCoverFile
(
PhabricatorFile
$file
)
{
$this
->
coverFile
=
$file
;
return
$this
;
}
public
function
getCoverFile
()
{
if
(
$this
->
coverFile
===
null
)
{
throw
new
Exception
(
"Call attachCoverFile() before getCoverFile()!"
);
}
return
$this
->
coverFile
;
}
/* -( PhabricatorSubscribableInterface Implementation )-------------------- */
public
function
isAutomaticallySubscribed
(
$phid
)
{
return
(
$this
->
authorPHID
==
$phid
);
}
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
public
function
getCapabilities
()
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
);
}
public
function
getPolicy
(
$capability
)
{
switch
(
$capability
)
{
case
PhabricatorPolicyCapability
::
CAN_VIEW
:
return
$this
->
getViewPolicy
();
case
PhabricatorPolicyCapability
::
CAN_EDIT
:
return
PhabricatorPolicies
::
POLICY_NOONE
;
}
}
public
function
hasAutomaticCapability
(
$capability
,
PhabricatorUser
$viewer
)
{
return
(
$viewer
->
getPHID
()
==
$this
->
getAuthorPHID
());
}
/* -( PhabricatorMarkupInterface )----------------------------------------- */
public
function
getMarkupFieldKey
(
$field
)
{
$hash
=
PhabricatorHash
::
digest
(
$this
->
getMarkupText
(
$field
));
return
'M:'
.
$hash
;
}
public
function
newMarkupEngine
(
$field
)
{
return
PhabricatorMarkupEngine
::
newMarkupEngine
(
array
());
}
public
function
getMarkupText
(
$field
)
{
return
$this
->
getDescription
();
}
public
function
didMarkupText
(
$field
,
$output
,
PhutilMarkupEngine
$engine
)
{
return
$output
;
}
public
function
shouldUseMarkupCache
(
$field
)
{
return
(
bool
)
$this
->
getID
();
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public
function
getApplicationTransactionEditor
()
{
return
new
PholioMockEditor
();
}
public
function
getApplicationTransactionObject
()
{
return
new
PholioTransaction
();
}
}
Event Timeline
Log In to Comment