Rajout d'une aide de vue
[zf2.biz/galerie.git] / vendor / zf2biz / Custom / View / Helper / Format.php
1 <?php 
2
3 namespace Custom\View\Helper; 
4  
5 use Zend\View\Helper\AbstractHelper; 
6  
7 class Format extends AbstractHelper 
8
9
10     protected $text = null;
11
12     public function __invoke($text = null, $format = null)
13     {
14         $this->text = $text;
15         if (null === $text || null === $format) {
16             return $this;
17         }
18         switch ($format) {
19             case 'strong': return $this->strong();
20             case 'em': return $this->em();
21             case 'info': return $this->info();
22             case 'warning': return $this->warning();
23             case 'error': return $this->error();
24             default: return $text;
25         }
26     }
27
28     public function strong($text = null)
29     {
30         if (null === $text) {
31             $text = $this->text;
32         }
33         return "<strong>{$text}</strong>";
34     }
35
36     public function em($text = null)
37     {
38         if (null === $text) {
39             $text = $this->text;
40         }
41         return "<strong>{$text}</strong>";
42     }
43
44     public function info($text = null)
45     {
46         if (null === $text) {
47             $text = $this->text;
48         }
49         return '<div class="alert-info">' . $text . '</div>';
50     }
51
52
53     public function warning($text = null)
54     {
55         if (null === $text) {
56             $text = $this->text;
57         }
58         return '<div class="alert-warning">' . $text . '</div>';
59     }
60
61
62     public function error($text = null)
63     {
64         if (null === $text) {
65             $text = $this->text;
66         }
67         return '<div class="alert-error">' . $text . '</div>';
68     }
69
70 }