Skip to content

Conversation

woodylan
Copy link
Contributor

add params id fork

@woodylan
Copy link
Contributor Author

I want to use namespace in fork project api ,so I added params in it。

@@ -498,9 +498,9 @@ public function removeLabel($project_id, $name)
* @param int $project_id
* @return mixed
*/
public function fork($project_id)
public function fork($project_id, array $params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options parameter should be optional

{
return $this->post('projects/'.$this->encodePath($project_id).'/fork');
return $this->post('projects/'.$this->encodePath($project_id).'/fork', $params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add $params validation using OptionResolver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to use;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that OK?

@woodylan
Copy link
Contributor Author

So,can you merge my pull requests?

Copy link
Contributor Author

@woodylan woodylan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add params in fork action function.

{
return $this->post('projects/'.$this->encodePath($project_id).'/fork');
return $this->post('projects/'.$this->encodePath($project_id).'/fork', $params);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that OK?

{
return $this->post('projects/'.$this->encodePath($project_id).'/fork');
return $this->post($this->getProjectPath($project_id, 'fork'), $params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use the OptionResolver to add input data validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

use the OptionResolver
@woodylan
Copy link
Contributor Author

woodylan commented Nov 2, 2017

I have finished it.

* @return mixed
*/
public function fork($project_id)
public function fork($project_id, array $params = array())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use $parameters for consistency with other methods in this library?

{
return $this->post('projects/'.$this->encodePath($project_id).'/fork');
$resolver = $this->createOptionsResolver();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use $this->createOptionsResolver() here as this methods returns an OptionsResolver preconfigured for pagination. Here a new OptionsResolver() will do the job.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you missed this one ;)

@woodylan
Copy link
Contributor Author

sorry,I didn't find it。
Can you tell me where it is?

@fbourigault
Copy link
Contributor

@woodylan
Copy link
Contributor Author

@fbourigault
Copy link
Contributor

The hooks method is about fetching a collection of existing hooks, so pagination is enabled and $this->createOptionsResolver can be used here as it come with page and per_page defaults.
The fork is an action to fork the project into an other namespace, thus you can't use the $this->createOptionsResolver() because it would add the page and per_page options which are not valid in this case. You have to do it like in https://github.com/dylangl/php-gitlab-api/blob/4693d29f03497917c154930d1f7291f23a9b5259/lib/Gitlab/Api/RepositoryFiles.php#L53.

use `$resolver = new OptionsResolver();`
@fbourigault
Copy link
Contributor

Thank you!

@fbourigault fbourigault merged commit 35ecf9b into GitLabPHP:master Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants