ConfirmationFactory.php
11 years ago
ConfirmationInterface.php
11 years ago
LinkDeletedConfirmation.php
11 years ago
TrashConfirmation.php
11 years ago
TrashRestoredConfirmation.php
11 years ago
ConfirmationFactory.php
59 lines
| 1 | <?php namespace NestedPages\Entities\Confirmation; |
| 2 | |
| 3 | /** |
| 4 | * Confirmation Message |
| 5 | * @since 1.2 |
| 6 | */ |
| 7 | class ConfirmationFactory { |
| 8 | |
| 9 | /** |
| 10 | * Message Output |
| 11 | * @var string |
| 12 | */ |
| 13 | private $message; |
| 14 | |
| 15 | /** |
| 16 | * Type of Message |
| 17 | * @var string |
| 18 | */ |
| 19 | private $type; |
| 20 | |
| 21 | |
| 22 | public function __construct() |
| 23 | { |
| 24 | $this->build(); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | /** |
| 29 | * Set the Type of confirmation |
| 30 | */ |
| 31 | private function build() |
| 32 | { |
| 33 | if ( (isset($_GET['trashed'])) && (intval($_GET['trashed']) > 0) ) $this->type = 'TrashConfirmation'; |
| 34 | if ( (isset($_GET['untrashed'])) && (intval($_GET['untrashed']) > 0) ) $this->type = 'TrashRestoredConfirmation'; |
| 35 | if ( (isset($_GET['linkdeleted'])) && (intval($_GET['linkdeleted']) > 0 ) ) $this->type = 'LinkDeletedConfirmation'; |
| 36 | if ( $this->type ) $this->createClass(); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | * Set the confirmation message |
| 42 | */ |
| 43 | private function createClass() |
| 44 | { |
| 45 | $class = 'NestedPages\Entities\Confirmation\\' . $this->type; |
| 46 | $confirm = new $class; |
| 47 | $this->message = $confirm->setMessage(); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | /** |
| 52 | * Get the Message |
| 53 | */ |
| 54 | public function getMessage() |
| 55 | { |
| 56 | return $this->message; |
| 57 | } |
| 58 | |
| 59 | } |