Is there a way to override bundle DI extension file in Symfony? - symfony

I'm having a hard time figuring out how to override the DI extension file in Sf2.
The reason I want to override this file is that I'm using a 3rd party bundle where they define certain services, check for certain params in this file. However, since I want to customize these settings and store them in a different way I need a way to either override or skip the loading of this file.
I have searched high

Related

What is the best way to override a function in an aikau widget in alfresco?

I am using Alfresco 6.2 Enterprise version. I have a requirement which calls for a couple of modifications in https://dev.alfresco.com/resource/docs/aikau-jsdoc/AlfSearchList.js_.html module.
What is the best approach to override the onScopeSelection function?
Is there a way I can modify searchPayload to include a new attribute?
I have gone through Alfresco documentation and couldn not figure out what's the best way to override an existing aikau.
The best option to override a function in Aikau is typically to extend the widget module in question and use module "class hierarchy" to override the function inherited from the AlfSearchList. The OOTBee Support Tools project has an example of a module extending AlfList and overriding its onDataLoadSuccess function. Once you have your own custom module, you can use a Surf Extension Module to customise the JSON model of the faceted search page to change the name of the module used for the search list to yours.
Unfortunately there is no other way to modify the searchPayload other than overriding the loadData function as well. And then the added attribute would not do anything unless you also override the SearchService's onSearchRequest function and used your custom service instead of the default by again modifying the JSON model of the page.

Correct way to override default template in Sonata

I'm a bit confused as I've seen a few varying methods posted online.
I have a bundle created with easyextends in src/Application/Sonata/SonataMediaBundle, which extends the SonataMediaBundle in the vendors.
The default template displays
This is the gallery index template. Feel free to override it.
This file can be found in SonataMediaBundle:Gallery:index.html.twig.
so I've added src/Application/Sonata/SonataMediaBundle/Resources/views/Gallery/index.html.twig in my bundle
and this works and overrides, so why all these various other ways like How to override Sonata Media Bundle templates?
You are using the correct way. To quote from symfonys How to Override Templates from Third-Party Bundles
To override the bundle template, just copy index.html.twig template from the bundle to app/Resources/AcmeBlogBundle/views/Blog/index.html.twig (the app/Resources/AcmeBlogBundle directory won't exist, so you'll need to create it). You're now free to customize the template.
And for more detailed/ complex overriding behaviour have a look at How to Use Bundle Inheritance to Override Parts of a Bundle
I wouldn't worry to much about other solutions unless you are not able to get the results you require using this method but I cant think of one.

Symfony: Overriding/Adding routes from inherited bundle

Suppose i have a few sites that share around 80% of their functionality, including things like routing strategy, templates,etc.
I'd like to use the same codebase for all them, and have a "DefaultSiteBundle", and several "SiteABundle","SiteBBundle" overriding or adding functionality to the DefaultSiteBundle using bundle inheritance.
This means, the DefaultSiteBundle should always be loaded, and, depending on the domain name, load SiteABundle or SiteBBundle conditionally.
My problem is, how do i manage routes, without adding all SiteBundles to app/config/routing.yml?
The way i've solved it, in the end, was using a custom router, based on the Advanced loader explained in the symfony docs.The router loads and merges routes from both bundles.
It's also important to create separate caches for each site (overriding "getCacheDir" in AppKernel so it returns a different path for each domain)

Override drupal's core include files

Specifically common.inc. I need to modify format_date, but I want to do it safely.
You can only override a few specific files (like session.inc or cache.inc), it is not possible to override common.inc.
However, you don't need to. See my answer to your other question: Drupal not using custom time format type

ASP.Net MVC: Centralizing CSS and JS dependencies

I'm using jQuery plugins in an ASP.Net MVC site.
I've often to include CSS and JS files as required by the plugins I use in every page. So I want to centralize all those dependencies in a single place in my app. thus if a dependency for a given plug-in is changed or updated, I'll only have to modify a single place in my app.
I've thought in two possible solutions:
Extend the HTMLHelper with a partial method
like GetPlugin("jqgrid"); that
will print out all the script and
style tags needed.
Create a partial view for each
pluginlike jqGridDependencies.ascx
that will contain the script and
style tags needed.
Do you have any other idea? what do you think of both proposals?
Could http://combres.codeplex.com/ provide you with a framework for this.
My only personal objection to this method is that each individual pages will have a unique JavaScript/CSS file where as if you combined and compressed everything into one and simply used classes and events to trigger the JavaScript enhancements as and when needed your site would run a lot faster.

Resources