OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce How can I override a moethod in symfony component

This topic contains 6 replies, has 2 voices, and was last updated by  Andrey Yatsenko 6 years, 4 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #32583

    Ayman Hussein
    Participant

    I need to override locate method in vendor\symfony\symfony\src\Symfony\Component\Config\FileLocator.php class,

    How can i override this method in my bundle?

    Thanks


    arh922

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #32584

    Andrey Yatsenko
    Moderator

    Hi arh922,
    It’s not possible to override class method in php without hacks, but if you use the class as a service,

    you can just override class parameter at the container, for example add in services.yml:

    or you can decorate the service file_locator, check out this tutorial
    https://symfony.com/doc/2.8/service_container/service_decoration.html

    #32585

    Ayman Hussein
    Participant

    What is the file locator service name (Id) so i can override old class with new class?


    arh922

    #32586

    Andrey Yatsenko
    Moderator

    What is the file locator service name (Id) so i can override old class with new class?

    file_locator

    #32587

    Ayman Hussein
    Participant

    Does it need any parameter because I got the following error when override the service:

    Yml:

    Error:

    [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
    Can’t parse configuration. oro_cache_invalidate.frontend_options.template: Unable to find template “OroCacheBundle:Action:invalidate.html.twig”

    where can I find the origin service (yml file)? i search it out in all vendors but did not find it?


    arh922

    #32588

    Andrey Yatsenko
    Moderator

    /vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml, line 58, if you have different symfony version it can be in different line.

    Service definition is for “Symfony\Component\HttpKernel\Config\FileLocator” as “Symfony\Component\Config\FileLocator” not used directly.

    #32589

    Andrey Yatsenko
    Moderator

    Probably you should configure Symfony plugin in your IDE, we use PhpStorm at Oro, it’s very useful, as it highlight services for classes to quick navigation it were easy to find definition for me.

Viewing 6 replies - 1 through 6 (of 6 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

Back to top