Example #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (!file_exists(base_path('resources/views/team/create.blade.php'))) {
         $this->line("\n\nPlease perform the starter command:\n");
         $this->info("\n\nphp artisan laracogs:starter\n");
         $this->line("\n\nThen one you're able to run the unit tests successfully re-run this command, to semantic ui your app :)\n");
     } else {
         $fileSystem = new Filesystem();
         $files = $fileSystem->allFiles(__DIR__ . '/../Packages/Semantic');
         $this->line("\n");
         foreach ($files as $file) {
             $this->line(str_replace(__DIR__ . '/../Packages/Semantic/', '', $file));
         }
         $this->info("\n\nThese files will be published\n");
         $result = $this->confirm('Are you sure you want to overwrite any files of the same name?');
         if ($result) {
             $this->copyPreparedFiles(__DIR__ . '/../Packages/Semantic/', base_path());
             $this->info("\nYou will need to install semantic-ui:");
             $this->comment('npm install semantic-ui');
             $this->info("\nWhen prompted, select automatic detection.");
             $this->info("\nWhen prompted, select your project location, default should be fine.");
             $this->info("\nWhen prompted, set the directory to:");
             $this->comment('semantic');
             $this->info("\nThen run:");
             $this->comment('cd semantic && gulp build');
             $this->info("\nThen run:");
             $this->comment('cd ../ && gulp');
             $this->info("\nMake sure you set the PagesController@dashboard to use the following view:");
             $this->comment("'dashboard.main'");
             $this->info("\nFinished setting up semantic-ui in your app\n\n");
         } else {
             $this->info('You cancelled the laracogs semantic');
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Filesystem $files)
 {
     $langDirectory = base_path('resources' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
     $diff = [];
     foreach (ModulesLoader::getRegisteredModules() as $module) {
         if (!is_dir($module->getLocalePath()) or !$module->isPublishable()) {
             continue;
         }
         $locale = $this->input->getOption('locale');
         foreach ($files->directories($module->getLocalePath()) as $localeDir) {
             foreach ($files->allFiles($localeDir) as $localeFile) {
                 $vendorFileDir = $module->getKey() . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFile->getFilename();
                 $vendorFilePath = $langDirectory . $vendorFileDir;
                 if (file_exists($vendorFilePath)) {
                     $localArray = $files->getRequire($localeFile->getRealPath());
                     $vendorArray = $files->getRequire($vendorFilePath);
                     $array = array_keys_exists_recursive($localArray, $vendorArray);
                     $arrayDiff = '';
                     foreach (array_dot($array) as $key => $value) {
                         $arrayDiff .= "{$key}: {$value}\n";
                     }
                     if (empty($arrayDiff)) {
                         continue;
                     }
                     $diff[] = ['modules' . DIRECTORY_SEPARATOR . $vendorFileDir, 'vendor' . DIRECTORY_SEPARATOR . $vendorFileDir];
                     $diff[] = new TableSeparator();
                     $diff[] = [$arrayDiff, var_export(array_merge_recursive($array, $vendorArray), true)];
                     $diff[] = new TableSeparator();
                 }
             }
         }
     }
     $this->table($this->headers, $diff);
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $fullPath = $this->createBaseMigration();
     $this->files->put($fullPath, $this->files->get(__DIR__ . '/stubs/notifications.stub'));
     $this->info('Migration created successfully!');
     $this->composer->dumpAutoloads();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach ($this->files->files(storage_path() . '/framework/sessions') as $file) {
         $this->files->delete($file);
     }
     $this->info('Session files deleted from storage');
 }
 public function it_returns_the_correct_information_on_failing_to_write_to_disk(Filesystem $filesystem)
 {
     $path = "tests/Forms/FooBarForm.php";
     $renderedContents = "Rendered Template Contents";
     $filesystem->put($path, $renderedContents)->willReturn(false);
     $this->writeTemplate($filesystem, $renderedContents, $path)->shouldReturn(['status' => 'fail', 'path' => $path]);
 }
 /**
  * Handle the command.
  *
  * @param Filesystem $files
  */
 public function handle(Filesystem $files)
 {
     $path = $this->fieldType->getStoragePath();
     if ($path && $files->isDirectory(dirname($path))) {
         $files->deleteDirectory(dirname($path));
     }
 }
Example #7
0
 /**
  * Get the composer command for the environment.
  *
  * @return string
  */
 protected function findComposer()
 {
     if ($this->files->exists($this->workingPath . '/composer.phar')) {
         return '"' . PHP_BINARY . '" composer.phar';
     }
     return 'composer';
 }
 public function update($projectId, $fileId, $file, array $data)
 {
     try {
         if (is_null($file)) {
             $this->validator->setRules(['name' => 'required|max:255', 'description' => 'required']);
             $this->validator->with($data)->passesOrFail();
             $fileUpdate = $this->repository->findWhere(['project_id' => $projectId, 'id' => $fileId])->first();
             $fileUpdate->update($data, $fileId);
             return $this->find($projectId, $fileUpdate->id);
         }
         $this->validator->with($data)->passesOrFail();
         $fileUpdate = $this->repository->findWhere(['project_id' => $projectId, 'id' => $fileId])->first();
         $data['extension'] = $file->getClientOriginalExtension();
         $data['file'] = md5(date('Y-m-d H:i:s')) . "." . $data['extension'];
         $this->storage->put($data['file'], $this->filesystem->get($file));
         if ($this->storage->exists($fileUpdate->file)) {
             $this->storage->delete($fileUpdate->file);
         }
         $fileUpdate->update($data, $fileId);
         return $this->find($projectId, $fileUpdate->id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     } catch (\Exception $e) {
         return ['error' => true, 'message' => $e->getMessage()];
     }
 }
 /**
  * Grabs a json file and returns a array
  *
  * @param  string $path The path to the json file
  * @return array        The parsed array
  */
 public function jsonFileToArray($path)
 {
     // Get file contents
     $contents = $this->filesystem->get($path);
     // Return array
     return json_decode($contents, true);
 }
Example #10
0
 /**
  * Load a locale from a given path.
  *
  * @param  string  $path
  * @param  string  $locale
  * @param  string  $group
  * @return array
  */
 protected function loadPath($path, $locale, $group)
 {
     if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
         return $this->files->getRequire($full);
     }
     return array();
 }
Example #11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach (User::all() as $user) {
         if (!$user->rsaKey) {
             throw new \RuntimeException('user ' . $user->email . ' has no RSA key. Create it using key:generate:users');
         }
     }
     if (!$this->filesystem->exists(config('app.backup_key'))) {
         $this->warn('Backup key does not exist. We recommend that you create one using key:generate:master');
     }
     $entries = Entry::all();
     foreach ($entries as $entry) {
         $list = $this->accessDecider->getUserListForEntry($entry);
         if ($list->count() == 0) {
             throw new \RuntimeException('Entry #' . $entry->id . ' has no access. Share it.');
         }
     }
     foreach ($entries as $entry) {
         if ($entry->password != '') {
             continue;
         }
         echo $entry->id . '... ';
         $this->entryCrypt->encrypt($entry->password, $entry);
         echo ' encrypted!' . "\n";
     }
 }
 /**
  * Tears down the fixture, for example, close a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     $filesystem = new Filesystem();
     $filesystem->deleteDirectory(tests_path() . DIRECTORY_SEPARATOR . 'Http');
     unset($this->generator);
     parent::tearDown();
 }
 public function stepDirectories($directory)
 {
     // Check for markers
     $alteredDirectoryName = $this->checkAndReplace($directory);
     // Move the directory and use the new name
     if ($directory !== $alteredDirectoryName) {
         exec("mv {$directory} {$alteredDirectoryName}");
         $directory = $alteredDirectoryName;
     }
     // For every file in the directory, rename and check content
     foreach ($this->files->allFiles($directory) as $file) {
         // Check for changes
         $alteredFilename = $this->checkAndReplace($file);
         // Rename file if it changed
         if ($file !== $alteredFilename) {
             rename($file, $alteredFilename);
             $file = $alteredFilename;
         }
         // Check the content in file, and rename as well
         file_put_contents($file, $this->checkAndReplace(file_get_contents($file)));
     }
     // Continue down the tree
     foreach ($this->files->directories($directory) as $childDirectory) {
         $this->stepDirectories($childDirectory);
     }
 }
Example #14
0
 /**
  * Return the last modified timestamp of a view.
  *
  * @param string $name
  * @return integer
  * @throws FileNotFoundException
  */
 public function lastModified($name)
 {
     if (!$this->files->exists($name)) {
         throw new FileNotFoundException("{$name} does not exist");
     }
     return $this->files->lastModified($name);
 }
 /**
  * @param string $locale
  * @param string $group
  * @return array
  */
 public function get($locale, $group)
 {
     if ($this->fs->exists($path = $this->path . "/{$locale}/{$group}.php")) {
         return $this->fs->getRequire($path);
     }
     return [];
 }
Example #16
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     foreach ($this->files->files(storage_path() . '/views') as $file) {
         $this->files->delete($file);
     }
     $this->info('Views deleted from cache');
 }
Example #17
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $model = ucfirst($this->argument('model'));
     $path = $this->option('path');
     if (empty($path)) {
         $path = database_path(config('smart-seeder.seedDir'));
     } else {
         $path = base_path($path);
     }
     $env = $this->option('env');
     if (!empty($env)) {
         $path .= "/{$env}";
     }
     if (!$this->files->exists($path)) {
         // mode 0755 is based on the default mode Laravel use.
         $this->files->makeDirectory($path, 755, true);
     }
     $created = date('Y_m_d_His');
     $path .= "/seed_{$created}_{$model}Seeder.php";
     $fs = $this->files->get(__DIR__ . '/stubs/DatabaseSeeder.stub');
     $namespace = rtrim($this->getAppNamespace(), '\\');
     $stub = str_replace('{{seeder}}', "seed_{$created}_" . $model . 'Seeder', $fs);
     $stub = str_replace('{{namespace}}', " namespace {$namespace};", $stub);
     $stub = str_replace('{{model}}', $model, $stub);
     $this->files->put($path, $stub);
     $message = "Seed created for {$model}";
     if (!empty($env)) {
         $message .= " in environment: {$env}";
     }
     $this->line($message);
 }
Example #18
0
 /**
  * Extension list.
  *
  * @return \Illuminate\Support\Collection
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function getExtensions()
 {
     if ($this->extensions->isEmpty()) {
         if ($this->files->isDirectory($this->getExtensionPath()) && !empty($vendors = $this->files->directories($this->getExtensionPath()))) {
             collect($vendors)->each(function ($vendor) {
                 if ($this->files->isDirectory($vendor) && !empty($directories = $this->files->directories($vendor))) {
                     collect($directories)->each(function ($directory) {
                         if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                             $package = new Collection(json_decode($this->files->get($file), true));
                             if (Arr::get($package, 'type') == 'notadd-extension' && ($name = Arr::get($package, 'name'))) {
                                 $extension = new Extension($name);
                                 $extension->setAuthor(Arr::get($package, 'authors'));
                                 $extension->setDescription(Arr::get($package, 'description'));
                                 if ($entries = data_get($package, 'autoload.psr-4')) {
                                     foreach ($entries as $namespace => $entry) {
                                         $extension->setEntry($namespace . 'Extension');
                                     }
                                 }
                                 $this->extensions->put($directory, $extension);
                             }
                         }
                     });
                 }
             });
         }
     }
     return $this->extensions;
 }
 function it_can_have_custom_fields(Filesystem $filesystem)
 {
     $this->setPath('path/to/file.md');
     $filesystem->get('path/to/file.md')->shouldBeCalled()->willReturn("---\r\nfoofield: foo\r\nbarfield: bar\r\n---\r\nContent'");
     $this->getCustomField('foofield')->shouldBe('foo');
     $this->getCustomField('barfield')->shouldBe('bar');
 }
Example #20
0
 /**
  * Get the given stub by name.
  *
  * @param  string  $table
  *
  * @return void
  */
 protected function getStub($name)
 {
     if (stripos($name, '.php.stub') === false) {
         $name = $name . '.php.stub';
     }
     return $this->files->get($this->getStubPath() . '/' . $name);
 }
Example #21
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (file_exists($compiled = base_path() . '/bootstrap/compiled.php')) {
         $this->error('Error generating IDE Helper: first delete bootstrap/compiled.php (php artisan clear-compiled)');
     } else {
         $filename = $this->argument('filename');
         $format = $this->option('format');
         // Strip the php extension
         if (substr($filename, -4, 4) == '.php') {
             $filename = substr($filename, 0, -4);
         }
         $filename .= '.' . $format;
         if ($this->option('memory')) {
             $this->useMemoryDriver();
         }
         $helpers = '';
         if ($this->option('helpers') || $this->config->get('laravel-ide-helper::include_helpers')) {
             foreach ($this->config->get('laravel-ide-helper::helper_files', array()) as $helper) {
                 if (file_exists($helper)) {
                     $helpers .= str_replace(array('<?php', '?>'), '', $this->files->get($helper));
                 }
             }
         } else {
             $helpers = '';
         }
         $generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers);
         $content = $generator->generate($format);
         $written = $this->files->put($filename, $content);
         if ($written !== false) {
             $this->info("A new helper file was written to {$filename}");
         } else {
             $this->error("The helper file could not be created at {$filename}");
         }
     }
 }
Example #22
0
 protected function makeDirectory($path)
 {
     if (!($status = $this->files->makeDirectory($path))) {
         return $this->files->makeDirectory(dirname($path), 0777, true, true);
     }
     return $status;
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->cache->flush();
     $this->files->delete($this->laravel['config']['app.manifest'] . '/services.json');
     $this->laravel['events']->fire('cache:cleared');
     $this->info('Application cache cleared!');
 }
Example #24
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $name = $this->argument('name');
     $fileSystem = new Filesystem();
     $files = $fileSystem->allFiles(base_path('resources/themes/' . strtolower($name) . '/public'));
     foreach ($files as $file) {
         if ($file->getType() === 'file') {
             $this->line(public_path($file->getBasename()));
         }
     }
     $this->info("\n\nThese files will be overwritten\n");
     if (!$this->option('forced')) {
         $result = $this->confirm('Are you sure you want to overwrite any files of the same name?');
     } else {
         $result = true;
     }
     if ($result) {
         foreach ($files as $file) {
             $newFileName = str_replace(base_path('resources/themes/' . strtolower($name) . '/public/'), '', $file);
             $this->line('Copying ' . public_path($newFileName) . '...');
             if (is_dir($file)) {
                 $fileSystem->copyDirectory($file, public_path($newFileName));
             } else {
                 @mkdir(public_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
                 $fileSystem->copy($file, public_path($newFileName));
             }
         }
     } else {
         $this->info("\n\nNo files were published\n");
     }
 }
Example #25
0
 /**
  * Get the composer command for the environment.
  *
  * @return string
  */
 protected function findComposer()
 {
     if ($this->files->exists($this->workingPath . '/composer.phar')) {
         return 'php ' . $this->workingPath . '/composer.phar';
     }
     return 'composer';
 }
Example #26
0
 /**
  * Find the extensions.
  *
  * @param  array $paths
  * @return array
  */
 public function findExtensions(array $paths)
 {
     $files = array();
     // Iterate over the paths.
     foreach ($paths as $path) {
         // Find the extension files.
         $found = $this->filesystem->glob($path . '/*/*/extension.php');
         // Check if we found some files.
         if (is_array($found)) {
             // Merge the files.
             $files = array_merge($files, $found);
         }
     }
     $extensions = array();
     // Iterate over the files.
     foreach ($files as $file) {
         // Get the extension attributes.
         $attributes = $this->filesystem->getRequire($file);
         // Check if the attributes are valid.
         if (is_array($attributes) && isset($attributes['slug'])) {
             // Initialise the extension class.
             $extensions[$attributes['slug']] = new Extension(dirname($file), $attributes);
         }
     }
     return $extensions;
 }
Example #27
0
 /**
  * Execute the console command.
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function fire()
 {
     $fullPath = $this->createBaseMigration();
     $this->files->put($fullPath, $this->files->get(__DIR__ . '/stubs/database.stub'));
     $this->info('Migration created successfully!');
     $this->call('dump-autoload');
 }
Example #28
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->call('config:clear');
     $config = $this->getFreshConfiguration();
     $this->files->put($this->laravel->getCachedConfigPath(), '<?php return ' . var_export($config, true) . ';' . PHP_EOL);
     $this->info('Configuration cached successfully!');
 }
Example #29
0
 /**
  * {@inheritDoc}
  */
 public function gc($lifetime)
 {
     $files = Finder::create()->in($this->path)->files()->ignoreDotFiles(true)->date('<= now - ' . $lifetime . ' seconds');
     foreach ($files as $file) {
         $this->files->delete($file->getRealPath());
     }
 }
Example #30
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (!file_exists(base_path('resources/views/team/create.blade.php'))) {
         $this->line("\n\nPlease perform the starter command:\n");
         $this->info("\n\nphp artisan laracogs:starter\n");
         $this->line("\n\nThen one you're able to run the unit tests successfully re-run this command, to bootstrap your app :)\n");
     } else {
         $fileSystem = new Filesystem();
         $files = $fileSystem->allFiles(__DIR__ . '/../Packages/Bootstrap');
         $this->line("\n");
         foreach ($files as $file) {
             $this->line(str_replace(__DIR__ . '/../Packages/Bootstrap/', '', $file));
         }
         $this->info("\n\nThese files will be published\n");
         $result = $this->confirm('Are you sure you want to overwrite any files of the same name?');
         if ($result) {
             $this->copyPreparedFiles(__DIR__ . '/../Packages/Bootstrap/', base_path());
             $this->line("\nMake sure you set the PagesController@dashboard to use the following view:\n");
             $this->comment("'dashboard.main'\n");
             $this->info("Run the following:\n");
             $this->comment("npm install\n");
             $this->comment("gulp\n");
             $this->info("Finished bootstrapping your app\n");
         } else {
             $this->info('You cancelled the laracogs bootstrap');
         }
     }
 }