Parse files on plugin init I have a scenario in a plugin where I need to create / check data obtained by reading files. This currently happens on plugin init but isn't completed in time to make use of by other functions.

My plugin needs to parse a few SVG's and stylesheets and create data accordingly. I'am currently checking against a last modified date to avoid extraneous work.

The SVG's and stylesheets are from the website public directory and can be modified by the developer at any time and I would like to avoid any manual interaction within the CP when it comes to parsing these files.

What would be an acceptable way to ensure this data is generated before my plugin attempts to use it?
After some reordering of my logic and moving code to the init method of the plugins service I have been able to solve this problem with the below.

class SvgIconsService extends BaseApplicationComponent
{
    public function init()
    {
        $this-&gt;createResources(); // Method call to perform file operations

        parent::init();
    }

    private function createResources()
    {
        $folders = IOHelper::getFolderContents(craft()-&gt;config-&gt;get('iconSetsPath', 'svgicons'), false);

        if (is_array($folders)) {
            foreach ($folders as $idx =&gt; $f)
            {
                $iconSets[IOHelper::getFolderName($f) . IOHelper::getFolderName($f, false)] = IOHelper::getFolderName($f, false);

                // Create sprite sheet resources from Stylesheet
                $stylesheets = IOHelper::getFolderContents($f, false, '\-sprites.css');

                if(!empty($stylesheets)) {
                    foreach ($stylesheets as $stylesheetIdx =&gt; $stylesheet) {
                        craft()-&gt;templates-&gt;includeCss(IOHelper::getFileContents($stylesheet));
                        $this-&gt;getSpritesFromStylesheet($stylesheet);
                    }
                }

                // Create sprite sheet resources from SVG
                $svgs = IOHelper::getFolderContents($f, false, '\-sprites.svg');

                if(!empty($svgs)) {
                    foreach ($svgs as $svgIdx =&gt; $svg) {
                        $this-&gt;getSpritesFromSvg($svg);
                    }
                }
            }
        }
    }
}


I was originally calling craft()-&gt;svgIcons-&gt;createResources(); from the plugin init method.