Slim: Only bind route callable state if DIC is specified

Created on 19 Nov 2016  路  9Comments  路  Source: slimphp/Slim

Otherwise let $this inside of closure fail.

Slim 4

Most helpful comment

We're doing away with Pimple. And if we're going to support third-party containers, they should adhere to container-interop. And if that means only supporting $this->get('...') inside of route callable closures, that's the way I would go.

All 9 comments

I must have missed this...

Can I get some clarification? :)

The container is becoming 100% optional in v4. Currently in v3, there is always a container, and we bind all route callable closures' state to the container (i.e. $this inside of a route callable closure is the container). In v4, if no container is provided, we cannot bind the closure state.

Would it make more sense to completely remove that? Callables would be bound to a container whose API is undefined.

I'm assuming that we'll continue to require that the container is must conform to the container-interop interface.

@akrabat so $this->service should be removed in favor of $this->get('...') only?

@akrabat so $this->service should be removed in favor of $this->get('...') only?

Now that's a good question that we'll have to think about.

We're doing away with Pimple. And if we're going to support third-party containers, they should adhere to container-interop. And if that means only supporting $this->get('...') inside of route callable closures, that's the way I would go.

Related to #2100

Was this page helpful?
0 / 5 - 0 ratings