Comments (20)
Comment by @tristanlins
Saturday Nov 01, 2014 at 13:27 GMT
if the
FrameworkBundle
is added to the autoload.json
You did something wrong, if you add "system related mandatory" bundles to your autoload.json
.
But this can be solved simply, just check if the autoloaded bundle class is already registered to the kernel.
https://github.com/contao/module-core/blob/feature/symfony2/src/HttpKernel/ContaoKernel.php#L112
protected function generateBundlesMap(array $hardcodedBundles)
{
$hardcodedBundleClasses = array_map(
function(BundleInterface $bundle) { return get_class($bundle); },
$hardcodedBundles
);
$autoloader = new BundleAutoloader($this->getRootDir(), $this->getEnvironment());
$bundlesMap = $autoloader->load();
$bundlesMap = array_filter(
$bundlesMap,
function (Config $bundleMap) use ($hardcodedBundleClasses) {
return !in_array($bundleMap->getClass(), $hardcodedBundleClasses);
}
);
return $bundlesMap;
}
I have made the proposal to support a src/autoload.json
for local / project specific autoload configuration on our meeting. The conclusion was that everyone can manipulate the AppKernel
and write local bundles directly into the kernel. If we propose to not put bundles directly into the AppKernel
we need to provide a local autoload.json
.
BTW: what happen when two bundles define the same autoload bundle in their autoload.json
???
from core-bundle.
Comment by @leofeyer
Saturday Nov 01, 2014 at 20:20 GMT
I am with @tristanlins on this.
BTW: what happen when two bundles define the same autoload bundle in their
autoload.json
???
We should definitely test this and apply array_unique
if necessary.
from core-bundle.
Comment by @aschempp
Sunday Nov 02, 2014 at 07:36 GMT
Multiple requirements with the same name should not be a problem, because we use array keys for the bundle names.
To me, the FrameworkBundle
is a dependency of the ContaoCoreBundle
. I agree we don't need a src/autoload.json
, because a developer can add his bundle in AppKernel
if there is a custom one. But then he also knows about the dependencies and wether they are already loaded. But an extension developer does not know if you removed FrameworkBundle
from the AppKernel
.
I can't see any advantage of including it in the kernel, I can only see potential issues.
from core-bundle.
Comment by @leofeyer
Wednesday Nov 05, 2014 at 09:26 GMT
To me, the
FrameworkBundle
is a dependency of theContaoCoreBundle
.
No, I don't agree. The FrameworkBundle
is required to run the application (just like the SensioFrameworkBundle
etc.). And any application related bundle should be hardcoded in the AppKernel
.
This also applies to any bundle that we are shipping pre-configured in the config.yml
file, e.g. Doctrine and SwiftMailer.
from core-bundle.
Comment by @aschempp
Wednesday Nov 05, 2014 at 09:31 GMT
If you follow that logic, it would mean the CoreBundle
is also a requirement to run the application... but this can't be included, because the autoloader would choke (with the same issue as I described).
Also, if we add ORM later, would that mean we need to add it to the AppKernel
because it will now be an application requirement?
from core-bundle.
Comment by @leofeyer
Wednesday Nov 05, 2014 at 09:33 GMT
Probably. We need to discuss this.
from core-bundle.
Comment by @tristanlins
Wednesday Nov 05, 2014 at 09:49 GMT
FrameworkBundle
is a little special, because it provide the distribution setup. Well it's not required to run a distribution, but it provide the basic "framework" to run the distribution.
from core-bundle.
Comment by @leofeyer
Wednesday Nov 05, 2014 at 10:04 GMT
I also tend to think that if the core bundle adds e.g. Doctrine, we should not provide its configuration in the config.yml
file. We would otherwise configure bundles from which we don't know if they are enabled at all (e.g. removing the core bundle would also remove Doctrine if it were a core bundle dependency).
from core-bundle.
Comment by @aschempp
Wednesday Nov 05, 2014 at 10:05 GMT
Do you mean the config.yml
of the bundle or the app folder?
from core-bundle.
Comment by @leofeyer
Wednesday Nov 05, 2014 at 10:06 GMT
Of the app folder (see #30).
from core-bundle.
Comment by @aschempp
Wednesday Nov 05, 2014 at 10:18 GMT
I think so too. Not sure if there are other options than a prepent bundle extension. It would also correctly mean extensions should add an autoload statement on the CoreBundle
, which is correct in my opinion. They should also add the CoreBundle
to their composer.json to make sure the Contao version fits.
from core-bundle.
Comment by @tristanlins
Wednesday Nov 05, 2014 at 11:01 GMT
It is possible to prepent the default connection. You can overwrite or extend it in the app/config/config.yml
.
Here is an example for the doctrine connection:
@CoreBundle\Resources\config\prepend.yml
doctrine:
dbal:
default_connection: default
connections:
default:
driver: "%database_driver%"
host: "%database_host%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
app/config/config.yml
doctrine:
dbal:
connections:
database2:
driver: "%database2_driver%"
host: "%database2_host%"
dbname: "%database2_name%"
user: "%database2_user%"
password: "%database2_password%"
After normalisation, the result would be:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: "%database_driver%"
host: "%database_host%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
database2:
driver: "%database2_driver%"
host: "%database2_host%"
dbname: "%database2_name%"
user: "%database2_user%"
password: "%database2_password%"
from core-bundle.
Comment by @tristanlins
Wednesday Nov 05, 2014 at 11:03 GMT
They should also add the CoreBundle to their composer.json to make sure the Contao version fits.
They must define all dependencies and CoreBundle is a dependency for every contao bundle!
from core-bundle.
Comment by @leofeyer
Wednesday Nov 05, 2014 at 11:08 GMT
Well, as I have said before, I would prefer to hardcode the application dependencies in the AppKernel
and add their default configuration to the app/config/config.yml
file.
What if e.g. five bundles require Doctrine but it is not available application wide? Are all five supposed to create a prepend configuration? Or will they rely on the core bundle? But what if the core bundle removes the Doctrine dependency? It would break the other four bundles.
@aschempp Just as you have said above (but exactly the other way round): I can't see any advantage of not including it in the kernel, I can only see potential issues ;)
from core-bundle.
Comment by @tristanlins
Wednesday Nov 05, 2014 at 11:21 GMT
Personally I prefer to add really basic bundles like database and swiftmailer to the global config. That make it easier to understand for newcomers. And bundle specific options are added to the bundle prepend configuration.
from core-bundle.
Comment by @aschempp
Wednesday Nov 05, 2014 at 11:52 GMT
What if e.g. five bundles require Doctrine but it is not available application wide? Are all five supposed to create a prepend configuration?
There's not really any other solution? If multiple bundles already use ORM now, what do they do?
from core-bundle.
Comment by @leofeyer
Wednesday Nov 05, 2014 at 12:39 GMT
The correct solution is to adjust the bundle autoloader so it does not throw an exception if one of the hardcoded bundles is being re-added by means of autoloading.
from core-bundle.
Comment by @leofeyer
Wednesday Nov 05, 2014 at 14:17 GMT
FIxed in d0900e7.
from core-bundle.
Comment by @tristanlins
Wednesday Nov 05, 2014 at 14:22 GMT
👍
from core-bundle.
Comment by @aschempp
Wednesday Nov 05, 2014 at 14:26 GMT
Looks good, apart from the fact that we are mixing bundle class/file name and $bundle->getName()
everywhere… This won't work if someone will include a legacy Contao module (which would be stupid though).
from core-bundle.
Related Issues (20)
- Unvollständige Navigation nach Update auf Contao 4.7.5 HOT 2
- [meta] Porting of imi-conrun feature which are missing in contao-console HOT 4
- Bug in MetaWizard widget HOT 1
- No thumbnails in backend file manager, with php internal webserver HOT 14
- Add option to disable "Lato Retina" HOT 2
- SQLSTATE[HY000]: General error: 1270 Illegal mix of collations (utf8_general_ci,COERCIBLE), (utf8_unicode_ci,COERCIBLE), (utf8_unicode_ci,COERCIBLE) for operation 'replace' HOT 2
- Insert-Tag {{session::*}} HOT 1
- Adding sitemap path and filename to HTML head (fe_page) HOT 1
- Closed FE Preview leaves preview.php in URL HOT 1
- [PHP Fatal Error] Argument passed to FragmentRegistry::get() must be of the type string, object given HOT 3
- [BUG] BackendAccessVoter fails with fatal error when using `allow_if` security access rules - Might not happen in prod enviornment HOT 1
- "Start open/closed" option for accordions HOT 7
- ContentModule: custom cssID not applied when using ModuleProxy HOT 1
- Back link broken due to "referer" issue in session when DCAs have 3+ levels of ptable/ctables HOT 1
- [4.9.X] - Porting the UserCreateCommand class HOT 2
- Fehlende Sprachen HOT 1
- OptInToken.php Mail-Instanz: Absender aus config.yml wird nicht beachtet HOT 3
- Create SECURITY.md HOT 4
- Isotope 2.8.7 breaks when running the Isotope Orders Module in the backend HOT 1
- Backend DCA filter dropdown/select options overwritten - can't have 2 options with the same label HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core-bundle.