Closed sweetappleuk closed 2 years ago
@sweetappleuk does it still error if you change:
if (class_exists(\Magento\Framework\Component\ComponentRegistrar::class)) {
to:
if (class_exists('Magento\Framework\Component\ComponentRegistrar')) {
?
Compiles when changed as suggested.
Could I ask what is the benefit to using the if(class_exists ) statement? If there 'is a problem with resolving \Magento\Framework\Component\ComponentRegistrar is it not better for there to be an explicit error thrown during s:d:c than for the module to fail to register "silently"?
Yours
T: 01380 830224 M: 0777 6075050 * E: @.*** W: http://www.sweet-apple.co.uk
Skype: ceesweet Messages: @.*** Google: https://g.page/sweet-apple-co-uk
Happy with my work? Leave a review for us: https://g.page/r/CauEn3UiSskLEAg/review
On 15 Aug 2022, at 16:58, David Windell @.***> wrote:
@sweetappleuk https://github.com/sweetappleuk does it still error if you change:
if (class_exists(\Magento\Framework\Component\ComponentRegistrar::class)) {
to:
if (class_exists('Magento\Framework\Component\ComponentRegistrar')) {
?
— Reply to this email directly, view it on GitHub https://github.com/outeredge/magento-structured-data-module/issues/27#issuecomment-1215231359, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF7HJH5NOMIRZIHHPC4NFTVZJSLVANCNFSM56SRZP2Q. You are receiving this because you were mentioned.
Ok great, will fix.
It's purely to allow easy PHPCS tests on this repo without needing to pull down Magento itself as a dev dependency.
On Magento v2.3.7 with the latest v2.3.0 of this module when I run
bin/magento setup:di:compile
I get the following error:
Compilation was started. Area configuration aggregation... 5/8 [=================>----------] 62% 52 secs 356.0 MiB In ClassReader.php line 26:
Class Magento does not exist
This appears to be because of the changes made in module v2.3.0 to registration.php. The standard module registration is now wrapped with a class_exists if statement. Remove the if statement, compilation completes successfully on M2.3.7
Have not tested on M2.4.x so I cannot say if this is a specific issue affect 2.3.x branch.
if (class_exists(\Magento\Framework\Component\ComponentRegistrar::class)) { \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'OuterEdge_StructuredData', DIR ); }