PublishHomepageCommand
extends Command
in package
uses
AsksToRebuildSite
Publish one of the default homepages to index.blade.php.
Table of Contents
Constants
- USER_EXIT = 130
Properties
- $description : string
- $options : array<string, array{name: string, description: string, group: string}>
- $signature : string
Methods
- askForString() : string|null
- fileLink() : string
- Create a filepath that can be opened in the browser from a terminal.
- gray() : void
- Write a grey-coloured line
- handle() : int
- The base handle method that can be overridden by child classes.
- handleException() : int
- Handle an exception that occurred during command execution.
- indentedLine() : void
- Write a line with the specified indentation level
- infoComment() : void
- Write a nicely formatted and consistent message to the console. Using InfoComment for a lack of a better term.
- askToRebuildSite() : void
- canExistingFileBeOverwritten() : bool
- formatPublishableChoices() : array<string|int, mixed>
- getTemplateOptions() : Collection<string|int, array{name: string, description: string, group: string}>
- isTheExistingFileADefaultOne() : bool
- parseChoiceIntoKey() : string
- parseSelection() : string
- promptForHomepage() : string
- safeHandle() : int
- This method can be overridden by child classes to provide automatic exception handling.
Constants
USER_EXIT
public
final mixed
USER_EXIT
= 130
Properties
$description
protected
string
$description
= 'Publish one of the default homepages to index.blade.php'
$options
protected
array<string, array{name: string, description: string, group: string}>
$options
= ['welcome' => ['name' => 'Welcome', 'description' => 'The default welcome page.', 'group' => 'hyde-welcome-page'], 'posts' => ['name' => 'Posts Feed', 'description' => 'A feed of your latest posts. Perfect for a blog site!', 'group' => 'hyde-posts-page'], 'blank' => ['name' => 'Blank Starter', 'description' => 'A blank Blade template with just the base layout.', 'group' => 'hyde-blank-page']]
$signature
protected
string
$signature
= 'publish:homepage {homepage? : The name of the page to publish}
{--force : Overwrite any existing files}'
Methods
askForString()
public
askForString(string $question[, string|null $default = null ]) : string|null
Parameters
- $question : string
- $default : string|null = null
Return values
string|nullfileLink()
Create a filepath that can be opened in the browser from a terminal.
public
static fileLink(string $path[, string|null $label = null ]) : string
Parameters
- $path : string
- $label : string|null = null
-
If provided, the link will be wrapped in a Symfony Console
href
tag. Note that not all terminals support this, and it may lead to only the label being shown, and the path being lost to the void.
Return values
stringgray()
Write a grey-coloured line
public
gray(string $string) : void
Parameters
- $string : string
handle()
The base handle method that can be overridden by child classes.
public
handle() : int
Alternatively, implement the safeHandle method in your child class to utilize the automatic exception handling provided by this method.
Return values
int —The exit code.
handleException()
Handle an exception that occurred during command execution.
public
handleException(Exception $exception) : int
Parameters
- $exception : Exception
Return values
int —The exit code
indentedLine()
Write a line with the specified indentation level
public
indentedLine(int $spaces, string $string) : void
Parameters
- $spaces : int
- $string : string
infoComment()
Write a nicely formatted and consistent message to the console. Using InfoComment for a lack of a better term.
public
infoComment(string $string) : void
Text in [brackets] will automatically be wrapped in
Parameters
- $string : string
askToRebuildSite()
protected
askToRebuildSite() : void
canExistingFileBeOverwritten()
protected
canExistingFileBeOverwritten() : bool
Return values
boolformatPublishableChoices()
protected
formatPublishableChoices() : array<string|int, mixed>
Return values
array<string|int, mixed>getTemplateOptions()
protected
getTemplateOptions() : Collection<string|int, array{name: string, description: string, group: string}>
Return values
Collection<string|int, array{name: string, description: string, group: string}>isTheExistingFileADefaultOne()
protected
isTheExistingFileADefaultOne() : bool
Return values
boolparseChoiceIntoKey()
protected
parseChoiceIntoKey(string $choice) : string
Parameters
- $choice : string
Return values
stringparseSelection()
protected
parseSelection() : string
Return values
stringpromptForHomepage()
protected
promptForHomepage() : string
Return values
stringsafeHandle()
This method can be overridden by child classes to provide automatic exception handling.
protected
safeHandle() : int
Existing code can be converted simply by renaming the handle() method to safeHandle().
Return values
int —The exit code.