Override a Sprunje?


Hi, I wanted to make some changes to the Sprunje that handles the user table in order to change the sortable items. (I want to have first_name and last_name in different columns and sort by them and not by the whole name and/or username)

I thought about ovverriding it, is there a way to override that Sprunje?

I tried to

  1. make MyUserSprunje copying UserSprunje and making the changes I wanted

  2. then made a new controller MyUserController that extends UserController with a new getList method, changing this line
    $sprunje = $classMapper->createInstance('user_sprunje', $classMapper, $params);
    $sprunje = $classMapper->createInstance('my_user_sprunje', $classMapper, $params);

  3. and then mapped the new class inside the ServicesProvider
    $container->extend('classMapper', function ($classMapper, $c) { $classMapper->setClassMapping('my_user_sprunje', 'UserFrosting\Sprinkle\Site\Sprunje\MyUserSprunje'); return $classMapper; });

However the default UserSprunje is still the one in charge when I visualize the table.
I know that MyUserSprunje works because it does if I place it in the Admin Sprinkle, as you may guess I do not want to make changes to the 3 base Sprinkles.

I’m new to UF and to web development so I’m not sure this is the right approach. If anyone could give some hints I’d be very grateful.


Should just be a matter of removing my_ from where you add it to the class mapper so that you replace the existing definition.

As for why just extending didn’t work, it’s down to the router pointing to UserController specifically (won’t resolve to your version). You shouldn’t need this if just replacing the sprunje with the class mapper, so long as the same key is used in the class mapper (user_sprunje in this case).


Yes, it was just that. Thanks a lot!