Blesta Addons Posted May 21, 2019 Report Posted May 21, 2019 in the blesta logs we found a lot of this notice message, is not a big deal , but it fill the logs and make them big sizer. E_NOTICE: Use of undefined constant COREDIR - assumed 'COREDIR' {"code":8,"message":"Use of undefined constant COREDIR - assumed 'COREDIR'","file":"/home/hhhhhh/public_html/core/Automation/Tasks/Common/AbstractTask.php","line":116} and still this old notice when editing invoice logged E_WARNING: sprintf(): Too few arguments {"code":2,"message":"sprintf(): Too few arguments","file":"/home/hhhhhh/public_html/vendors/minphp/language/src/Language.php","line":125}
Tyson Posted May 23, 2019 Report Posted May 23, 2019 Do you have COREDIR defined in /core/ServiceProviders/MinphpBridge.php? It sounds like it's missing.
Blesta Addons Posted May 23, 2019 Author Report Posted May 23, 2019 1 hour ago, Tyson said: Do you have COREDIR defined in /core/ServiceProviders/MinphpBridge.php? It sounds like it's missing. Yes , i have checked, it exist, but i have found that we didn't add it in a custom plugin that override some container functions.
Tyson Posted May 23, 2019 Report Posted May 23, 2019 I recommend you don't override containers, but extend them instead.
Blesta Addons Posted May 24, 2019 Author Report Posted May 24, 2019 12 hours ago, Tyson said: I recommend you don't override containers, but extend them instead. in this particular case we need to override . as we need to set a new value of WEBDIR .
Tyson Posted May 24, 2019 Report Posted May 24, 2019 I'm curious to know what the reason is behind overriding WEBDIR? Adding a new constant for your case would not suffice? Also, you can override WEBDIR by extending the container.
Blesta Addons Posted May 25, 2019 Author Report Posted May 25, 2019 23 hours ago, Tyson said: I'm curious to know what the reason is behind overriding WEBDIR? Adding a new constant for your case would not suffice? Also, you can override WEBDIR by extending the container. we have some seo practice in our website, nd we need this to do it in our multilanguage plugin that add instance for every language in blesta like /fr/ or /ar/ ...ect how we can override only WEBDIR by extending the container?
Tyson Posted May 28, 2019 Report Posted May 28, 2019 Interesting. You can extend it by calling the container's ::extend method, e.g.: $this->container->extend( 'minphp.constants', function ($instance, $c) { return array_merge($instance, ['WEBDIR' => $instance['WEBDIR'] . 'fr/']); } ); There is an example in Blesta v4.6 that does this to override a few of the services for the application.
Blesta Addons Posted May 29, 2019 Author Report Posted May 29, 2019 9 hours ago, Tyson said: Interesting. You can extend it by calling the container's ::extend method, e.g.: $this->container->extend( 'minphp.constants', function ($instance, $c) { return array_merge($instance, ['WEBDIR' => $instance['WEBDIR'] . 'fr/']); } ); There is an example in Blesta v4.6 that does this to override a few of the services for the application. thank tyson, this only for the upcoming blesta 4.6 ? i will test it later, this will allow us to override it globally in blesta. so anywhere to call $this->base_uri will get the overridden value and not the default one ? so from the preAction event we can dot it without changing or modifying any blesta files ?
Tyson Posted May 29, 2019 Report Posted May 29, 2019 Extending the container has been available since v4.0. We just happen to use it for v4.6. I suspect you can extend the container from wherever you'd like (although I have not tested that), but it is better to extend it as early as possible in execution or it may be possible for some places to have already used the value before you override it.
Recommended Posts