public function generate($feature, $service, array $jobs = []) { $feature = Str::feature($feature); $service = Str::service($service); $path = $this->findFeaturePath($service, $feature); if ($this->exists($path)) { throw new Exception('Feature already exists!'); return false; } $namespace = $this->findFeatureNamespace($service); $content = file_get_contents($this->getStub()); $useJobs = ''; // stores the `use` statements of the jobs $runJobs = ''; // stores the `$this->run` statements of the jobs foreach ($jobs as $index => $job) { $useJobs .= 'use ' . $job['namespace'] . '\\' . $job['className'] . ";\n"; $runJobs .= "\t\t" . '$this->run(' . $job['className'] . '::class);'; // only add carriage returns when it's not the last job if ($index != count($jobs) - 1) { $runJobs .= "\n\n"; } } $content = str_replace(['{{feature}}', '{{namespace}}', '{{foundation_namespace}}', '{{use_jobs}}', '{{run_jobs}}'], [$feature, $namespace, $this->findFoundationNamespace(), $useJobs, $runJobs], $content); $this->createFile($path, $content); // generate test file $this->generateTestFile($feature, $service); return new Feature($feature, basename($path), $path, $this->relativeFromReal($path), $service ? $this->findService($service) : null, $content); }
/** * Execute the console command. * * @return bool|null */ public function fire() { try { $request = $this->parseRequestName($this->argument('request')); $service = Str::service($this->argument('service')); if (!$this->exists($path = $this->findRequestPath($service, $request))) { $this->error('Request class ' . $request . ' cannot be found.'); } else { $this->delete($path); $this->info('Request class <comment>' . $request . '</comment> deleted successfully.'); } } catch (Exception $e) { $this->error($e->getMessage()); } }
public function generate($name, $service, $plain = false) { $name = Str::controller($name); $service = Str::service($service); $path = $this->findControllerPath($service, $name); if ($this->exists($path)) { throw new Exception('Controller already exists!'); return false; } $namespace = $this->findControllerNamespace($service); $content = file_get_contents($this->getStub($plain)); $content = str_replace(['{{controller}}', '{{namespace}}', '{{foundation_namespace}}'], [$name, $namespace, $this->findFoundationNamespace()], $content); $this->createFile($path, $content); return $this->relativeFromReal($path); }
/** * Execute the console command. * * @return bool|null */ public function fire() { try { $service = Str::service($this->argument('service')); $title = $this->parseName($this->argument('feature')); if (!$this->exists($feature = $this->findFeaturePath($service, $title))) { $this->error('Feature class ' . $title . ' cannot be found.'); } else { $this->delete($feature); $this->info('Feature class <comment>' . $title . '</comment> deleted successfully.'); } } catch (Exception $e) { $this->error($e->getMessage()); } }
/** * Generate the file. * * @param string $name * @param string $service * @return Request|bool * @throws Exception */ public function generate($name, $service) { $request = Str::request($name); $service = Str::service($service); $path = $this->findRequestPath($service, $request); if ($this->exists($path)) { throw new Exception('Request already exists'); return false; } $namespace = $this->findRequestsNamespace($service); $content = file_get_contents($this->getStub()); $content = str_replace(['{{request}}', '{{namespace}}', '{{foundation_namespace}}'], [$request, $namespace, $this->findFoundationNamespace()], $content); $this->createFile($path, $content); return new Request($request, $service, $namespace, basename($path), $path, $this->relativeFromReal($path), $content); }
/** * Execute the console command. * * @return bool|null */ public function fire() { if ($this->isMicroservice()) { return $this->error('This functionality is disabled in a Microservice'); } try { $name = Str::service($this->argument('name')); if (!$this->exists($service = $this->findServicePath($name))) { return $this->error('Service ' . $name . ' cannot be found.'); } $this->delete($service); $this->info('Service <comment>' . $name . '</comment> deleted successfully.' . "\n"); $this->info('Please remove your registered service providers, if any.'); } catch (\Exception $e) { dd($e->getMessage(), $e->getFile(), $e->getLine()); } }
public function generate($name) { $name = Str::service($name); $slug = snake_case($name); $path = $this->findServicePath($name); if ($this->exists($path)) { throw new Exception('Service already exists!'); return false; } // create service directory $this->createDirectory($path); // create .gitkeep file in it $this->createFile($path . '/.gitkeep'); $this->createServiceDirectories($path); $this->addServiceProviders($name, $slug, $path); $this->addRoutesFile($name, $slug, $path); $this->addWelcomeViewFile($path); return new Service($name, $slug, $path, $this->relativeFromReal($path)); }
/** * Find the domain for the given domain name. * * @param string $domain * * @return \Lucid\Console\Components\Domain */ public function findDomain($domain) { $finder = new SymfonyFinder(); $dirs = $finder->name($domain)->in($this->findDomainsRootPath())->directories(); if ($dirs->count() < 1) { throw new Exception('Domain "' . $domain . '" could not be found.'); } foreach ($dirs as $dir) { $path = $dir->getRealPath(); return new Domain(Str::service($domain), $this->findDomainNamespace($domain), $path, $this->relativeFromReal($path)); } }