Create Custom Sprunje [SOLVED]


#1

Trying to add a custom spunje to a custom sprinkle without success. Getting “UserFrosting \ Sprinkle \ Core \ Util \ BadClassNameException”

I get no error from simply having a custom sprunje in the Sprunje folder …

  • sprinkles/MySprinkle/src/Sprunje/MyDataThing.php

However, referencing it from the sprinkles/MySprinkle/src/ServicesProvider/ServicesProvider.php class triggers the runtime error.

The tutorial says I only need to create the sprunje file (extends Sprunje) … but clearly I have to add a declaration somewhere else too?

NOTE: Maybe my mistake is in thinking I can map mydatathing_sprunje to the MyDataThingSprunje in the ServicesProvider.php class. I’m looking through the core code to make better sense of it — would help if there was a recipe that added a custom sprunje.


#2

Possible solution to my specific issue: Looks like the sprunje php file has to have same name as the class?

Once I renamed my file to MyDataThingSprunje.php (same name as the class) the error went away.


#3

I don’t understand why you want (need) to reference your Sprunje in a ServicesProvider ?


#4

Hi @Malou, I’m just trying to create a data service that I can call from an ajax process. Got it working and am now trying to figure out how to extract ad-hoc URL arguments from inside my twig file. Will probably post that question separately soon.


#5

You can also ask your questions on the Chat :wink: