Tagged Questions
0
votes
0answers
23 views
Injecting routing using symfony2 extension class / semantic configuration
How come there isn't (or if there is please point me to it) a repeatable pattern for consistently and safely enabling injection of a third party bundle's routing resource ...
1
vote
0answers
24 views
How do I set default configuration value in Symfony2 correctly?
I've built a service which I'd like to be able to configure from a config file. I've been able to get it working as needed, but when I look at other bundles, don't see the same config setup as I've ...
1
vote
1answer
27 views
How to inject User to symfony controller
I define AuthController as service and want test it. I add setUser method and want that DI inject it's using security context.
Something like that, but right:
$authController = ...
1
vote
1answer
38 views
Using service aliases for dependency injection
In my application I have an SMS service. This service is a simple POPO that takes an instance to a driver to do the actual SMS functionality.
Imagine I have two drivers, mock_driver and ...
0
votes
1answer
21 views
Symfony2 JMSDiExtraBundle child service dependency error
I'm using JMSDiExtraBundle in my Symfony2 project.
Here is my the problem:
Repository.php
abstract class Repository extends DocumentRepository implements ReadOnlyRepositoryInterface {
protected ...
0
votes
2answers
26 views
Symfony2 : How to translate a template in a service
I created a service in wich I inject translator & templating services.
I use it to send mail from controllers
Everything work fine, except that the twig template used to generate the email body ...
0
votes
2answers
35 views
$this object not working properly when used in services in Symfony2
I've working for a while with Symfony and I started to use controllers as services. The problem is that I'm not sure if I get how the Dependency Injection works. If I print $this inside an action it ...
0
votes
1answer
46 views
Symfony2 Service Container - Passing ordinary arguments to service constructor
I have this Paginator class constructor:
class Paginator
{
public function __construct($total_count, $per_page, $current_page)
{
}
}
The Paginator Service is registered in ...
0
votes
1answer
36 views
How to inject variables, arrays or pre-made objects using $this->get() in symfony2
When inside a controller,
$this->get('some_service');
gives me an object after creating/injecting the required services into "some_service".
However, if I had a class that had:
class ...
1
vote
2answers
35 views
How should I configure an object dynamically when using Symfony's DI?
I'm using a YAML configuration to wire my dependencies, and I need to provide some runtime information to get a useful object back. I was going to run a setter method from my code once the object has ...
1
vote
1answer
56 views
I have no access to container in my controller
I am trying to a service in a Symfony Controller
$session = $this->get('session');
But I get the next error:
PHP Fatal error: Call to a member function get() on a non-object
I thought that ...
0
votes
1answer
54 views
most accepted methods to validate an entity in silex framework
I want to validate an entity but do not know the best place to do this. I put validation code in the setter method. What if I choose Symfony\Component\Validator for validation, how can I access the ...
0
votes
3answers
91 views
Setting $this->something in class body, can't use constructor dependency injection
I have a Symfony controller that uses a data_provider service. I can't figure out how to initialise this service.
I tried:
class DefaultController extends Controller {
public ...
1
vote
1answer
27 views
Lazy service drawbacks?
As of Symfony 2.3 lazy service option has become available using ProxyManager. My question is that is there any drawback to this? It seems like it's perfect to init a service only when you need it but ...
0
votes
3answers
205 views
There is no extension able to load the configuration for “my_bundle_name”
I know this post is popular in here, there are a lot of questions about this problem, but nothing helped me to solve my problem. I have to ask this.
I created a bundle named ...