verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

Fixed loading remote sources every time the service is initiated/called #36

Closed bertoost closed 4 years ago

bertoost commented 4 years ago

Fixes https://github.com/verbb/icon-picker/issues/34 And makes loading custom remote sources much faster

bertoost commented 4 years ago

FYI; Because for every icon in a set this line is executed; https://github.com/verbb/icon-picker/blob/craft-3/src/models/IconModel.php#L115 And after that; https://github.com/verbb/icon-picker/blob/craft-3/src/models/IconModel.php#L91 The IconSources service is initiated a lot of times. Luckily PHP remembers the object instance from memory, but when not keeping the already-loaded sources in the object, it will load over and over again. That's why storing it in a local variable is working.

engram-design commented 4 years ago

Great thinking here, and thanks for the PR!