Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8753755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:29:09+00:00 2026-06-13T13:29:09+00:00

Im trying to call a method within a service that calls ANOTHER method from

  • 0

Im trying to call a method within a service that calls ANOTHER method from another service.

Current class -> different class/service -> to different class/service

I can successfully call the initial service, but when that service tries calling an additional service i get the error

Fatal error</b>:  Call to a member function get() on a non-object

Heres the code that causes the error:

$edmt = $this->get('endorsements');

And the declaration of the service:

endorsements:
    class:        EndorseMe\EndorsementBundle\Controller\DefaultController
    arguments: [ @router, @service_container]

However, to make things trickier, this service isnt always used as a service. Its also regular symfony controller. It needs to be able to work both ways

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:29:10+00:00Added an answer on June 13, 2026 at 1:29 pm

    You should be passing your second service to your first service as a parameter:

    endorsements:
        class:     EndorseMe\EndorsementBundle\Controller\DefaultController
        arguments: [ @router, @service_container, @your_second_service ]
    

    Then in your first service:

    protected $injectedService;
    
    public function __construct(SecondServiceClass $injectedService)
    {
        $this->injectedService = $injectedService;
    }
    

    After that you should be able to use the injected service by calling $this->injectedService

    Take a look at the Referencing Services chapter in the documentation.

    EDIT: I don’t think it’s possible to use the same class both as Service and Controller. I suggest to define Controller as Service instead. In the end you would have your second service injected in your first service, and your first service injected in your controller service (three services total).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call a method from another class with a simple button in
I'm trying to call a @Cacheable method from within the same class: @Cacheable(value =
Im trying to call a method that will add or subtract 1 from a
I'm trying to call a boolean method in another class and Eclipse is reporting
I'm trying to make a call to a remote WCF service from within an
I'm trying to create a C# class that can call the same methods on
I'm trying to call a method of another class but this causes my app
I'm trying to call a method on a grails service from a controller, but
In the below method I'm trying to call a fragments method from within an
I'm trying to call an instance method a() from within a jQuery ajax call.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.