Caffeinated\Modules\Repositories\LocalRepository::optimize PHP Method

optimize() public method

Update cached repository of module information.
public optimize ( ) : boolean
return boolean
    public function optimize()
    {
        $cachePath = $this->getCachePath();
        $cache = $this->getCache();
        $basenames = $this->getAllBasenames();
        $modules = collect();
        $basenames->each(function ($module, $key) use($modules, $cache) {
            $basename = collect(['basename' => $module]);
            $temp = $basename->merge(collect($cache->get($module)));
            $manifest = $temp->merge(collect($this->getManifest($module)));
            $modules->put($module, $manifest);
        });
        $modules->each(function ($module) {
            $module->put('id', crc32($module->get('slug')));
            if (!$module->has('enabled')) {
                $module->put('enabled', config('modules.enabled', true));
            }
            if (!$module->has('order')) {
                $module->put('order', 9001);
            }
            return $module;
        });
        $content = json_encode($modules->all(), JSON_PRETTY_PRINT);
        return $this->files->put($cachePath, $content);
    }