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

getRegisteredIconSources() curls full URLs instead of local file #16

Closed gbowne-quickbase closed 4 years ago

gbowne-quickbase commented 4 years ago

Description

The call to getRegisteredIconSources() will make 5 repeated calls to curl the font-awesome.json file out of the cpresources files and uses a fully qualified URL to do this, which is working fine on our dev machines, but in hosted and CI/CD environments, the machine may not allow it to curl itself using an outside name.

This was causing our install to fail completely in our AWS-hosted CI/CD servers, until we turned the icon-picker plugin off.

Could the implementation for getting the font-awesome.json file be changed from

        $icons = Craft::$app->getAssetManager()->getPublishedUrl('@verbb/iconpicker/resources/dist', false, 'json/font-awesome.json');

to

        $icons = Craft::$app->getAssetManager()->getPublishedPath('@verbb/iconpicker/resources/dist', false) . 'json/font-awesome.json';

getPublishedUrl changed to getPublishedPath and then avoid the Guzzle Curl to change

 $icons = Json::decode(IconPickerHelper::getFileContents($icons));

to

        $icons = Json::decode(file_get_contents($icons));

Additional info

I've put this into a pull request here: https://github.com/verbb/icon-picker/pull/17

engram-design commented 4 years ago

Thanks for the PR and merged in 1.0.8