本文整理汇总了PHP中PhabricatorContentSource::newConsoleSource方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorContentSource::newConsoleSource方法的具体用法?PHP PhabricatorContentSource::newConsoleSource怎么用?PHP PhabricatorContentSource::newConsoleSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorContentSource
的用法示例。
在下文中一共展示了PhabricatorContentSource::newConsoleSource方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateServiceLock
protected function updateServiceLock(AlmanacService $service, $lock)
{
$almanac_phid = id(new PhabricatorAlmanacApplication())->getPHID();
$xaction = id(new AlmanacServiceTransaction())->setTransactionType(AlmanacServiceTransaction::TYPE_LOCK)->setNewValue((int) $lock);
$editor = id(new AlmanacServiceEditor())->setActor($this->getViewer())->setActingAsPHID($almanac_phid)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnMissingFields(true);
$editor->applyTransactions($service, array($xaction));
}
示例2: generate
public function generate()
{
$title = $this->generateTitle();
// Prepend or append 'Sprint'
$title = mt_rand(0, 1) ? $title . ' Sprint' : 'Sprint ' . $title;
$author = $this->loadPhabrictorUser();
$authorPHID = $author->getPHID();
$project = PhabricatorProject::initializeNewProject($author);
$this->addTransaction(PhabricatorProjectTransaction::TYPE_NAME, $title);
$this->addTransaction(PhabricatorProjectTransaction::TYPE_ICON, 'fa-briefcase');
$this->addTransaction(PhabricatorProjectTransaction::TYPE_COLOR, 'blue');
// $this->addTransaction(
// PhabricatorProjectTransaction::TYPE_MEMBERS,
// $this->loadMembersWithAuthor($authorPHID));
$this->addTransaction(PhabricatorTransactions::TYPE_VIEW_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
$this->addTransaction(PhabricatorTransactions::TYPE_EDIT_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
$this->addTransaction(PhabricatorTransactions::TYPE_JOIN_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
// Pick a date to be the start date for the sprint
// Random between 4 weeks ago and one week from now
$start = mt_rand(time() - 28 * 24 * 60 * 60, time() + 7 * 24 * 60 * 60);
$this->xactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)->setMetadataValue('customfield:key', 'isdc:sprint:startdate')->setOldValue(null)->setNewValue($start);
// Pick a date to be the end date for the sprint
// Sprint is between 3 days and 3 weeks long
$end = $start + mt_rand(3 * 24 * 60 * 60, 21 * 24 * 60 * 60);
$this->xactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)->setMetadataValue('customfield:key', 'isdc:sprint:enddate')->setOldValue(null)->setNewValue($end);
$editor = id(new PhabricatorProjectTransactionEditor())->setActor($author)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $this->xactions);
$project->save();
// Generate a bunch of tasks created the before the sprint starts
for ($i = 0, $num = mt_rand(5, 40); $i <= $num; $i++) {
echo ".";
$this->generateTask($project, $start, $end);
}
return $project;
}
示例3: addMessageWithFile
protected function addMessageWithFile(PhabricatorUser $actor, ConpherenceThread $conpherence)
{
$file = $this->generateTestFile($actor);
$message = Filesystem::readRandomCharacters(64) . sprintf(' {%s} ', $file->getMonogram());
$editor = id(new ConpherenceEditor())->setActor($actor)->setContentSource(PhabricatorContentSource::newConsoleSource());
$xactions = $editor->generateTransactionsFromText($actor, $conpherence, $message);
return $editor->applyTransactions($conpherence, $xactions);
}
示例4: generate
public function generate()
{
$title = $this->generateTitle();
$author = $this->loadPhabrictorUser();
$authorPHID = $author->getPHID();
$project = id(new PhabricatorProject())->setName($title)->setAuthorPHID($authorPHID);
$this->addTransaction(PhabricatorProjectTransaction::TYPE_NAME, $title);
$this->addTransaction(PhabricatorProjectTransaction::TYPE_MEMBERS, $this->loadMembersWithAuthor($authorPHID));
$this->addTransaction(PhabricatorProjectTransaction::TYPE_STATUS, $this->generateProjectStatus());
$this->addTransaction(PhabricatorTransactions::TYPE_VIEW_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
$this->addTransaction(PhabricatorTransactions::TYPE_EDIT_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
$this->addTransaction(PhabricatorTransactions::TYPE_JOIN_POLICY, PhabricatorPolicies::POLICY_PUBLIC);
$editor = id(new PhabricatorProjectTransactionEditor())->setActor($author)->setContentSource(PhabricatorContentSource::newConsoleSource())->applyTransactions($project, $this->xactions);
return $project->save();
}
示例5: execute
public function execute(PhutilArgumentParser $args)
{
$repos = $this->loadRepositories($args, 'repos');
if (!$repos) {
throw new PhutilArgumentUsageException(pht('Specify one or more repositories to edit.'));
}
$console = PhutilConsole::getConsole();
// TODO: It would be nice to just take this action as "Administrator" or
// similar, since that would make it easier to use this script, harder to
// impersonate users, and more clear to viewers what happened. However,
// the omnipotent user doesn't have a PHID right now, can't be loaded,
// doesn't have a handle, etc. Adding all of that is fairly involved, and
// I want to wait for stronger use cases first.
$username = $args->getArg('as');
if (!$username) {
throw new PhutilArgumentUsageException(pht('Specify a user to edit as with %s.', '--as <username>'));
}
$actor = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withUsernames(array($username))->executeOne();
if (!$actor) {
throw new PhutilArgumentUsageException(pht("No such user '%s'!", $username));
}
foreach ($repos as $repo) {
$console->writeOut("%s\n", pht('Editing "%s"...', $repo->getDisplayName()));
$xactions = array();
$type_local_path = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
$type_protocol_http = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_HTTP;
$type_protocol_ssh = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_SSH;
$allowed_serve_modes = array(PhabricatorRepository::SERVE_OFF, PhabricatorRepository::SERVE_READONLY, PhabricatorRepository::SERVE_READWRITE);
if ($args->getArg('local-path')) {
$xactions[] = id(new PhabricatorRepositoryTransaction())->setTransactionType($type_local_path)->setNewValue($args->getArg('local-path'));
}
$serve_http = $args->getArg('serve-http');
if ($serve_http && in_array($serve_http, $allowed_serve_modes)) {
$xactions[] = id(new PhabricatorRepositoryTransaction())->setTransactionType($type_protocol_http)->setNewValue($serve_http);
}
$serve_ssh = $args->getArg('serve-ssh');
if ($serve_ssh && in_array($serve_ssh, $allowed_serve_modes)) {
$xactions[] = id(new PhabricatorRepositoryTransaction())->setTransactionType($type_protocol_ssh)->setNewValue($serve_ssh);
}
if (!$xactions) {
throw new PhutilArgumentUsageException(pht('Specify one or more fields to edit!'));
}
$content_source = PhabricatorContentSource::newConsoleSource();
$editor = id(new PhabricatorRepositoryEditor())->setActor($actor)->setContentSource($content_source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($repo, $xactions);
}
$console->writeOut("%s\n", pht('Done.'));
return 0;
}
示例6: execute
public function execute(PhutilArgumentParser $args)
{
$repos = $this->loadRepositories($args, 'repos');
if (!$repos) {
throw new PhutilArgumentUsageException('Specify one or more repositories to edit, by callsign.');
}
$console = PhutilConsole::getConsole();
// TODO: It would be nice to just take this action as "Administrator" or
// similar, since that would make it easier to use this script, harder to
// impersonate users, and more clear to viewers what happened. However,
// the omnipotent user doesn't have a PHID right now, can't be loaded,
// doesn't have a handle, etc. Adding all of that is fairly involved, and
// I want to wait for stronger use cases first.
$username = $args->getArg('as');
if (!$username) {
throw new PhutilArgumentUsageException(pht('Specify a user to edit as with --as <username>.'));
}
$actor = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withUsernames(array($username))->executeOne();
if (!$actor) {
throw new PhutilArgumentUsageException(pht("No such user '%s'!", $username));
}
foreach ($repos as $repo) {
$console->writeOut("Editing '%s'...\n", $repo->getCallsign());
$xactions = array();
$type_local_path = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
if ($args->getArg('local-path')) {
$xactions[] = id(new PhabricatorRepositoryTransaction())->setTransactionType($type_local_path)->setNewValue($args->getArg('local-path'));
}
if (!$xactions) {
throw new PhutilArgumentUsageException(pht('Specify one or more fields to edit!'));
}
$content_source = PhabricatorContentSource::newConsoleSource();
$editor = id(new PhabricatorRepositoryEditor())->setActor($actor)->setContentSource($content_source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($repo, $xactions);
}
$console->writeOut("Done.\n");
return 0;
}
示例7: applyTransactions
private function applyTransactions(PhabricatorProject $project, PhabricatorUser $user, array $xactions)
{
$editor = id(new PhabricatorProjectTransactionEditor())->setActor($user)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnNoEffect(true)->applyTransactions($project, $xactions);
}
示例8: joinOrLeaveProject
private function joinOrLeaveProject(PhabricatorProject $project, PhabricatorUser $user, $operation)
{
$spec = array($operation => array($user->getPHID() => $user->getPHID()));
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectProjectHasMemberEdgeType::EDGECONST)->setNewValue($spec);
$editor = id(new PhabricatorProjectTransactionEditor())->setActor($user)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnNoEffect(true)->applyTransactions($project, $xactions);
}
示例9: changeEditPolicy
private function changeEditPolicy(PhabricatorUser $actor, ConpherenceThread $room, $policy)
{
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($policy);
id(new ConpherenceEditor())->setActor($actor)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnNoEffect(true)->applyTransactions($room, $xactions);
}
示例10: newSpace
private function newSpace(PhabricatorUser $actor, $name, $is_default, array $options = array())
{
$space = PhabricatorSpacesNamespace::initializeNewNamespace($actor);
$type_name = PhabricatorSpacesNamespaceTransaction::TYPE_NAME;
$type_default = PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
$xactions = array();
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction())->setTransactionType($type_name)->setNewValue($name);
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction())->setTransactionType($type_view)->setNewValue($actor->getPHID());
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction())->setTransactionType($type_edit)->setNewValue($actor->getPHID());
if ($is_default) {
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction())->setTransactionType($type_default)->setNewValue($is_default);
}
$content_source = PhabricatorContentSource::newConsoleSource();
$editor = id(new PhabricatorSpacesNamespaceEditor())->setActor($actor)->setContentSource($content_source);
if (isset($options['continueOnNoEffect'])) {
$editor->setContinueOnNoEffect(true);
}
$editor->applyTransactions($space, $xactions);
return $space;
}
示例11: applyTaskTransactions
private function applyTaskTransactions(PhabricatorUser $viewer, ManiphestTask $task, array $xactions)
{
$content_source = PhabricatorContentSource::newConsoleSource();
$editor = id(new ManiphestTransactionEditor())->setActor($viewer)->setContentSource($content_source)->setContinueOnNoEffect(true)->applyTransactions($task, $xactions);
return $task;
}
示例12: createThread
private function createThread(PhabricatorUser $creator, array $participant_phids)
{
list($errors, $conpherence) = ConpherenceEditor::createThread($creator, $participant_phids, pht('Test'), pht('Test'), PhabricatorContentSource::newConsoleSource());
return $conpherence;
}
示例13: modifyProjectMembers
function modifyProjectMembers($project, $members_diff, $viewer)
{
$projectname = $project->getName();
if (DEBUG && !empty($members_diff['+'])) {
debug("Will add members to project '" . $projectname . "':\n");
foreach ($members_diff['+'] as $memberphid) {
$user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($memberphid))->executeOne();
$username = $user->getUserName();
debug(" " . $username . " (" . $memberphid . ")\n");
}
}
if (DEBUG && !empty($members_diff['-'])) {
debug("Will remove members from project '" . $projectname . "':\n");
foreach ($members_diff['-'] as $memberphid) {
$user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($memberphid))->executeOne();
$username = $user->getUserName();
debug(" " . $username . " (" . $memberphid . ")\n");
}
}
if (!DRY_RUN) {
$type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_member)->setNewValue($members_diff);
$editor = id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions);
}
}