Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 119be59

Browse files
committed
move filesystem-specific method to their own trait Filesystem
1 parent 1b1bd91 commit 119be59

File tree

2 files changed

+48
-35
lines changed

2 files changed

+48
-35
lines changed

src/Commands/ServiceMakeCommand.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Lucid\Console\Commands;
1313

1414
use Lucid\Console\Finder;
15-
use Illuminate\Filesystem\Filesystem;
15+
use Lucid\Console\Filesystem;
1616
use Illuminate\Console\GeneratorCommand;
1717
use Illuminate\Config\Repository as Config;
1818
use Symfony\Component\Console\Input\InputOption;
@@ -25,6 +25,7 @@
2525
class ServiceMakeCommand extends GeneratorCommand
2626
{
2727
use Finder;
28+
use Filesystem;
2829

2930
/**
3031
* The base namespace for this command.
@@ -54,13 +55,6 @@ class ServiceMakeCommand extends GeneratorCommand
5455
*/
5556
protected $description = 'Create a new Service';
5657

57-
/**
58-
* The type of class being generated.
59-
*
60-
* @var string
61-
*/
62-
protected $type = 'Service';
63-
6458
/**
6559
* The directories to be created under the service directory.
6660
*
@@ -76,6 +70,7 @@ class ServiceMakeCommand extends GeneratorCommand
7670
'Http/Middleware/',
7771
'Http/Requests/',
7872
'Providers/',
73+
'Features/',
7974
'resources/',
8075
'resources/lang/',
8176
'resources/views/',
@@ -105,7 +100,7 @@ public function fire()
105100
$path = $this->getPath($name);
106101

107102
if ($this->files->exists($path)) {
108-
$this->error($this->type.' already exists!');
103+
$this->error('Service already exists!');
109104

110105
return false;
111106
}
@@ -149,31 +144,6 @@ public function getPath($name)
149144
return $this->findServicePath($name);
150145
}
151146

152-
/**
153-
* Create an empty directory at the given path.
154-
*
155-
* @param string $path
156-
*
157-
* @return bool
158-
*/
159-
public function createDirectory($path)
160-
{
161-
return $this->files->makeDirectory($path, 0755, true, true);
162-
}
163-
164-
/**
165-
* Create a file at the given path with the given contents.
166-
*
167-
* @param string $path
168-
* @param string $contents
169-
*
170-
* @return bool
171-
*/
172-
public function createFile($path, $contents = '')
173-
{
174-
return $this->files->put($path, $contents);
175-
}
176-
177147
/**
178148
* Create the default directories at the given service path.
179149
*
@@ -236,7 +206,7 @@ public function createRouteServiceProvider($name, $path, $slug, $namespace)
236206
{
237207
$serviceNamespace = $this->findServiceNamespace($name);
238208
$controllers = $serviceNamespace.'\Http\Controllers';
239-
$foundation = $this->findRootNamespace().'\Foundation';
209+
$foundation = $this->findFoundationNamespace();
240210

241211
$content = file_get_contents(__DIR__.'/stubs/routeserviceprovider.stub');
242212
$content = str_replace(

src/Filesystem.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the lucid-console project.
5+
*
6+
* (c) Vinelab <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Lucid\Console;
13+
14+
/**
15+
* @author Abed Halawi <[email protected]>
16+
*/
17+
trait Filesystem
18+
{
19+
/**
20+
* Create an empty directory at the given path.
21+
*
22+
* @param string $path
23+
*
24+
* @return bool
25+
*/
26+
public function createDirectory($path)
27+
{
28+
return $this->files->makeDirectory($path, 0755, true, true);
29+
}
30+
31+
/**
32+
* Create a file at the given path with the given contents.
33+
*
34+
* @param string $path
35+
* @param string $contents
36+
*
37+
* @return bool
38+
*/
39+
public function createFile($path, $contents = '')
40+
{
41+
return $this->files->put($path, $contents);
42+
}
43+
}

0 commit comments

Comments
 (0)