Skip to content

Commit 378cf17

Browse files
committed
Updated restriction types
Added newly available restriction types Added method to add custom restriction types (when new one come available)
1 parent d9c45f4 commit 378cf17

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

lib/Bitbucket/API/Repositories/BranchRestrictions.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@
2121
*/
2222
class BranchRestrictions extends Api
2323
{
24+
/**
25+
* Allowed restrictions to create a new branch permission for
26+
* @var array
27+
*/
28+
protected $allowedRestrictionTypes = array(
29+
'require_tasks_to_be_completed',
30+
'require_passing_builds_to_merge',
31+
'force',
32+
'require_all_dependencies_merged',
33+
'push',
34+
'require_approvals_to_merge',
35+
'enforce_merge_checks',
36+
'restrict_merges',
37+
'reset_pullrequest_approvals_on_change',
38+
'delete'
39+
);
40+
2441
/**
2542
* Get the information associated with a repository's branch restrictions
2643
*
@@ -64,7 +81,7 @@ public function create($account, $repo, $params = array())
6481

6582
$params = array_merge($defaults, $params);
6683

67-
if (empty($params['kind']) || !in_array($params['kind'], array('push', 'delete', 'force','restrict_merges'))) {
84+
if (empty($params['kind']) || !in_array($params['kind'], $this->$allowedRestrictionTypes)) {
6885
throw new \InvalidArgumentException('Invalid restriction kind.');
6986
}
7087

@@ -142,4 +159,14 @@ public function delete($account, $repo, $id)
142159
sprintf('repositories/%s/%s/branch-restrictions/%d', $account, $repo, $id)
143160
);
144161
}
162+
163+
/**
164+
* Add allowed permission types
165+
*
166+
* @param array $restrictions
167+
*/
168+
public function addAllowedRestrictionType($restrictions = array())
169+
{
170+
$this->allowedRestrictionTypes = array_merge($this->allowedRestrictionTypes, $restrictions);
171+
}
145172
}

0 commit comments

Comments
 (0)