code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function getObject() {
return $this->object;
} | Get object in which this comment textarea is displayed | getObject | php | phorgeit/phorge | src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php | Apache-2.0 |
public function getQueryApplicationClass() {
return null;
} | Get name of class of application queried by the query.
To be overwritten by child classes when applicable.
@return string|null Application class name | getQueryApplicationClass | php | phorgeit/phorge | src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php | Apache-2.0 |
public function shouldRequireMFA() {
return false;
} | Do edits to this object REQUIRE that the user submit MFA?
This is a strict requirement: users will need to add MFA to their accounts
if they don't already have it.
@return bool True to strictly require MFA. | shouldRequireMFA | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngineMFAEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngineMFAEngine.php | Apache-2.0 |
public function shouldTryMFA() {
return false;
} | Should edits to this object prompt for MFA if it's available?
This is advisory: users without MFA on their accounts will be able to
perform edits without being required to add MFA.
@return bool True to prompt for MFA if available. | shouldTryMFA | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngineMFAEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngineMFAEngine.php | Apache-2.0 |
public function setTargetObject($target_object) {
$this->targetObject = $target_object;
return $this;
} | Force the engine to edit a particular object. | setTargetObject | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getFormHeaderText($object) {
$config = $this->getEditEngineConfiguration();
return $config->getName();
} | @task text | getFormHeaderText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getObjectCreateButtonText($object) {
return $this->getObjectCreateTitleText($object);
} | @task text | getObjectCreateButtonText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getObjectEditButtonText($object) {
return pht('Save Changes');
} | @task text | getObjectEditButtonText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getCommentViewSeriousHeaderText($object) {
return pht('Take Action');
} | @task text | getCommentViewSeriousHeaderText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getCommentViewSeriousButtonText($object) {
return pht('Submit');
} | @task text | getCommentViewSeriousButtonText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getCommentViewHeaderText($object) {
return $this->getCommentViewSeriousHeaderText($object);
} | @task text | getCommentViewHeaderText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getCommentViewButtonText($object) {
return $this->getCommentViewSeriousButtonText($object);
} | @task text | getCommentViewButtonText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getPageHeader($object) {
return null;
} | @task text | getPageHeader | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
public function getCommentFieldPlaceholderText($object) {
return '';
} | Set default placeholder plain text in the comment textarea of the engine.
To be overwritten by conditions defined in the child EditEngine class.
@param object $object Object in which the comment textarea is displayed.
@return string Placeholder text to display in the comment textarea.
@task text | getCommentFieldPlaceholderText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getObjectCreateCancelURI($object) {
return $this->getApplication()->getApplicationURI();
} | @task uri | getObjectCreateCancelURI | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getEditorURI() {
return $this->getApplication()->getApplicationURI('edit/');
} | @task uri | getEditorURI | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function getObjectEditCancelURI($object) {
return $this->getObjectViewURI($object);
} | @task uri | getObjectEditCancelURI | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
public function getCreateURI($form_key) {
try {
$create_uri = $this->getEditURI(null, "form/{$form_key}/");
} catch (Exception $ex) {
$create_uri = null;
}
return $create_uri;
} | @task uri | getCreateURI | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
public function getEditURI($object = null, $path = null) {
$parts = array();
$parts[] = $this->getEditorURI();
if ($object && $object->getID()) {
$parts[] = $object->getID().'/';
}
if ($path !== null) {
$parts[] = $path;
}
return implode('', $parts);
} | @task uri | getEditURI | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
final public function getIsCreate() {
return $this->isCreate;
} | Test if this workflow is creating a new object or editing an existing one.
@return bool True if a new object is being created.
@task load | getIsCreate | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function newEditableObjectFromConduit(array $raw_xactions) {
return $this->newEditableObject();
} | Initialize a new object for object creation via Conduit.
@return object Newly initialized object.
@param list<wild> $raw_xactions Raw transactions.
@task load | newEditableObjectFromConduit | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
protected function newEditableObjectForDocumentation() {
return $this->newEditableObject();
} | Initialize a new object for documentation creation.
@return object Newly initialized object.
@task load | newEditableObjectForDocumentation | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
private function setIsCreate($is_create) {
$this->isCreate = $is_create;
return $this;
} | Flag this workflow as a create or edit.
@param bool $is_create True if this is a create workflow.
@return $this
@task load | setIsCreate | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
private function validateObject($object) {
if (!$object || !is_object($object)) {
throw new Exception(
pht(
'EditEngine "%s" created or loaded an invalid object: object must '.
'actually be an object, but is of some other type ("%s").',
get_class($this),
gettype($object)));
}
if (!($object instanceof PhabricatorApplicationTransactionInterface)) {
throw new Exception(
pht(
'EditEngine "%s" created or loaded an invalid object: object (of '.
'class "%s") must implement "%s", but does not.',
get_class($this),
get_class($object),
'PhabricatorApplicationTransactionInterface'));
}
} | Verify that an object is appropriate for editing.
@param wild $object Loaded value.
@return void
@task load | validateObject | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
private function buildParametersResponse($object) {
$controller = $this->getController();
$viewer = $this->getViewer();
$request = $controller->getRequest();
$fields = $this->buildEditFields($object);
$crumbs = $this->buildCrumbs($object);
$crumbs->addTextCrumb(pht('HTTP Parameters'));
$crumbs->setBorder(true);
$header_text = pht(
'HTTP Parameters: %s',
$this->getObjectCreateShortText());
$header = id(new PHUIHeaderView())
->setHeader($header_text);
$help_view = id(new PhabricatorApplicationEditHTTPParameterHelpView())
->setUser($viewer)
->setFields($fields);
$document = id(new PHUIDocumentView())
->setUser($viewer)
->setHeader($header)
->appendChild($help_view);
return $controller->newPage()
->setTitle(pht('HTTP Parameters'))
->setCrumbs($crumbs)
->appendChild($document);
} | Respond to a request for documentation on HTTP parameters.
@param object $object Editable object.
@return AphrontResponse Response object.
@task http | buildParametersResponse | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngine.php | Apache-2.0 |
public function setTagText($text) {
$this->tagText = $text;
return $this;
} | Set the text of the tag
This is usually the 'name' key of your subtype map.
Sometime this is an uppercase text like 'BUG' for a 'bug' subtype name.
@param string|null $text
@return self | setTagText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php | Apache-2.0 |
public function getTagText() {
return $this->tagText;
} | Get the text of the tag
@see PhabricatorEditEngineSubtype::setTagText()
@return string|null | getTagText | php | phorgeit/phorge | src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php | Apache-2.0 |
public function setContinueOnNoEffect($continue) {
$this->continueOnNoEffect = $continue;
return $this;
} | When the editor tries to apply transactions that have no effect, should
it raise an exception (default) or drop them and continue?
Generally, you will set this flag for edits coming from "Edit" interfaces,
and leave it cleared for edits coming from "Comment" interfaces, so the
user will get a useful error if they try to submit a comment that does
nothing (e.g., empty comment with a status change that has already been
performed by another user).
@param bool $continue True to drop transactions without effect and
continue.
@return $this | setContinueOnNoEffect | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
public function setContinueOnMissingFields($continue_on_missing_fields) {
$this->continueOnMissingFields = $continue_on_missing_fields;
return $this;
} | When the editor tries to apply transactions which don't populate all of
an object's required fields, should it raise an exception (default) or
drop them and continue?
For example, if a user adds a new required custom field (like "Severity")
to a task, all existing tasks won't have it populated. When users
manually edit existing tasks, it's usually desirable to have them provide
a severity. However, other operations (like batch editing just the
owner of a task) will fail by default.
By setting this flag for edit operations which apply to specific fields
(like the priority, batch, and merge editors in Maniphest), these
operations can continue to function even if an object is outdated.
@param bool $continue_on_missing_fields True to continue when transactions
don't completely satisfy all required fields.
@return $this | setContinueOnMissingFields | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
public function setParentMessageID($parent_message_id) {
$this->parentMessageID = $parent_message_id;
return $this;
} | Not strictly necessary, but reply handlers ideally set this value to
make email threading work better. | setParentMessageID | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function applyBuiltinInternalTransaction(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_VIEW_POLICY:
$object->setViewPolicy($xaction->getNewValue());
break;
case PhabricatorTransactions::TYPE_EDIT_POLICY:
$object->setEditPolicy($xaction->getNewValue());
break;
case PhabricatorTransactions::TYPE_JOIN_POLICY:
$object->setJoinPolicy($xaction->getNewValue());
break;
case PhabricatorTransactions::TYPE_INTERACT_POLICY:
$object->setInteractPolicy($xaction->getNewValue());
break;
case PhabricatorTransactions::TYPE_SPACE:
$object->setSpacePHID($xaction->getNewValue());
break;
case PhabricatorTransactions::TYPE_SUBTYPE:
$object->setEditEngineSubtype($xaction->getNewValue());
break;
}
} | @{class:PhabricatorTransactions} provides many built-in transactions
which should not require much - if any - code in specific applications.
This method is a hook for the exceedingly-rare cases where you may need
to do **additional** work for built-in transactions. Developers should
extend this method, making sure to return the parent implementation
regardless of handling any transactions.
See also @{method:applyBuiltinExternalTransaction}. | applyBuiltinInternalTransaction | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function populateTransaction(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
$actor = $this->getActor();
// TODO: This needs to be more sophisticated once we have meta-policies.
$xaction->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC);
if ($actor->isOmnipotent()) {
$xaction->setEditPolicy(PhabricatorPolicies::POLICY_NOONE);
} else {
$xaction->setEditPolicy($this->getActingAsPHID());
}
// If the transaction already has an explicit author PHID, allow it to
// stand. This is used by applications like Owners that hook into the
// post-apply change pipeline.
if (!$xaction->getAuthorPHID()) {
$xaction->setAuthorPHID($this->getActingAsPHID());
}
$xaction->setContentSource($this->getContentSource());
$xaction->attachViewer($actor);
$xaction->attachObject($object);
if ($object->getPHID()) {
$xaction->setObjectPHID($object->getPHID());
}
if ($this->getIsSilent()) {
$xaction->setIsSilentTransaction(true);
}
return $xaction;
} | Fill in a transaction's common values, like author and content source. | populateTransaction | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
final public function applyImplicitCC(
PhabricatorLiskDAO $object,
array $xactions) {
if (!($object instanceof PhabricatorSubscribableInterface)) {
// If the object isn't subscribable, we can't CC them.
return $xactions;
}
$actor_phid = $this->getActingAsPHID();
$type_user = PhabricatorPeopleUserPHIDType::TYPECONST;
if (phid_get_type($actor_phid) != $type_user) {
// Transactions by application actors like Herald, Harbormaster and
// Diffusion should not CC the applications.
return $xactions;
}
if ($object->isAutomaticallySubscribed($actor_phid)) {
// If they're auto-subscribed, don't CC them.
return $xactions;
}
$should_cc = false;
foreach ($xactions as $xaction) {
if ($this->shouldImplyCC($object, $xaction)) {
$should_cc = true;
break;
}
}
if (!$should_cc) {
// Only some types of actions imply a CC (like adding a comment).
return $xactions;
}
if ($object->getPHID()) {
if (isset($this->subscribers[$actor_phid])) {
// If the user is already subscribed, don't implicitly CC them.
return $xactions;
}
$unsub = PhabricatorEdgeQuery::loadDestinationPHIDs(
$object->getPHID(),
PhabricatorObjectHasUnsubscriberEdgeType::EDGECONST);
$unsub = array_fuse($unsub);
if (isset($unsub[$actor_phid])) {
// If the user has previously unsubscribed from this object explicitly,
// don't implicitly CC them.
return $xactions;
}
}
$actor = $this->getActor();
$user = id(new PhabricatorPeopleQuery())
->setViewer($actor)
->withPHIDs(array($actor_phid))
->executeOne();
if (!$user) {
return $xactions;
}
// When a bot acts (usually via the API), don't automatically subscribe
// them as a side effect. They can always subscribe explicitly if they
// want, and bot subscriptions normally just clutter things up since bots
// usually do not read email.
if ($user->getIsSystemAgent()) {
return $xactions;
}
$xaction = newv(get_class(head($xactions)), array());
$xaction->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS);
$xaction->setNewValue(array('+' => array($actor_phid)));
array_unshift($xactions, $xaction);
return $xactions;
} | Adds the actor as a subscriber to the object with which they interact
@param PhabricatorLiskDAO $object on which the action is performed
@param array $xactions Transactions to apply
@return array Transactions to apply | applyImplicitCC | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function shouldImplyCC(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
return ($xaction->isCommentTransaction() &&
!($xaction->getComment()->getIsRemoved()));
} | Whether the action implies the actor should be subscribed on the object
@param PhabricatorLiskDAO $object on which the action is performed
@param PhabricatorApplicationTransaction $xaction Transaction to apply
@return bool True if the actor should be subscribed on the object | shouldImplyCC | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
return false;
} | @task mail | shouldSendMail | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
private function buildMail(
PhabricatorLiskDAO $object,
array $xactions) {
$email_to = $this->mailToPHIDs;
$email_cc = $this->mailCCPHIDs;
$email_cc = array_merge($email_cc, $this->heraldEmailPHIDs);
$unexpandable = $this->mailUnexpandablePHIDs;
if (!is_array($unexpandable)) {
$unexpandable = array();
}
$messages = $this->buildMailWithRecipients(
$object,
$xactions,
$email_to,
$email_cc,
$unexpandable);
$this->runHeraldMailRules($messages);
return $messages;
} | @task mail | buildMail | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getStrongestAction(
PhabricatorLiskDAO $object,
array $xactions) {
return head(msortv($xactions, 'newActionStrengthSortVector'));
} | @task mail | getStrongestAction | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
throw new Exception(pht('Capability not supported.'));
} | @task mail | buildReplyHandler | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getMailSubjectPrefix() {
throw new Exception(pht('Capability not supported.'));
} | @task mail | getMailSubjectPrefix | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
public function getMailTagsMap() {
// TODO: We should move shared mail tags, like "comment", here.
return array();
} | @task mail | getMailTagsMap | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getMailAction(
PhabricatorLiskDAO $object,
array $xactions) {
return $this->getStrongestAction($object, $xactions)->getActionName();
} | @task mail | getMailAction | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
throw new Exception(pht('Capability not supported.'));
} | @task mail | buildMailTemplate | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getMailTo(PhabricatorLiskDAO $object) {
throw new Exception(pht('Capability not supported.'));
} | @task mail | getMailTo | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function buildMailBody(
PhabricatorLiskDAO $object,
array $xactions) {
$body = id(new PhabricatorMetaMTAMailBody())
->setViewer($this->requireActor())
->setContextObject($object);
$button_label = $this->getObjectLinkButtonLabelForMail($object);
$button_uri = $this->getObjectLinkButtonURIForMail($object);
$this->addHeadersAndCommentsToMailBody(
$body,
$xactions,
$button_label,
$button_uri);
$this->addCustomFieldsToMailBody($body, $object, $xactions);
return $body;
} | @task mail | buildMailBody | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function addEmailPreferenceSectionToMailBody(
PhabricatorMetaMTAMailBody $body,
PhabricatorLiskDAO $object,
array $xactions) {
$href = PhabricatorEnv::getProductionURI(
'/settings/panel/emailpreferences/');
$body->addLinkSection(pht('EMAIL PREFERENCES'), $href);
} | @task mail | addEmailPreferenceSectionToMailBody | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object,
array $xactions) {
return false;
} | @task feed | shouldPublishFeedStory | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getFeedStoryType() {
return 'PhabricatorApplicationTransactionFeedStory';
} | @task feed | getFeedStoryType | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getFeedRelatedPHIDs(
PhabricatorLiskDAO $object,
array $xactions) {
$phids = array(
$object->getPHID(),
$this->getActingAsPHID(),
);
if ($object instanceof PhabricatorProjectInterface) {
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$object->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
foreach ($project_phids as $project_phid) {
$phids[] = $project_phid;
}
}
return $phids;
} | @task feed | getFeedRelatedPHIDs | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getFeedStoryData(
PhabricatorLiskDAO $object,
array $xactions) {
$xactions = msortv($xactions, 'newActionStrengthSortVector');
return array(
'objectPHID' => $object->getPHID(),
'transactionPHIDs' => mpull($xactions, 'getPHID'),
);
} | @task feed | getFeedStoryData | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function supportsSearch() {
return false;
} | @task search | supportsSearch | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
private function getCustomFieldForTransaction(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
$field_key = $xaction->getMetadataValue('customfield:key');
if (!$field_key) {
throw new Exception(
pht(
"Custom field transaction has no '%s'!",
'customfield:key'));
}
$field = PhabricatorCustomField::getObjectField(
$object,
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
$field_key);
if (!$field) {
throw new Exception(
pht(
"Custom field transaction has invalid '%s'; field '%s' ".
"is disabled or does not exist.",
'customfield:key',
$field_key));
}
if (!$field->shouldAppearInApplicationTransactions()) {
throw new Exception(
pht(
"Custom field transaction '%s' does not implement ".
"integration for %s.",
$field_key,
'ApplicationTransactions'));
}
$field->setViewer($this->getActor());
return $field;
} | @task customfield | getCustomFieldForTransaction | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function extractFilePHIDsFromCustomTransaction(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
return array();
} | @task files | extractFilePHIDsFromCustomTransaction | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function willPublish(PhabricatorLiskDAO $object, array $xactions) {
return $object;
} | Load any object state which is required to publish transactions.
This hook is invoked in the main process before we compute data related
to publishing transactions (like email "To" and "CC" lists), and again in
the worker before publishing occurs.
@return object Publishable object.
@task workers | willPublish | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
private function getWorkerState() {
$state = array();
foreach ($this->getAutomaticStateProperties() as $property) {
$state[$property] = $this->$property;
}
$custom_state = $this->getCustomWorkerState();
$custom_encoding = $this->getCustomWorkerStateEncoding();
$state += array(
'excludeMailRecipientPHIDs' => $this->getExcludeMailRecipientPHIDs(),
'custom' => $this->encodeStateForStorage($custom_state, $custom_encoding),
'custom.encoding' => $custom_encoding,
);
return $state;
} | Convert the editor state to a serializable dictionary which can be passed
to a worker.
This data will be loaded with @{method:loadWorkerState} in the worker.
@return dict<string, wild> Serializable editor state.
@task workers | getWorkerState | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getCustomWorkerState() {
return array();
} | Hook; return custom properties which need to be passed to workers.
@return dict<string, wild> Custom properties.
@task workers | getCustomWorkerState | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function getCustomWorkerStateEncoding() {
return array();
} | Hook; return storage encoding for custom properties which need to be
passed to workers.
This primarily allows binary data to be passed to workers and survive
JSON encoding.
@return dict<string, string> Property encodings.
@task workers | getCustomWorkerStateEncoding | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
protected function loadCustomWorkerState(array $state) {
return $this;
} | Hook; set custom properties on the editor from data emitted by
@{method:getCustomWorkerState}.
@param dict<string, wild> $state Custom state,
from @{method:getCustomWorkerState}.
@return $this
@task workers | loadCustomWorkerState | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
private function getAutomaticStateProperties() {
return array(
'parentMessageID',
'isNewObject',
'heraldEmailPHIDs',
'heraldForcedEmailPHIDs',
'heraldHeader',
'mailToPHIDs',
'mailCCPHIDs',
'feedNotifyPHIDs',
'feedRelatedPHIDs',
'feedShouldPublish',
'mailShouldSend',
'mustEncrypt',
'mailStamps',
'mailUnexpandablePHIDs',
'mailMutedPHIDs',
'webhookMap',
'silent',
'sendHistory',
);
} | Get a list of object properties which should be automatically sent to
workers in the state data.
These properties will be automatically stored and loaded by the editor in
the worker.
@return list<string> List of properties.
@task workers | getAutomaticStateProperties | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
private function shouldScramblePolicy($policy) {
switch ($policy) {
case PhabricatorPolicies::POLICY_PUBLIC:
case PhabricatorPolicies::POLICY_USER:
return false;
}
return true;
} | Check if a policy is strong enough to justify scrambling. Objects which
are set to very open policies don't need to scramble their files, and
files with very open policies don't need to be scrambled when associated
objects change. | shouldScramblePolicy | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php | Apache-2.0 |
public function applyEdit(
PhabricatorApplicationTransaction $xaction,
PhabricatorApplicationTransactionComment $comment) {
$this->validateEdit($xaction, $comment);
$actor = $this->requireActor();
$this->applyMFAChecks($xaction, $comment);
$comment->setContentSource($this->getContentSource());
$comment->setAuthorPHID($this->getActingAsPHID());
// TODO: This needs to be more sophisticated once we have meta-policies.
$comment->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC);
$comment->setEditPolicy($this->getActingAsPHID());
$xaction->openTransaction();
$xaction->beginReadLocking();
if ($xaction->getID()) {
$xaction->reload();
}
$new_version = $xaction->getCommentVersion() + 1;
$comment->setCommentVersion($new_version);
$comment->setTransactionPHID($xaction->getPHID());
$comment->save();
$old_comment = $xaction->getComment();
$comment->attachOldComment($old_comment);
$xaction->setCommentVersion($new_version);
$xaction->setCommentPHID($comment->getPHID());
$xaction->setViewPolicy($comment->getViewPolicy());
$xaction->setEditPolicy($comment->getEditPolicy());
$xaction->save();
$xaction->attachComment($comment);
// For comment edits, we need to make sure there are no automagical
// transactions like adding mentions or projects.
if ($new_version > 1) {
$object = id(new PhabricatorObjectQuery())
->withPHIDs(array($xaction->getObjectPHID()))
->setViewer($this->getActor())
->executeOne();
if ($object &&
$object instanceof PhabricatorApplicationTransactionInterface) {
$editor = $object->getApplicationTransactionEditor();
$editor->setActor($this->getActor());
$support_xactions = $editor->getExpandedSupportTransactions(
$object,
$xaction);
if ($support_xactions) {
$editor
->setContentSource($this->getContentSource())
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true)
->applyTransactions($object, $support_xactions);
}
}
}
$xaction->endReadLocking();
$xaction->saveTransaction();
return $this;
} | Edit a transaction's comment. This method effects the required create,
update or delete to set the transaction's comment to the provided comment. | applyEdit | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php | Apache-2.0 |
private function validateEdit(
PhabricatorApplicationTransaction $xaction,
PhabricatorApplicationTransactionComment $comment) {
if (!$xaction->getPHID()) {
throw new Exception(
pht(
'Transaction must have a PHID before calling %s!',
'applyEdit()'));
}
$type_comment = PhabricatorTransactions::TYPE_COMMENT;
if ($xaction->getTransactionType() == $type_comment) {
if ($comment->getPHID()) {
throw new Exception(
pht('Transaction comment must not yet have a PHID!'));
}
}
if (!$this->getContentSource()) {
throw new PhutilInvalidStateException('applyEdit');
}
$actor = $this->requireActor();
PhabricatorPolicyFilter::requireCapability(
$actor,
$xaction,
PhabricatorPolicyCapability::CAN_VIEW);
if ($comment->getIsRemoved() && $actor->getIsAdmin()) {
// NOTE: Administrators can remove comments by any user, and don't need
// to pass the edit check.
} else {
PhabricatorPolicyFilter::requireCapability(
$actor,
$xaction,
PhabricatorPolicyCapability::CAN_EDIT);
PhabricatorPolicyFilter::requireCanInteract(
$actor,
$xaction->getObject());
}
} | Validate that the edit is permissible, and the actor has permission to
perform it. | validateEdit | php | phorgeit/phorge | src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php | Apache-2.0 |
private function buildMessageView($class_name, $icon_name, $text) {
$icon = id(new PHUIIconView())
->setIcon($icon_name);
$message = phutil_tag(
'span',
array(
'class' => 'connection-status-text '.$class_name,
),
$text);
return array(
$icon,
$message,
);
} | Create an icon and a message.
@param string $class_name Raw CSS class name(s) space separated
@param string $icon_name Icon name
@param string $text Text to be shown
@return array | buildMessageView | php | phorgeit/phorge | src/applications/notification/view/PhabricatorNotificationStatusView.php | https://github.com/phorgeit/phorge/blob/master/src/applications/notification/view/PhabricatorNotificationStatusView.php | Apache-2.0 |
public function withUnread($unread) {
$this->unread = $unread;
return $this;
} | Filter results by read/unread status. Note that `true` means to return
only unread notifications, while `false` means to return only //read//
notifications. The default is `null`, which returns both.
@param mixed $unread True or false to filter results by read status. Null
to remove the filter.
@return $this
@task config | withUnread | php | phorgeit/phorge | src/applications/notification/query/PhabricatorNotificationQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/notification/query/PhabricatorNotificationQuery.php | Apache-2.0 |
public function getStartDateTimeEpochForCache() {
$epoch = $this->getStartDateTimeEpoch();
$window = phutil_units('15 minutes in seconds');
return ($epoch - $window);
} | Get the event start epoch for evaluating invitee availability.
When assessing availability, we pretend events start earlier than they
really do. This allows us to mark users away for the entire duration of a
series of back-to-back meetings, even if they don't strictly overlap.
@return int Event start date for availability caches. | getStartDateTimeEpochForCache | php | phorgeit/phorge | src/applications/calendar/storage/PhabricatorCalendarEvent.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/storage/PhabricatorCalendarEvent.php | Apache-2.0 |
public function getMarkupFieldKey($field) {
$content = $this->getMarkupText($field);
return PhabricatorMarkupEngine::digestRemarkupContent($this, $content);
} | @task markup | getMarkupFieldKey | php | phorgeit/phorge | src/applications/calendar/storage/PhabricatorCalendarEvent.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/storage/PhabricatorCalendarEvent.php | Apache-2.0 |
public function getMarkupText($field) {
return $this->getDescription();
} | @task markup | getMarkupText | php | phorgeit/phorge | src/applications/calendar/storage/PhabricatorCalendarEvent.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/storage/PhabricatorCalendarEvent.php | Apache-2.0 |
public function newMarkupEngine($field) {
return PhabricatorMarkupEngine::newCalendarMarkupEngine();
} | @task markup | newMarkupEngine | php | phorgeit/phorge | src/applications/calendar/storage/PhabricatorCalendarEvent.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/storage/PhabricatorCalendarEvent.php | Apache-2.0 |
public function didMarkupText(
$field,
$output,
PhutilMarkupEngine $engine) {
return $output;
} | @task markup | didMarkupText | php | phorgeit/phorge | src/applications/calendar/storage/PhabricatorCalendarEvent.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/storage/PhabricatorCalendarEvent.php | Apache-2.0 |
public function shouldUseMarkupCache($field) {
return (bool)$this->getID();
} | @task markup | shouldUseMarkupCache | php | phorgeit/phorge | src/applications/calendar/storage/PhabricatorCalendarEvent.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/storage/PhabricatorCalendarEvent.php | Apache-2.0 |
public static function getTimestamps(
PhabricatorUser $user,
$start_day_str,
$days) {
$objects = self::getStartDateTimeObjects($user, $start_day_str);
$start_day = $objects['start_day'];
$timestamps = array();
for ($day = 0; $day < $days; $day++) {
$timestamp = clone $start_day;
$timestamp->modify(sprintf('+%d days', $day));
$timestamps[] = $timestamp;
}
return array(
'today' => $objects['today'],
'epoch_stamps' => $timestamps,
);
} | Public for testing purposes only. You should probably use one of the
functions above. | getTimestamps | php | phorgeit/phorge | src/applications/calendar/util/CalendarTimeUtil.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/util/CalendarTimeUtil.php | Apache-2.0 |
private function generateTestUserWithVerifiedMail($mail, $is_verified) {
$user = $this->generateNewTestUser();
// Set our primary address as verified or not.
$email = id(new PhabricatorUserEmail())->loadOneWhere(
'userPHID = %s',
$user->getPHID());
$email->setAddress($mail);
$email->setIsVerified($is_verified);
$email->setIsPrimary(true);
$email->save();
return $user;
} | Generate a test user with a specific verified (or not) email.
@param string $mail Email address
@param int $is_verified 0: unverified, 1: verified
@return PhabricatorUser | generateTestUserWithVerifiedMail | php | phorgeit/phorge | src/applications/calendar/import/__tests__/CalendarImportTestCase.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/import/__tests__/CalendarImportTestCase.php | Apache-2.0 |
private function getDisplayYearAndMonthAndDay(
$range_start,
$range_end,
$display) {
$viewer = $this->requireViewer();
$epoch = null;
if ($this->calendarYear && $this->calendarMonth) {
$start_year = $this->calendarYear;
$start_month = $this->calendarMonth;
$start_day = $this->calendarDay ? $this->calendarDay : 1;
} else {
if ($range_start) {
$epoch = $range_start;
} else if ($range_end) {
$epoch = $range_end;
} else {
$epoch = time();
}
if ($display == 'month') {
$day = 1;
} else {
$day = phabricator_format_local_time($epoch, $viewer, 'd');
}
$start_year = phabricator_format_local_time($epoch, $viewer, 'Y');
$start_month = phabricator_format_local_time($epoch, $viewer, 'm');
$start_day = $day;
}
return array($start_year, $start_month, $start_day);
} | @param string|null $range_start Epoch
@param string|null $range_end Epoch
@param string $display View, such as "month" or "day"
@return array<string|int, string|int, string|int> YYYY, M, D | getDisplayYearAndMonthAndDay | php | phorgeit/phorge | src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | Apache-2.0 |
private function getQueryDateFrom(PhabricatorSavedQuery $saved) {
if ($this->calendarYear && $this->calendarMonth) {
$viewer = $this->requireViewer();
$start_year = $this->calendarYear;
$start_month = $this->calendarMonth;
$start_day = $this->calendarDay ? $this->calendarDay : 1;
return AphrontFormDateControlValue::newFromDictionary(
$viewer,
array(
'd' => "{$start_year}-{$start_month}-{$start_day}",
));
}
$date = $this->getQueryDate($saved, 'rangeStart');
$this->validateDate($date);
return $date;
} | @param PhabricatorSavedQuery $saved
@return AphrontFormDateControlValue Query date range start | getQueryDateFrom | php | phorgeit/phorge | src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | Apache-2.0 |
private function getQueryDateTo(PhabricatorSavedQuery $saved) {
$date = $this->getQueryDate($saved, 'rangeEnd');
$this->validateDate($date);
return $date;
} | @param PhabricatorSavedQuery $saved
@return AphrontFormDateControlValue Query date range end | getQueryDateTo | php | phorgeit/phorge | src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | Apache-2.0 |
private function validateDate(AphrontFormDateControlValue $date) {
if (!$date->isValid()) {
// TODO: Use DateMalformedStringException once we require PHP 8.3.0
throw new Exception(
pht('Invalid date or time value set as query value.'));
}
} | Validate the user provided date and time value(s) by calling
@{class:AphrontFormDateControlValue}::isValid().
Throw an Exception if invalid.
@param AphrontFormDateControlValue $date
@return void | validateDate | php | phorgeit/phorge | src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php | Apache-2.0 |
public static function loadRestrictedNamespace(
PhabricatorUser $viewer,
$name) {
// For a name like "x.y.z", produce a list of controlling namespaces like
// ("z", "y.x", "x.y.z").
$names = array();
$parts = explode('.', $name);
for ($ii = 0; $ii < count($parts); $ii++) {
$names[] = implode('.', array_slice($parts, -($ii + 1)));
}
// Load all the possible controlling namespaces.
$namespaces = id(new AlmanacNamespaceQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withNames($names)
->execute();
if (!$namespaces) {
return null;
}
// Find the "nearest" (longest) namespace that exists. If both
// "sub.domain.com" and "domain.com" exist, we only care about the policy
// on the former.
$namespaces = msort($namespaces, 'getNameLength');
$namespace = last($namespaces);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$namespace,
PhabricatorPolicyCapability::CAN_EDIT);
if ($can_edit) {
return null;
}
return $namespace;
} | Load the namespace which prevents use of an Almanac name, if one exists. | loadRestrictedNamespace | php | phorgeit/phorge | src/applications/almanac/storage/AlmanacNamespace.php | https://github.com/phorgeit/phorge/blob/master/src/applications/almanac/storage/AlmanacNamespace.php | Apache-2.0 |
public function isClusterServiceType() {
return false;
} | Return `true` if this service type is a Phabricator cluster service type.
These special services change the behavior of Phabricator, and require
elevated permission to create and edit.
@return bool True if this is a Phabricator cluster service type. | isClusterServiceType | php | phorgeit/phorge | src/applications/almanac/servicetype/AlmanacServiceType.php | https://github.com/phorgeit/phorge/blob/master/src/applications/almanac/servicetype/AlmanacServiceType.php | Apache-2.0 |
public static function getAllServiceTypes() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getServiceTypeConstant')
->setSortMethod('getServiceTypeName')
->execute();
} | List all available service type implementations.
@return map<string, object> Dictionary of available service types. | getAllServiceTypes | php | phorgeit/phorge | src/applications/almanac/servicetype/AlmanacServiceType.php | https://github.com/phorgeit/phorge/blob/master/src/applications/almanac/servicetype/AlmanacServiceType.php | Apache-2.0 |
public static function getCleanGitWorkspace(
PhabricatorRepository $repo) {
$origin_path = $repo->getLocalPath();
$path = rtrim($origin_path, '/');
$path = $path.'__workspace';
if (!Filesystem::pathExists($path)) {
$repo->execxLocalCommand(
'clone -- file://%s %s',
$origin_path,
$path);
if (!$repo->isHosted()) {
id(new ArcanistGitAPI($path))->execxLocal(
'remote set-url origin %s',
$repo->getRemoteURI());
}
}
$workspace = new ArcanistGitAPI($path);
$workspace->execxLocal('clean -f -d');
$workspace->execxLocal('checkout master');
$workspace->execxLocal('fetch');
$workspace->execxLocal('reset --hard origin/master');
$workspace->reloadWorkingCopy();
return $workspace;
} | Creates and/or cleans a workspace for the requested repo.
return ArcanistGitAPI | getCleanGitWorkspace | php | phorgeit/phorge | src/applications/differential/DifferentialGetWorkingCopy.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/DifferentialGetWorkingCopy.php | Apache-2.0 |
public static function getCleanMercurialWorkspace(
PhabricatorRepository $repo) {
$origin_path = $repo->getLocalPath();
$path = rtrim($origin_path, '/');
$path = $path.'__workspace';
if (!Filesystem::pathExists($path)) {
$repo->execxLocalCommand(
'clone -- file://%s %s',
$origin_path,
$path);
}
$workspace = new ArcanistMercurialAPI($path);
$workspace->execxLocal('pull');
$workspace->execxLocal('update --clean default');
$workspace->reloadWorkingCopy();
return $workspace;
} | Creates and/or cleans a workspace for the requested repo.
return ArcanistMercurialAPI | getCleanMercurialWorkspace | php | phorgeit/phorge | src/applications/differential/DifferentialGetWorkingCopy.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/DifferentialGetWorkingCopy.php | Apache-2.0 |
public function hasSameEffectAs(DifferentialChangeset $other) {
if ($this->getFilename() !== $other->getFilename()) {
return false;
}
$hash_key = self::METADATA_EFFECT_HASH;
$u_hash = $this->getChangesetMetadata($hash_key);
if ($u_hash === null) {
return false;
}
$v_hash = $other->getChangesetMetadata($hash_key);
if ($v_hash === null) {
return false;
}
if ($u_hash !== $v_hash) {
return false;
}
// Make sure the final states for the file properties (like the "+x"
// executable bit) match one another.
$u_props = $this->getNewProperties();
$v_props = $other->getNewProperties();
ksort($u_props);
ksort($v_props);
if ($u_props !== $v_props) {
return false;
}
return true;
} | Test if this changeset and some other changeset put the affected file in
the same state.
@param DifferentialChangeset $other Changeset to compare against.
@return bool True if the two changesets have the same effect. | hasSameEffectAs | php | phorgeit/phorge | src/applications/differential/storage/DifferentialChangeset.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/storage/DifferentialChangeset.php | Apache-2.0 |
public function setRevisionID($revision_id) {
$revision = id(new DifferentialRevision())->load($revision_id);
return $this->setRevision($revision);
} | Although these are purely transitional, they're also *extra* dumb. | setRevisionID | php | phorgeit/phorge | src/applications/differential/storage/DifferentialInlineComment.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/storage/DifferentialInlineComment.php | Apache-2.0 |
public static function getStatusStrength($constant) {
$map = array(
self::STATUS_ADDED => 1,
self::STATUS_COMMENTED => 2,
self::STATUS_BLOCKING => 3,
self::STATUS_ACCEPTED_OLDER => 4,
self::STATUS_REJECTED_OLDER => 4,
self::STATUS_ACCEPTED => 5,
self::STATUS_REJECTED => 5,
self::STATUS_RESIGNED => 5,
);
return idx($map, $constant, 0);
} | Returns the relative strength of a status, used to pick a winner when a
transaction group makes several status changes to a particular reviewer.
For example, if you accept a revision and leave a comment, the transactions
will attempt to update you to both "commented" and "accepted". We want
"accepted" to win, because it's the stronger of the two.
@param string $constant Reviewer status constant.
@return int Relative strength (higher is stronger). | getStatusStrength | php | phorgeit/phorge | src/applications/differential/constants/DifferentialReviewerStatus.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/constants/DifferentialReviewerStatus.php | Apache-2.0 |
protected function renderShowContextLinks(
$top,
$len,
$changeset_length,
$is_blocks = false) {
$block_size = 20;
$end = ($top + $len) - $block_size;
// If this is a large block, such that the "top" and "bottom" ranges are
// non-overlapping, we'll provide options to show the top, bottom or entire
// block. For smaller blocks, we only provide an option to show the entire
// block, since it would be silly to show the bottom 20 lines of a 25-line
// block.
$is_large_block = ($len > ($block_size * 2));
$links = array();
$block_display = new PhutilNumber($block_size);
if ($is_large_block) {
$is_first_block = ($top == 0);
if ($is_first_block) {
if ($is_blocks) {
$text = pht('Show First %s Block(s)', $block_display);
} else {
$text = pht('Show First %s Line(s)', $block_display);
}
} else {
if ($is_blocks) {
$text = pht("\xE2\x96\xB2 Show %s Block(s)", $block_display);
} else {
$text = pht("\xE2\x96\xB2 Show %s Line(s)", $block_display);
}
}
$links[] = $this->renderShowContextLink(
false,
"{$top}-{$len}/{$top}-20",
$text);
}
if ($is_blocks) {
$text = pht('Show All %s Block(s)', new PhutilNumber($len));
} else {
$text = pht('Show All %s Line(s)', new PhutilNumber($len));
}
$links[] = $this->renderShowContextLink(
true,
"{$top}-{$len}/{$top}-{$len}",
$text);
if ($is_large_block) {
$is_last_block = (($top + $len) >= $changeset_length);
if ($is_last_block) {
if ($is_blocks) {
$text = pht('Show Last %s Block(s)', $block_display);
} else {
$text = pht('Show Last %s Line(s)', $block_display);
}
} else {
if ($is_blocks) {
$text = pht("\xE2\x96\xBC Show %s Block(s)", $block_display);
} else {
$text = pht("\xE2\x96\xBC Show %s Line(s)", $block_display);
}
}
$links[] = $this->renderShowContextLink(
false,
"{$top}-{$len}/{$end}-20",
$text);
}
return phutil_implode_html(" \xE2\x80\xA2 ", $links);
} | Build links which users can click to show more context in a changeset.
@param int $top Beginning of the line range to build links for.
@param int $len Length of the line range to build links for.
@param int $changeset_length Total number of lines in the changeset.
@param bool $is_blocks (optional)
@return markup Rendered links. | renderShowContextLinks | php | phorgeit/phorge | src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | Apache-2.0 |
private function renderShowContextLink($is_all, $range, $text) {
$reference = $this->getRenderingReference();
return javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
'sigil' => 'show-more',
'meta' => array(
'type' => ($is_all ? 'all' : null),
'range' => $range,
),
),
$text);
} | Build a link that shows more context in a changeset.
See @{method:renderShowContextLinks}.
@param bool $is_all Does this link show all context when clicked?
@param string $range Range specification for lines to show.
@param string $text Text of the link.
@return markup Rendered link. | renderShowContextLink | php | phorgeit/phorge | src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | Apache-2.0 |
protected function getLineIDPrefixes() {
// These look like "C123NL45", which means the line is line 45 on the
// "new" side of the file in changeset 123.
// The "C" stands for "changeset", and is followed by a changeset ID.
// "N" stands for "new" and means the comment should attach to the new file
// when stored. "O" stands for "old" and means the comment should attach to
// the old file. These are important because either the old or new part
// of a file may appear on the left or right side of the diff in the
// diff-of-diffs view.
// The "L" stands for "line" and is followed by the line number.
if ($this->getOldChangesetID()) {
$left_prefix = array();
$left_prefix[] = 'C';
$left_prefix[] = $this->getOldChangesetID();
$left_prefix[] = $this->getOldAttachesToNewFile() ? 'N' : 'O';
$left_prefix[] = 'L';
$left_prefix = implode('', $left_prefix);
} else {
$left_prefix = null;
}
if ($this->getNewChangesetID()) {
$right_prefix = array();
$right_prefix[] = 'C';
$right_prefix[] = $this->getNewChangesetID();
$right_prefix[] = $this->getNewAttachesToNewFile() ? 'N' : 'O';
$right_prefix[] = 'L';
$right_prefix = implode('', $right_prefix);
} else {
$right_prefix = null;
}
return array($left_prefix, $right_prefix);
} | Build the prefixes for line IDs used to track inline comments.
@return pair<wild, wild> Left and right prefixes. | getLineIDPrefixes | php | phorgeit/phorge | src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php | Apache-2.0 |
public function getFieldKeyForConduit() {
return $this->getFieldKey();
} | TODO: It would be nice to remove this, but a lot of different code is
bound together by it. Until everything is modernized, retaining the old
field keys is the only reasonable way to update things one piece
at a time. | getFieldKeyForConduit | php | phorgeit/phorge | src/applications/differential/customfield/DifferentialCustomField.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/customfield/DifferentialCustomField.php | Apache-2.0 |
public function getProTips() {
if ($this->getProxy()) {
return $this->getProxy()->getProTips();
}
return array();
} | @task commitmessage | getProTips | php | phorgeit/phorge | src/applications/differential/customfield/DifferentialCustomField.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/customfield/DifferentialCustomField.php | Apache-2.0 |
public function shouldAppearInDiffPropertyView() {
if ($this->getProxy()) {
return $this->getProxy()->shouldAppearInDiffPropertyView();
}
return false;
} | @task diff | shouldAppearInDiffPropertyView | php | phorgeit/phorge | src/applications/differential/customfield/DifferentialCustomField.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/customfield/DifferentialCustomField.php | Apache-2.0 |
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {
if ($this->getProxy()) {
return $this->getProxy()->renderDiffPropertyViewLabel($diff);
}
return $this->getFieldName();
} | @task diff | renderDiffPropertyViewLabel | php | phorgeit/phorge | src/applications/differential/customfield/DifferentialCustomField.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/customfield/DifferentialCustomField.php | Apache-2.0 |
public function renderDiffPropertyViewValue(DifferentialDiff $diff) {
if ($this->getProxy()) {
return $this->getProxy()->renderDiffPropertyViewValue($diff);
}
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
} | @task diff | renderDiffPropertyViewValue | php | phorgeit/phorge | src/applications/differential/customfield/DifferentialCustomField.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/customfield/DifferentialCustomField.php | Apache-2.0 |
protected function shouldGroupTransactions(
PhabricatorApplicationTransaction $u,
PhabricatorApplicationTransaction $v) {
if ($u->getAuthorPHID() != $v->getAuthorPHID()) {
// Don't group transactions by different authors.
return false;
}
if (($v->getDateCreated() - $u->getDateCreated()) > 60) {
// Don't group if transactions that happened more than 60s apart.
return false;
}
switch ($u->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
case DifferentialTransaction::TYPE_INLINE:
break;
default:
return false;
}
switch ($v->getTransactionType()) {
case DifferentialTransaction::TYPE_INLINE:
return true;
}
return parent::shouldGroupTransactions($u, $v);
} | TODO: There's a whole lot of code duplication between this and
PholioTransactionView to handle inlines. Merge this into the core? Some of
it can probably be shared, while other parts are trickier. | shouldGroupTransactions | php | phorgeit/phorge | src/applications/differential/view/DifferentialTransactionView.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/view/DifferentialTransactionView.php | Apache-2.0 |
public function withPaths(array $paths) {
$this->paths = $paths;
return $this;
} | Find revisions affecting one or more items in a list of paths.
@param list<string> $paths List of file paths.
@return $this
@task config | withPaths | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
public function withAuthors(array $author_phids) {
$this->authors = $author_phids;
return $this;
} | Filter results to revisions authored by one of the given PHIDs. Calling
this function will clear anything set by previous calls to
@{method:withAuthors}.
@param array $author_phids List of PHIDs of authors
@return $this
@task config | withAuthors | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
public function withCCs(array $cc_phids) {
$this->ccs = $cc_phids;
return $this;
} | Filter results to revisions which CC one of the listed people. Calling this
function will clear anything set by previous calls to @{method:withCCs}.
@param array $cc_phids List of PHIDs of subscribers.
@return $this
@task config | withCCs | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
public function withReviewers(array $reviewer_phids) {
if ($reviewer_phids === array()) {
throw new Exception(
pht(
'Empty "withReviewers()" constraint is invalid. Provide one or '.
'more values, or remove the constraint.'));
}
$with_none = false;
foreach ($reviewer_phids as $key => $phid) {
switch ($phid) {
case DifferentialNoReviewersDatasource::FUNCTION_TOKEN:
$with_none = true;
unset($reviewer_phids[$key]);
break;
default:
break;
}
}
$this->noReviewers = $with_none;
if ($reviewer_phids) {
$this->reviewers = array_values($reviewer_phids);
}
return $this;
} | Filter results to revisions that have one of the provided PHIDs as
reviewers. Calling this function will clear anything set by previous calls
to @{method:withReviewers}.
@param array $reviewer_phids List of PHIDs of reviewers
@return $this
@task config | withReviewers | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
public function withCommitHashes(array $commit_hashes) {
$this->commitHashes = $commit_hashes;
return $this;
} | Filter results to revisions that have one of the provided commit hashes.
Calling this function will clear anything set by previous calls to
@{method:withCommitHashes}.
@param array $commit_hashes List of pairs <Class
ArcanistDifferentialRevisionHash::HASH_$type constant,
hash>
@return $this
@task config | withCommitHashes | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
public function withBranches(array $branches) {
$this->branches = $branches;
return $this;
} | Filter results to revisions on given branches.
@param list $branches List of branch names.
@return $this
@task config | withBranches | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
public function withIDs(array $ids) {
$this->revIDs = $ids;
return $this;
} | Filter results to only return revisions whose ids are in the given set.
@param array $ids List of revision ids
@return $this
@task config | withIDs | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
public function withPHIDs(array $phids) {
$this->phids = $phids;
return $this;
} | Filter results to only return revisions whose PHIDs are in the given set.
@param array $phids List of revision PHIDs
@return $this
@task config | withPHIDs | php | phorgeit/phorge | src/applications/differential/query/DifferentialRevisionQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/differential/query/DifferentialRevisionQuery.php | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.