-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added command to generate shortcode class, multiple other edtis
- Loading branch information
Showing
8 changed files
with
208 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Vedmant\LaravelShortcodes\Commands; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
|
||
class MakeShortcodeCommand extends GeneratorCommand | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'make:shortcode'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new shortcode class'; | ||
|
||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Shortcode'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
if (parent::handle() === false && ! $this->option('force')) { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/../../stubs/shortcode.stub'; | ||
} | ||
|
||
/** | ||
* Determine if the class already exists. | ||
* | ||
* @param string $rawName | ||
* @return bool | ||
*/ | ||
protected function alreadyExists($rawName) | ||
{ | ||
return class_exists($rawName); | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
return $rootNamespace.'\Shortcodes'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace DummyNamespace; | ||
|
||
use Vedmant\LaravelShortcodes\Shortcode; | ||
|
||
class DummyClass extends Shortcode | ||
{ | ||
/** | ||
* @var string Shortcode description | ||
*/ | ||
public $description = 'Shortcode description'; | ||
|
||
/** | ||
* Get attributes config | ||
* | ||
* @return mixed | ||
*/ | ||
public function attributes() | ||
{ | ||
return [ | ||
'example' => [ | ||
'default' => 'default', | ||
'description' => 'Example attribute', | ||
'sample' => 'some-sample-value', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Render shortcode | ||
* | ||
* @param array $atts | ||
* @param string $content | ||
* @return string | ||
*/ | ||
public function render(array $atts, $content, $tag) | ||
{ | ||
return $this->view('shortcodes.some-shortcode', compact('atts', 'content')); | ||
} | ||
} |