This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fea38b1
commit eb6c14d
Showing
4 changed files
with
154 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Part of muse project. | ||
* | ||
* @copyright Copyright (C) 2011 - 2015 SMS Taiwan, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
namespace Muse\Controller; | ||
|
||
use Muse\IO\IOInterface; | ||
use Windwalker\Structure\Structure; | ||
|
||
/** | ||
* Base controller class. | ||
*/ | ||
abstract class AbstractMuseController implements MuseControllerInterface | ||
{ | ||
/** | ||
* IO adapter. | ||
* | ||
* @var IOInterface | ||
*/ | ||
public $io; | ||
|
||
/** | ||
* Instantiate the controller. | ||
* | ||
* @param IOInterface $io The Controller object. | ||
* @param Structure $config Config | ||
*/ | ||
public function __construct(IOInterface $io, Structure $config = null) | ||
{ | ||
$this->io = $io; | ||
$this->config = $config ? : new Structure; | ||
} | ||
|
||
/** | ||
* Write a string to standard output. | ||
* | ||
* @param string $text The text to display. | ||
* | ||
* @return AbstractMuseController Instance of $this to allow chaining. | ||
*/ | ||
public function out($text = '') | ||
{ | ||
$this->io->out($text); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Write a string to standard error output. | ||
* | ||
* @param string $text The text to display. | ||
* | ||
* @return AbstractMuseController Instance of $this to allow chaining. | ||
*/ | ||
public function err($text = '') | ||
{ | ||
$this->io->err($text); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get a value from standard input. | ||
* | ||
* @param string $question The question you want to ask user. | ||
* | ||
* @return string The input string from standard input. | ||
*/ | ||
public function in($question = '') | ||
{ | ||
return $this->io->in($question); | ||
} | ||
|
||
/** | ||
* Close system. | ||
* | ||
* @param string $text Close message. | ||
* | ||
* @return void | ||
*/ | ||
public function close($text = '') | ||
{ | ||
$this->io->close($text); | ||
} | ||
} |
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,63 @@ | ||
<?php | ||
/** | ||
* Part of muse project. | ||
* | ||
* @copyright Copyright (C) 2011 - 2015 SMS Taiwan, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
namespace Muse\Controller; | ||
|
||
/** | ||
* Interface ControllerInterface | ||
*/ | ||
interface MuseControllerInterface | ||
{ | ||
/** | ||
* Execute the controller. | ||
* | ||
* @return boolean True if controller finished execution, false if the controller did not | ||
* finish execution. A controller might return false if some precondition for | ||
* the controller to run has not been satisfied. | ||
* | ||
* @throws \LogicException | ||
* @throws \RuntimeException | ||
*/ | ||
public function execute(); | ||
|
||
/** | ||
* Write a string to standard output. | ||
* | ||
* @param string $text The text to display. | ||
* | ||
* @return MuseControllerInterface Instance of $this to allow chaining. | ||
*/ | ||
public function out($text = ''); | ||
|
||
/** | ||
* Write a string to standard error output. | ||
* | ||
* @param string $text The text to display. | ||
* | ||
* @return MuseControllerInterface Instance of $this to allow chaining. | ||
*/ | ||
public function err($text = ''); | ||
|
||
/** | ||
* Get a value from standard input. | ||
* | ||
* @param string $question The question you want to ask user. | ||
* | ||
* @return string The input string from standard input. | ||
*/ | ||
public function in($question = ''); | ||
|
||
/** | ||
* Close system. | ||
* | ||
* @param string $text Close message. | ||
* | ||
* @return void | ||
*/ | ||
public function close($text = ''); | ||
} |