Endpoints
4 months ago
Validator
4 months ago
Main.php
4 months ago
Messages.php
4 months ago
Post_Repository.php
4 months ago
Service_Provider.php
4 months ago
Messages.php
82 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Pods\REST\V1; |
| 4 | |
| 5 | // Don't load directly. |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | die( '-1' ); |
| 8 | } |
| 9 | |
| 10 | use Pods\REST\Interfaces\Messages_Interface; |
| 11 | |
| 12 | /** |
| 13 | * Class Messages |
| 14 | * |
| 15 | * @since 2.8.0 |
| 16 | */ |
| 17 | class Messages implements Messages_Interface { |
| 18 | |
| 19 | /** |
| 20 | * @var string |
| 21 | */ |
| 22 | protected $message_prefix = 'rest-v1:'; |
| 23 | |
| 24 | /** |
| 25 | * @var array |
| 26 | */ |
| 27 | protected $messages = []; |
| 28 | |
| 29 | /** |
| 30 | * Messages constructor. |
| 31 | * |
| 32 | * @since 2.8.0 |
| 33 | */ |
| 34 | public function __construct() { |
| 35 | $this->messages = [ |
| 36 | // @todo Fill this out. |
| 37 | ]; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Returns the localized message associated with the slug. |
| 42 | * |
| 43 | * @since 2.8.0 |
| 44 | * |
| 45 | * @param string $message_slug |
| 46 | * |
| 47 | * @return string |
| 48 | */ |
| 49 | public function get_message( $message_slug ) { |
| 50 | if ( isset( $this->messages[ $message_slug ] ) ) { |
| 51 | return $this->messages[ $message_slug ]; |
| 52 | } |
| 53 | |
| 54 | return ''; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns the associative array of all the messages handled by the class. |
| 59 | * |
| 60 | * @since 2.8.0 |
| 61 | * |
| 62 | * @return array An associative array in the `[ <slug> => <localized message> ]` format. |
| 63 | */ |
| 64 | public function get_messages() { |
| 65 | return $this->messages; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Prefixes a message slug with a common root. |
| 70 | * |
| 71 | * @since 2.8.0 |
| 72 | * |
| 73 | * @param string $message_slug |
| 74 | * |
| 75 | * @return string The prefixed message slug. |
| 76 | */ |
| 77 | public function prefix_message_slug( $message_slug ) { |
| 78 | return $this->message_prefix . $message_slug; |
| 79 | } |
| 80 | |
| 81 | } |
| 82 |