Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file uploads support #1097

Merged
merged 2 commits into from
Sep 15, 2015
Merged

Add file uploads support #1097

merged 2 commits into from
Sep 15, 2015

Conversation

GuilhemN
Copy link
Member

This PR add file uploads support. (#793)
Currently, there are no requirements supported.

<?php

use FOS\RestBundle\Controller\Annotations\QueryParam;

/**
 * @FileParam(
 *   name="foo_file",
 *   key=null,
 *   incompatibles={},
 *   default=null,
 *   description="",
 *   strict=false,
 *   nullable=false,
 *   requirements={},
 *   image=false
 * )
 */

I moved the scalar constraints (notBlank, array) in another abstract class ScalarParam, I don't know if this is a really good name ...

The requirements parameter of @FileParam must be a constraint or an array that can contain all the fields of http://symfony.com/doc/current/reference/constraints/File.html or http://symfony.com/doc/current/reference/constraints/Image.html. It depends of the image parameter.

@lsmith77 lsmith77 added this to the 2.0 milestone Aug 29, 2015
@lsmith77
Copy link
Member

please rebase on master

@lsmith77
Copy link
Member

can you also add something to the docs?

@GuilhemN
Copy link
Member Author

I add some examples in the ParamFetcher documentation.

}

return $default;
Copy link
Member

Choose a reason for hiding this comment

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

and what happens now in this case .. we return null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Look the code, it's the same thing, I just removed an useless call to simplify.

@GuilhemN GuilhemN closed this Sep 1, 2015
@GuilhemN GuilhemN reopened this Sep 1, 2015
@lsmith77
Copy link
Member

needs a rebase

@GuilhemN
Copy link
Member Author

done.

@lsmith77
Copy link
Member

and another one :-/

@GuilhemN
Copy link
Member Author

done :-)

{
return $this->name;
}
/** {@inheritdoc} */
Copy link
Member

Choose a reason for hiding this comment

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

please add an empty line between methods

@lsmith77
Copy link
Member

actually .. I just activated styleci ..

#1115

@GuilhemN
Copy link
Member Author

I'll wait that you merge #1115 to see if there is some standard mistakes related to this PR.

@lsmith77
Copy link
Member

indeed .. needs another rebase :-/

form now on it should then also show you any CS violations automatically

@GuilhemN
Copy link
Member Author

Yes, I fixed them.

@lsmith77
Copy link
Member

awesome!

lsmith77 added a commit that referenced this pull request Sep 15, 2015
@lsmith77 lsmith77 merged commit 32bf432 into FriendsOfSymfony:master Sep 15, 2015
@GuilhemN GuilhemN deleted the ISSUE_793 branch September 15, 2015 10:55
@ReservedDeveloper
Copy link

In attempting to test this out (specifically using the example with @QueryParam(name="page", requirements="\d+", default="1", description="Page of the overview."), I ran in to an issue with the annotations parser. Specifically Doctrine/Common/Annotations/DocParser.php:786:

} elseif (gettype($values[$property]) !== $type['type'] && !$values[$property] instanceof $type['type']) {

Note the gettype call when $values[$property] is a string will return string type, when only scalar|array|Constraint|null are supported.

Since string !== (scalar|array|Constraint|null)... 💥

The specific error I'm receiving is:

  [Doctrine\Common\Annotations\AnnotationException]                                                                                                                                                     
  [Type Error] Attribute "requirements" of @FOSRest\QueryParam declared on method AppBundle\Controller\XyzController::indexAction() expects a(n) scalar|array|Constraint|null, but got string.

I didn't see any changes to the dependencies that would suggest a different version of the Doctrine library. Am I missing something here?

@GuilhemN
Copy link
Member Author

Hum so it seems that the doctrine annotations reader doesn't support the scalar type... If you have the time, can you change this doc and add a test for this case please?

Instead I'll fix this later, probably tomorrow.

@xabbuh
Copy link
Member

xabbuh commented Feb 4, 2016

@Ener-Getick @lsmith77 For some reason it seems that this change is not in the 1.8 branch. Do you now if that was intended?

@GuilhemN
Copy link
Member Author

GuilhemN commented Feb 4, 2016

@xabbuh Yeah it needs a lot of changes to be backported this is why I didn't do it.

@xabbuh
Copy link
Member

xabbuh commented Feb 4, 2016

@Ener-Getick Alright, thanks for the confirmation.

@GuilhemN
Copy link
Member Author

GuilhemN commented Feb 4, 2016

But at least we can backport the map option in Param. It should be pretty simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants