Overriding issues
Permalink 5 2 Browser Info EnvironmentI have some examples....
Override \Concrete\Core\User\User
1. Created a new (duplicate) file User.php in /application/src/Concrete/User
2. Then added to bootstrap/autoload.php the following code:
$classLoader = new \Symfony\Component\ClassLoader\Psr4ClassLoader(); $classLoader->addPrefix('Application\\Concrete', DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/Concrete'); $classLoader->register();
3. Then added to bootstrap/app.php the following code (based on examples shown in this file):
$app->bind('\Concrete\Core\User\User', function($app, $params) { return new \Application\Concrete\User\User(); });
In my opinion this should overwrite any call to \Concrete\Core\User\User or \User, but that's not working....
So let's try something else....
In /application/config/app.php, I added a new alias.
Like this (copied from the /concrete/config/app.php):
return [ aliases => [ 'Users' => '\Application\Concrete\User\User' '\Concrete\Core\User\User' => '\Application\Concrete\User\User' ] ] [code] In this case I thought that a call to \User will call my override, but again no joy. The second line is also not working, although I didn't think it would.... So an "easy" override for a Src file isn't so easy... Performance-wise I know that reading all dirs isn't the best approche, but why not a config file-like solution like you already have for some? And why, if you give the example in the application/bootstrap/app.php file you give an example that isn't working.... This way, by making it impossible to override, there is a big problem with updating or upgrading. Is there another way to override my example? Then another override thingy.....
Here I expect to overwrite any "$this->requireAsset('javascript', 'community-store');" to call my new javascript file. But it's not!
Again! This is an example from the file itself.
Overriding Elements and SinglePages is still works great, so thats good.
So I guess my bug (or request) is:
Can we make overriding of Core files easier? It's ok if its a config or an alias or something like that. But please make it possible on any level!
Every file should be overridable in an easy way. For me that is one of the great things of Concrete5!
Status: New