Comments (4)
Could you provide an example usecase for that?
Imho you could override ServiceHandler and create own ServiceCallback, if really needed. https://github.com/apitte/core/blob/master/src/Handler/ServiceHandler.php#L37-L45
from apitte.
This is great. Thanks!!!
from apitte.
Could you describe what you want to achieve? Maybe we could add an system solution.
from apitte.
I'm sending auth key with each request ... middleware is sorting authentication and forwarding user's object to the controller. I would like to inject model and pass some variables from user's object in the constructor...
final class TestController extends BaseApiController {
public function __construct(SomeModel $model)
{
// HOW TO ACCESS REQUEST's attributes here?
// $user = $request->getAttribute('user');
$this->someModel = $model;
$this->someModel->setSomeVar($user->foo); // How can I read user's object here???
}
/**
* @Path("/test")
* @Method({"GET"})
*/
public function list(ApiRequest $request, ApiResponse $response)
{
$user = $request->getAttribute('user'); // here I can get user passed by middleware
// Workaround - I can call setter here - but why to repeat it in every method??? It can be already done in BaseApiController ;)
// $this->someModel->setSomeVar($user->foo);
$data = $this->someModel->getData(); // this should return data based on "someVar"
return $response->withEntity(ArrayEntity::from($data));
}
}
Hope, it describes what I want to achieve.
Regards,
Martin
from apitte.
Related Issues (20)
- Refinement of the composer dependencies HOT 1
- PHP 8 annotations not supported HOT 9
- Simple response decoration HOT 1
- Method signature instead of RequestParameters HOT 1
- Returns 500 when creating an entity HOT 1
- Custom parameter mapping types HOT 5
- Dispatcher / transformer supporting SerializerInterface out of the box HOT 5
- RequestParameter datetime validation HOT 2
- FileResponseAdjuster should implement just PSR-7 response
- TryCatchMiddleware is redundant because of error handling in ApiMiddleware HOT 4
- Feedback on [email protected] HOT 8
- [Deprecated] Mapping AbstractEntity getIterator method return type
- OpenApi schema type issue: integer vs. int (validation problem) HOT 2
- OpenApi (OAS3) datetime -> date-time mapping type HOT 1
- Fatal Error: During inheritance of IteratorAggregate HOT 2
- Unlock `doctrine/annotations`
- OpenApi / responses / links
- New release v0.11.0 HOT 1
- No matched route by given URL HOT 10
- `x-codeSamples` is omitted when present in OpenAPI annotation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apitte.