/**
  * Returns an array containing the full path to each dump file.
  * 
  * @return array
  */
 private function dumpFiles()
 {
     $files = [];
     foreach (File::allFiles(Config::dumpPath()) as $dumpFile) {
         $files[] = $dumpFile->getRealpath();
     }
     sort($files);
     return $files;
 }
 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  * @param Router $router
  */
 public function map(Router $router)
 {
     $router->group(['namespace' => $this->namespace], function ($router) {
         $directory = File::allFiles(app_path() . '/Http/Routes');
         foreach ($directory as $file) {
             require_once $file->getPathName();
         }
         require_once app_path() . '/Http/Helpers.php';
     });
 }
示例#3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Start the progress bar
     $bar = $this->helper->barSetup($this->output->createProgressBar(7));
     $bar->start();
     // Common variables
     $vendor = strtolower($this->argument('vendor'));
     $name = strtolower($this->argument('name'));
     $path = getcwd() . '/packages/';
     $fullPath = $path . $vendor . '/' . $name;
     $cVendor = studly_case($vendor);
     $cName = studly_case($name);
     $requirement = '"psr-4": {
         "' . $cVendor . '\\\\' . $cName . '\\\\": "packages/' . $vendor . '/' . $name . '/src",';
     $appConfigLine = 'App\\Providers\\RouteServiceProvider::class,
     ' . $cVendor . '\\' . $cName . '\\' . 'ServiceProvider::class,';
     // Start creating the package
     $this->info('Creating package ' . $vendor . '\\' . $name . '...');
     if (!$this->option('force')) {
         $this->helper->checkExistingPackage($path, $vendor, $name);
     }
     $bar->advance();
     // Create the package directory
     $this->info('Creating packages directory...');
     $this->helper->makeDir($path);
     $bar->advance();
     // Create the vendor directory
     $this->info('Creating vendor...');
     $this->helper->makeDir($path . $vendor);
     $bar->advance();
     // Copying package skeleton
     $this->info('Copying package skeleton...');
     File::copyDirectory(__DIR__ . '/../skeleton', $fullPath);
     foreach (File::allFiles($fullPath) as $file) {
         $search = [':vendor_name', ':VendorName', ':package_name', ':PackageName'];
         $replace = [$vendor, $cVendor, $name, $cName];
         $newfile = substr($file, 0, -5);
         $this->helper->replaceAndSave($file, $search, $replace, $newfile, $deleteOldFile = true);
     }
     $bar->advance();
     // Add it to composer.json
     $this->info('Adding package to composer and app...');
     $this->helper->replaceAndSave(getcwd() . '/composer.json', '"psr-4": {', $requirement);
     //And add it to the providers array in config/app.php
     $this->helper->replaceAndSave(getcwd() . '/config/app.php', 'App\\Providers\\RouteServiceProvider::class,', $appConfigLine);
     $bar->advance();
     // Finished creating the package, end of the progress bar
     $bar->finish();
     $this->info('Package created successfully!');
     $this->output->newLine(2);
     $bar = null;
 }
示例#4
0
 public function handle()
 {
     if (($table = $this->option('table')) === null) {
         $tables = $this->DBHelper->listTables();
         $table = $this->choice('Choose table:', $tables, null);
     }
     $columns = collect($this->DBHelper->listColumns($table));
     $this->transformer->setColumns($columns);
     $namespace = config('thunderclap.namespace');
     $moduleName = str_replace('_', '', title_case($table));
     $containerPath = config('thunderclap.target_dir', base_path('modules'));
     $modulePath = $containerPath . DIRECTORY_SEPARATOR . $moduleName;
     // 1. check existing module
     if (is_dir($modulePath)) {
         $overwrite = $this->confirm("Folder {$modulePath} already exist, do you want to overwrite it?");
         if ($overwrite) {
             File::deleteDirectory($modulePath);
         } else {
             return false;
         }
     }
     // 2. create modules directory
     $this->info('Creating modules directory...');
     $this->packerHelper->makeDir($containerPath);
     $this->packerHelper->makeDir($modulePath);
     // 3. copy module skeleton
     $stubs = __DIR__ . '/../../stubs';
     $this->info('Copying module skeleton into ' . $modulePath);
     File::copyDirectory($stubs, $modulePath);
     $templates = ['module-name' => str_replace('_', '-', $table), 'route-prefix' => config('thunderclap.routes.prefix')];
     // 4. rename file and replace common string
     $search = [':Namespace:', ':module_name:', ':module-name:', ':module name:', ':Module Name:', ':moduleName:', ':ModuleName:', ':FILLABLE:', ':TRANSFORMER_FIELDS:', ':VALIDATION_RULES:', ':LANG_FIELDS:', ':TABLE_HEADERS:', ':TABLE_FIELDS:', ':DETAIL_FIELDS:', ':FORM_CREATE_FIELDS:', ':FORM_EDIT_FIELDS:', ':VIEW_EXTENDS:', ':route-prefix:', ':route-middleware:', ':route-url-prefix:'];
     $replace = [$namespace, snake_case($table), $templates['module-name'], str_replace('_', ' ', strtolower($table)), ucwords(str_replace('_', ' ', $table)), str_replace('_', '', camel_case($table)), str_replace('_', '', title_case($table)), $this->transformer->toFillableFields(), $this->transformer->toTransformerFields(), $this->transformer->toValidationRules(), $this->transformer->toLangFields(), $this->transformer->toTableHeaders(), $this->transformer->toTableFields(), $this->transformer->toDetailFields(), $this->transformer->toFormCreateFields(), $this->transformer->toFormUpdateFields(), config('thunderclap.view.extends'), $templates['route-prefix'], $this->toArrayElement(config('thunderclap.routes.middleware')), $this->getRouteUrlPrefix($templates['route-prefix'], $templates['module-name'])];
     foreach (File::allFiles($modulePath) as $file) {
         if (is_file($file)) {
             $newFile = $deleteOriginal = false;
             if (Str::endsWith($file, '.stub')) {
                 $newFile = Str::substr($file, 0, -5);
                 $deleteOriginal = true;
             }
             $this->packerHelper->replaceAndSave($file, $search, $replace, $newFile, $deleteOriginal);
         }
     }
     $this->warn('Add following service provider to config/app.php ====> ' . $namespace . '\\' . ucwords(str_replace('_', ' ', $table)) . '\\ServiceProvider::class,');
 }
 protected function bootRoutes()
 {
     $config = $this->app['config'];
     if ($config->has('routie.path')) {
         $root = $config->get('routie.path');
         if (File::isDirectory($root)) {
             $path = str_replace('\\', '/', $root);
             $path = '/' . $path;
             $files = File::allFiles($path);
             foreach ($files as $file) {
                 $filename = str_replace('/' . base_path() . '/', null, $file->getPathname());
                 $filename = ucfirst($filename);
                 $filename = explode('.', $filename)[0];
                 $filename = str_replace('/', '\\', $filename);
                 $this->app->make($filename);
             }
         }
     }
 }
 /**
  * Minify files
  *
  */
 private function _minify()
 {
     $this->info("Minifying...");
     //If we don't have directories to scan
     if (empty($this->_directories)) {
         $this->error('No javascript directories to scan');
         return false;
     }
     foreach ($this->_directories as $folder) {
         foreach (File::allFiles($this->_assetsDirectory . '/' . $folder) as $file) {
             $in = $file->getPathname();
             if ($file->getExtension() == 'js' && substr($in, -7) != '.min.js' && substr($in, -8) != '.pack.js') {
                 $out = str_replace('.js', '.min.js', $file->getPathname());
                 shell_exec("uglifyjs " . $in . " -c -o " . $out);
                 $this->line("\t" . $in . " → " . $out);
             }
         }
     }
     return true;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $from = $this->argument('from_locale');
     $to = $this->argument('to_locale');
     $Lari18n = Lari18n::getInstance();
     $data = $Lari18n->retrieveI18nData();
     $languages = $data['languages'];
     $languagesPath = $data['paths']['lang'];
     // check
     if (!in_array($from, $languages)) {
         $this->error('There is no locale [' . $from . ']');
     }
     if (in_array($to, $languages)) {
         $this->error('The [' . $to . '] locale already exist');
     }
     // Create the new language directory
     File::copyDirectory($languagesPath . '/' . $from, $languagesPath . '/' . $to);
     $files = File::allFiles($languagesPath . '/' . $to);
     $Lari18n->reinitialiseFiles($files, $to);
     $this->info('The [' . $to . '] translation directory as been created from [' . $from . '] translations files');
 }
 /**
  * Minify files
  *
  */
 private function _minify()
 {
     $this->info("Minifying...");
     //If we don't have directories to scan
     if (empty($this->_directories)) {
         $this->error('No css directories to scan');
         return false;
     }
     foreach ($this->_directories as $folder) {
         foreach (File::allFiles($this->_assetsDirectory . '/' . $folder) as $file) {
             $in = $file->getPathname();
             if ($file->getExtension() == 'css' && substr($in, -8) != '.min.css' && substr($in, -9) != '.pack.css') {
                 $out = str_replace('.css', '.min.css', $file->getPathname());
                 $command = 'cat ' . $in . ' | sed -e \'s/^[ \\t]*//g; s/[ \\t]*$//g; s/\\([:{;,]\\) /\\1/g; s/ {/{/g; s/\\/\\*.*\\*\\///g; /^$/d\' | sed -e :a -e \'$!N; s/\\n\\(.\\)/\\1/; ta\' > ' . $out;
                 shell_exec($command);
                 $this->line("\t" . $in . " → " . $out);
             }
         }
     }
     return true;
 }
示例#9
0
文件: Asset.php 项目: lightgear/asset
 /**
  * Search for the assets in the passed path
  * taking into account configured base paths (workbench, vendor, etc)
  *
  * @param  string $path    The path to search
  * @param  string $package The package the assets belong to
  * @return array|null      The array of SplFileInfo objects or null
  */
 protected function findAssets($path, $package)
 {
     $paths = array_merge($this->paths, $this->config->get('asset::search_paths'));
     foreach ($paths as $searchPath) {
         $fullPath = base_path() . $searchPath . '/' . $package . '/' . $path;
         if (File::isDirectory($fullPath)) {
             return File::allFiles($fullPath);
         } elseif (File::isFile($fullPath)) {
             return Finder::create()->depth(0)->name(basename($fullPath))->in(dirname($fullPath));
         }
     }
 }
示例#10
0
<?php

use Illuminate\Support\Facades\File;
foreach (File::allFiles(app_path('Http/Routes')) as $route) {
    $path = $route->getPathname();
    if ($route->getExtension() === 'php') {
        require_once $path;
    }
}
示例#11
0
<?php

use Illuminate\Support\Facades\File;
foreach (File::allFiles(app_path() . '/Http/Routes') as $partial) {
    require_once $partial->getPathName();
}
 /**
  * Execute the Command.
  */
 public function handle()
 {
     // Get all the models
     $modelFiles = File::allFiles(base_path('scaffolder-config/models/'));
     // Start progress bar
     $this->output->progressStart(count($modelFiles));
     // Get app config
     $scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json'));
     // Compilers
     $modelCompiler = new ModelCompiler();
     $migrationCompiler = new MigrationCompiler();
     $controllerCompiler = new ControllerCompiler();
     $indexViewCompiler = new IndexViewCompiler();
     $createViewCompiler = new CreateViewCompiler();
     $editViewCompiler = new EditViewCompiler();
     $pageLayoutViewCompiler = new PageLayoutCompiler();
     $routeCompiler = new RouteCompiler();
     // Compiler output
     $modelCompilerOutput = [];
     $controllerCompilerOutput = [];
     $viewCompilerOutput = [];
     $migrationCompilerOutput = [];
     // Sidenav links
     $sidenavLinks = [];
     // Compiled routes
     $compiledRoutes = '';
     // Get stubs
     $modelStub = File::get($this->stubsDirectory . 'Model.php');
     $migrationStub = File::get($this->stubsDirectory . 'Migration.php');
     $controllerStub = File::get($this->stubsDirectory . 'Controller.php');
     $indexViewStub = File::get($this->themeViews->getIndexPath());
     $createViewStub = File::get($this->themeViews->getCreatePath());
     $editViewStub = File::get($this->themeViews->getEditPath());
     $routeStub = File::get($this->stubsDirectory . 'ResourceRoute.php');
     // Create models directory
     Directory::createIfNotExists(app_path('Models'));
     // Iterate over model files
     foreach ($modelFiles as $modelFile) {
         // Get model name
         $modelName = ucwords($modelFile->getBasename('.' . $modelFile->getExtension()));
         // Get model data
         $modelData = Json::decodeFile($modelFile->getRealPath());
         // Create views directory
         Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName)));
         $modelHash = md5_file($modelFile->getRealPath());
         // Compile stubs
         array_push($modelCompilerOutput, $modelCompiler->compile($modelStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($controllerCompilerOutput, $controllerCompiler->compile($controllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($migrationCompilerOutput, $migrationCompiler->compile($migrationStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
         $compiledRoutes .= $routeCompiler->compile($routeStub, $modelName, $modelData, $scaffolderConfig, null);
         // Add entity link
         array_push($sidenavLinks, $modelName);
         // Advance progress
         $this->output->progressAdvance();
     }
     // Store compiled routes
     $routeCompiler->compileGroup(File::get($this->stubsDirectory . 'Routes.php'), $compiledRoutes, $scaffolderConfig);
     // Create layouts directory
     Directory::createIfNotExists(base_path('resources/views/layouts'));
     // Store compiled page layout
     array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, ['links' => $sidenavLinks]));
     // Store create layout
     File::copy($this->themeLayouts->getCreatePath(), base_path('resources/views/layouts/create.blade.php'));
     array_push($viewCompilerOutput, base_path('resources/views/layouts/create.blade.php'));
     // Store edit layout
     File::copy($this->themeLayouts->getEditPath(), base_path('resources/views/layouts/edit.blade.php'));
     array_push($viewCompilerOutput, base_path('resources/views/layouts/edit.blade.php'));
     // Store dashboard
     File::copy($this->themeViews->getDashboardPath(), base_path('resources/views/dashboard.blade.php'));
     array_push($viewCompilerOutput, base_path('resources/views/dashboard.blade.php'));
     // Finish progress
     $this->output->progressFinish();
     // Summary
     $this->comment('- Files created');
     $this->comment('- - Views');
     foreach ($viewCompilerOutput as $viewFile) {
         $this->info('- - - ' . $viewFile);
     }
     $this->comment('- - Controllers');
     foreach ($controllerCompilerOutput as $controllerFile) {
         $this->info('- - - ' . $controllerFile);
     }
     $this->comment('- - Migrations');
     foreach ($migrationCompilerOutput as $migrationFile) {
         $this->info('- - - ' . $migrationFile);
     }
     $this->comment('- - Models');
     foreach ($modelCompilerOutput as $modelFile) {
         $this->info('- - - ' . $modelFile);
     }
 }
示例#13
0
 /**
  * Execute the Command.
  */
 public function handle()
 {
     $scaffoldApi = $this->option('api');
     $webExecution = $this->option('webExecution');
     try {
         // Get all the models
         $modelFiles = File::allFiles(base_path('scaffolder-config/models/'));
         // Get app config
         $scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json'));
         $apiDirectory = strtolower(str_replace(' ', '-', $scaffolderConfig->name . '-api'));
         // Compilers
         $modelCompiler = new ModelCompiler();
         $apiModelCompiler = new ApiModelCompiler();
         $migrationCompiler = new MigrationCompiler();
         $controllerCompiler = new ControllerCompiler();
         $apiControllerCompiler = new ApiControllerCompiler();
         $indexViewCompiler = new IndexViewCompiler();
         $createViewCompiler = new CreateViewCompiler();
         $editViewCompiler = new EditViewCompiler();
         $dashboardViewCompiler = new DashboardViewCompiler();
         $welcomeViewCompiler = new WelcomeViewCompiler();
         $loginViewCompiler = new LoginViewCompiler();
         $pageLayoutViewCompiler = new PageLayoutCompiler();
         $createLayoutCompiler = new CreateLayoutCompiler();
         $editLayoutCompiler = new EditLayoutCompiler();
         $routeCompiler = new RouteCompiler();
         $apiRouteCompiler = new ApiRouteCompiler();
         // Compiler output
         $modelCompilerOutput = [];
         $apiModelCompilerOutput = [];
         $controllerCompilerOutput = [];
         $apiControllerCompilerOutput = [];
         $viewCompilerOutput = [];
         $migrationCompilerOutput = [];
         // Sidenav links
         $sidenavLinks = [];
         // Compiled routes
         $compiledRoutes = '';
         $compiledApiRoutes = '';
         // Get stubs
         $modelStub = File::get($this->stubsDirectory . 'Model.php');
         $apiModelStub = File::get($this->stubsDirectory . 'api/Model.php');
         $migrationStub = File::get($this->stubsDirectory . 'Migration.php');
         $controllerStub = File::get($this->stubsDirectory . 'Controller.php');
         $apiControllerStub = File::get($this->stubsDirectory . 'api/Controller.php');
         $indexViewStub = File::get($this->themeViews->getIndexPath());
         $createViewStub = File::get($this->themeViews->getCreatePath());
         $editViewStub = File::get($this->themeViews->getEditPath());
         $routeStub = File::get($this->stubsDirectory . 'ResourceRoute.php');
         $apiRouteStub = File::get($this->stubsDirectory . 'api/ResourceRoute.php');
         // Create models directory
         Directory::createIfNotExists(app_path('Models'));
         // Initialize API
         if ($scaffoldApi) {
             if (!(new \FilesystemIterator(base_path('../' . $apiDirectory)))->valid()) {
                 $this->writeStatus('Initializing API ...', $webExecution);
                 $this->call('scaffolder:api-initialize', ['name' => $scaffolderConfig->name, 'domain' => $scaffolderConfig->api->domain, '--webExecution' => $webExecution]);
                 $this->output->newLine();
             } else {
                 $this->writeStatus('API already initialized', $webExecution);
             }
             // Create models directory
             Directory::createIfNotExists(base_path('../' . $apiDirectory . '/app/Models'));
         }
         $this->writeStatus('Compiling ...', $webExecution);
         $this->output->newLine();
         // Start progress bar
         $this->output->progressStart(count($modelFiles));
         // Iterate over model files
         foreach ($modelFiles as $modelFile) {
             // Get model name
             $modelName = ucwords($modelFile->getBasename('.' . $modelFile->getExtension()));
             // Get model data
             $modelData = Json::decodeFile($modelFile->getRealPath());
             // Create views directory
             Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName)));
             $modelHash = md5_file($modelFile->getRealPath());
             // Compile stubs
             array_push($modelCompilerOutput, $modelCompiler->compile($modelStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
             if ($scaffoldApi) {
                 array_push($apiModelCompilerOutput, $apiModelCompiler->compile($apiModelStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
             }
             array_push($controllerCompilerOutput, $controllerCompiler->compile($controllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
             if ($scaffoldApi) {
                 array_push($apiControllerCompilerOutput, $apiControllerCompiler->compile($apiControllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
             }
             array_push($migrationCompilerOutput, $migrationCompiler->compile($migrationStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
             array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
             array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
             array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
             $compiledRoutes .= $routeCompiler->compile($routeStub, $modelName, $modelData, $scaffolderConfig, null, $this->extensions);
             if ($scaffoldApi) {
                 $compiledApiRoutes .= $apiRouteCompiler->compile($apiRouteStub, $modelName, $modelData, $scaffolderConfig, null, $this->extensions);
             }
             // Add entity link
             array_push($sidenavLinks, ['modelName' => $modelName, 'modelLabel' => $modelData->modelLabel]);
             // Advance progress
             $this->output->progressAdvance();
         }
         // Finish progress
         $this->output->progressFinish();
         // Store compiled routes
         $routeCompiler->compileGroup(File::get($this->stubsDirectory . 'Routes.php'), $compiledRoutes, $scaffolderConfig);
         if ($scaffoldApi) {
             $apiRouteCompiler->compileGroup(File::get($this->stubsDirectory . 'api/Routes.php'), $compiledApiRoutes, $scaffolderConfig);
         }
         // Create layouts directory
         Directory::createIfNotExists(base_path('resources/views/layouts'));
         // Compile page layout
         array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions, ['links' => $sidenavLinks]));
         // Compile create layout
         array_push($viewCompilerOutput, $createLayoutCompiler->compile(File::get($this->themeLayouts->getCreatePath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));
         // Compile edit layout
         array_push($viewCompilerOutput, $editLayoutCompiler->compile(File::get($this->themeLayouts->getEditPath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));
         // Compile dashboard view
         array_push($viewCompilerOutput, $dashboardViewCompiler->compile(File::get($this->themeViews->getDashboardPath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));
         // Compile welcome view
         array_push($viewCompilerOutput, $welcomeViewCompiler->compile(File::get($this->themeViews->getWelcomePath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));
         // Compile login view
         array_push($viewCompilerOutput, $loginViewCompiler->compile(File::get($this->themeViews->getLoginPath()), null, null, $scaffolderConfig, null, $this->themeExtension, $this->extensions));
         // Summary
         $this->comment('- Files created');
         $this->comment('- - Views');
         foreach ($viewCompilerOutput as $viewFile) {
             $this->info('- - - ' . $viewFile);
         }
         $this->comment('- - Controllers');
         foreach ($controllerCompilerOutput as $controllerFile) {
             $this->info('- - - ' . $controllerFile);
         }
         $this->comment('- - Migrations');
         foreach ($migrationCompilerOutput as $migrationFile) {
             $this->info('- - - ' . $migrationFile);
         }
         $this->comment('- - Models');
         foreach ($modelCompilerOutput as $modelFile) {
             $this->info('- - - ' . $modelFile);
         }
         if ($scaffoldApi) {
             $this->comment('- - API Controllers');
             foreach ($apiControllerCompilerOutput as $apiControllerFile) {
                 $this->info('- - - ' . $apiControllerFile);
             }
             $this->comment('- - API Models');
             foreach ($apiModelCompilerOutput as $apiModelFile) {
                 $this->info('- - - ' . $apiModelFile);
             }
         }
         $this->writeStatus('Done', $webExecution);
     } catch (\Exception $exception) {
         $this->writeStatus('Error', $webExecution);
         Log::error($exception->getMessage());
     }
 }
示例#14
0
 /**
  * Get list of all files in the views folder
  * @return mixed
  */
 public function allFilesList($dir_path)
 {
     $files = [];
     if (File::exists($dir_path)) {
         $dir_files = File::allFiles($dir_path);
         foreach ($dir_files as $file) {
             $path = basename($file);
             $name = strstr(basename($file), '.', true);
             $files[$name] = $path;
         }
     }
     return $files;
 }
示例#15
0
 public function refresh()
 {
     DB::beginTransaction();
     try {
         $image_files = DB::table($this->_table)->select('id', 'dir', 'filename')->get();
         $exists_image_paths = [];
         foreach ($image_files as $key => $image_file) {
             $path = $this->filePath($image_file->dir, $image_file->filename);
             if (!file_exists($path)) {
                 DB::table($this->_table)->where('id', $image_file->id)->delete();
             } else {
                 $exists_image_paths[] = public_path($this->_path . '/' . $image_file->dir . '/' . $image_file->filename);
             }
         }
         $files = File::allFiles($this->_path);
         foreach ($files as $file) {
             $remove_path = $file->getRealPath();
             if (!in_array($remove_path, $exists_image_paths)) {
                 File::delete($remove_path);
             }
         }
         DB::commit();
         return true;
     } catch (Exception $e) {
         DB::rollback();
         return false;
     }
 }
示例#16
0
文件: TypiCMS.php 项目: vizo/Core
 /**
  * List templates files from directory
  * @return array
  */
 public function templates($directory = 'resources/views/vendor/pages/public')
 {
     $templates = [];
     try {
         $files = File::allFiles(base_path($directory));
     } catch (Exception $e) {
         $files = File::allFiles(base_path('vendor/typicms/pages/src/resources/views/public'));
     }
     foreach ($files as $key => $file) {
         $name = str_replace('.blade.php', '', $file->getRelativePathname());
         if ($name[0] != '_' && $name != 'master') {
             $templates[$name] = ucfirst($name);
         }
     }
     return ['' => ''] + $templates;
 }
示例#17
0
 public function fileManager()
 {
     $destinationPath = $_SERVER['DOCUMENT_ROOT'] . '/public/uploads/files/';
     // upload path
     $files = File::allFiles($destinationPath);
     $result = [];
     foreach ($files as $file) {
         $fileName = str_replace($destinationPath, '/uploads/files/', (string) $file);
         $result[] = ['link' => $fileName, 'size' => filesize((string) $file), 'title' => 'File', 'name' => 'File'];
     }
     return $result;
 }