本文整理汇总了PHP中PhabricatorOwnersPackage::attachOldPrimaryOwnerPHID方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorOwnersPackage::attachOldPrimaryOwnerPHID方法的具体用法?PHP PhabricatorOwnersPackage::attachOldPrimaryOwnerPHID怎么用?PHP PhabricatorOwnersPackage::attachOldPrimaryOwnerPHID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorOwnersPackage
的用法示例。
在下文中一共展示了PhabricatorOwnersPackage::attachOldPrimaryOwnerPHID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
if ($this->id) {
$package = id(new PhabricatorOwnersPackage())->load($this->id);
if (!$package) {
return new Aphront404Response();
}
} else {
$package = new PhabricatorOwnersPackage();
$package->setPrimaryOwnerPHID($user->getPHID());
}
$e_name = true;
$e_primary = true;
$errors = array();
if ($request->isFormPost()) {
$package->setName($request->getStr('name'));
$package->setDescription($request->getStr('description'));
$old_auditing_enabled = $package->getAuditingEnabled();
$package->setAuditingEnabled($request->getStr('auditing') === 'enabled' ? 1 : 0);
$primary = $request->getArr('primary');
$primary = reset($primary);
$old_primary = $package->getPrimaryOwnerPHID();
$package->setPrimaryOwnerPHID($primary);
$owners = $request->getArr('owners');
if ($primary) {
array_unshift($owners, $primary);
}
$owners = array_unique($owners);
$paths = $request->getArr('path');
$repos = $request->getArr('repo');
$excludes = $request->getArr('exclude');
$path_refs = array();
for ($ii = 0; $ii < count($paths); $ii++) {
if (empty($paths[$ii]) || empty($repos[$ii])) {
continue;
}
$path_refs[] = array('repositoryPHID' => $repos[$ii], 'path' => $paths[$ii], 'excluded' => $excludes[$ii]);
}
if (!strlen($package->getName())) {
$e_name = pht('Required');
$errors[] = pht('Package name is required.');
} else {
$e_name = null;
}
if (!$package->getPrimaryOwnerPHID()) {
$e_primary = pht('Required');
$errors[] = pht('Package must have a primary owner.');
} else {
$e_primary = null;
}
if (!$path_refs) {
$errors[] = pht('Package must include at least one path.');
}
if (!$errors) {
$package->attachUnsavedOwners($owners);
$package->attachUnsavedPaths($path_refs);
$package->attachOldAuditingEnabled($old_auditing_enabled);
$package->attachOldPrimaryOwnerPHID($old_primary);
$package->attachActorPHID($user->getPHID());
try {
$package->save();
return id(new AphrontRedirectResponse())->setURI('/owners/package/' . $package->getID() . '/');
} catch (AphrontDuplicateKeyQueryException $ex) {
$e_name = pht('Duplicate');
$errors[] = pht('Package name must be unique.');
}
}
} else {
$owners = $package->loadOwners();
$owners = mpull($owners, 'getUserPHID');
$paths = $package->loadPaths();
$path_refs = array();
foreach ($paths as $path) {
$path_refs[] = array('repositoryPHID' => $path->getRepositoryPHID(), 'path' => $path->getPath(), 'excluded' => $path->getExcluded());
}
}
$handles = $this->loadViewerHandles($owners);
$primary = $package->getPrimaryOwnerPHID();
if ($primary && isset($handles[$primary])) {
$handle_primary_owner = array($handles[$primary]);
} else {
$handle_primary_owner = array();
}
$handles_all_owners = array_select_keys($handles, $owners);
if ($package->getID()) {
$title = pht('Edit Package');
$side_nav_filter = 'edit/' . $this->id;
} else {
$title = pht('New Package');
$side_nav_filter = 'new';
}
$this->setSideNavFilter($side_nav_filter);
$repos = id(new PhabricatorRepositoryQuery())->setViewer($user)->execute();
$default_paths = array();
foreach ($repos as $repo) {
$default_path = $repo->getDetail('default-owners-path');
if ($default_path) {
$default_paths[$repo->getPHID()] = $default_path;
//.........这里部分代码省略.........