public function testGetConfig() { $this->repository->config('assets'); $this->repository->config('modules'); $this->repository->config('migration'); $this->repository->getAssetsPath(); }
/** * Execute the console command. * * @return mixed */ public function handle(\Pingpong\Modules\Repository $modules) { $baseUrl = str_replace(public_path(), '', $modules->getAssetsPath()); $config = ['baseUrl' => rtrim($baseUrl, '/') . '/', 'shim' => [], 'paths' => [], 'urlArgs' => time()]; $dir = public_path('backend'); if (!is_dir($dir)) { mkdir($dir); } /* @var Module $module */ foreach ($modules->enabled() as $module) { $path = $module->getExtraPath('Config/backend.php'); if (file_exists($path)) { $value = (require $path); if (is_array($value) && array_key_exists('requirejs', $value) && is_array($value['requirejs'])) { foreach ($value['requirejs'] as $m => $c) { if (is_string($c)) { $config['paths'][$m] = $module->getLowerName() . '/' . ltrim($c, '/'); } elseif (is_array($c)) { if (array_key_exists('path', $c)) { $config['paths'][$m] = $module->getLowerName() . '/' . ltrim($c['path'], '/'); } if (array_key_exists('deps', $c)) { $config['shim'][$m] = ['deps' => (array) $c['deps']]; } } } } } } $config = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); file_put_contents(public_path('backend/config.js'), "require.config({$config});"); }
/** * Get module assets path. * * @return string * @static */ public static function getAssetsPath() { return \Pingpong\Modules\Repository::getAssetsPath(); }