File tree Expand file tree Collapse file tree 8 files changed +210
-0
lines changed Expand file tree Collapse file tree 8 files changed +210
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \MUIH \Bridge \ZendViewHelper ;
4
+
5
+ use MyCLabs \MUIH \GenericVoidTag as MUIHGenericVoidTag ;
6
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \Traits \AttributesTrait ;
7
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \Traits \TitleEnhancementTrait ;
8
+
9
+ /**
10
+ * @author valentin-mcs
11
+ * @package MyCLabs\MUIH
12
+ * @subpackage ZendViewHelper
13
+ */
14
+ class GenericVoidTag
15
+ {
16
+ use AttributesTrait;
17
+ use TitleEnhancementTrait;
18
+
19
+ /**
20
+ * @var MUIHGenericVoidTag
21
+ */
22
+ protected $ uiElement = null ;
23
+
24
+
25
+ /**
26
+ * @return string
27
+ */
28
+ public function __toString ()
29
+ {
30
+ return (string ) $ this ->uiElement ;
31
+ }
32
+
33
+ /**
34
+ * @param string $tag
35
+ * @param bool $withSelfClosing
36
+ * @return $this
37
+ */
38
+ public function genericVoidTag ($ tag , $ withSelfClosing =false )
39
+ {
40
+ $ this ->uiElement = new MUIHGenericVoidTag ($ tag , $ withSelfClosing );
41
+
42
+ return $ this ;
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \MUIH \Bridge \ZendViewHelper ;
4
+
5
+ use MyCLabs \MUIH \Image as MUIHImage ;
6
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \Traits \AttributesTrait ;
7
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \Traits \TitleEnhancementTrait ;
8
+
9
+ /**
10
+ * @author valentin-mcs
11
+ * @package MyCLabs\MUIH
12
+ * @subpackage ZendViewHelper
13
+ */
14
+ class Image
15
+ {
16
+ use AttributesTrait;
17
+ use TitleEnhancementTrait;
18
+
19
+ /**
20
+ * @var MUIHImage
21
+ */
22
+ protected $ uiElement = null ;
23
+
24
+
25
+ /**
26
+ * @return string
27
+ */
28
+ public function __toString ()
29
+ {
30
+ return (string ) $ this ->uiElement ;
31
+ }
32
+
33
+ /**
34
+ * @param string $src
35
+ * @param string $alt
36
+ * @param bool $withSelfClosing
37
+ * @return $this
38
+ */
39
+ public function image ($ src , $ alt ='' , $ withSelfClosing =false )
40
+ {
41
+ $ this ->uiElement = new MUIHImage ($ src , $ alt , $ withSelfClosing );
42
+
43
+ return $ this ;
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \MUIH \Bridge \ZendViewHelper \Zend1 ;
4
+
5
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \GenericVoidTag as ZendGenericVoidTag ;
6
+
7
+ /**
8
+ * @author valentin-mcs
9
+ * @package MyCLabs\MUIH
10
+ * @subpackage ZendViewHelper\Zend1
11
+ */
12
+ class GenericVoidTag extends ZendGenericVoidTag implements \Zend_View_Helper_Interface
13
+ {
14
+ use Zend1HelperTrait;
15
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \MUIH \Bridge \ZendViewHelper \Zend1 ;
4
+
5
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \Image as ZendImage ;
6
+
7
+ /**
8
+ * @author valentin-mcs
9
+ * @package MyCLabs\MUIH
10
+ * @subpackage ZendViewHelper\Zend1
11
+ */
12
+ class Image extends ZendImage implements \Zend_View_Helper_Interface
13
+ {
14
+ use Zend1HelperTrait;
15
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \MUIH \Bridge \ZendViewHelper \Zend2 ;
4
+
5
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \GenericVoidTag as ZendGenericVoidTag ;
6
+
7
+ /**
8
+ * @author valentin-mcs
9
+ * @package MyCLabs\MUIH
10
+ * @subpackage ZendViewHelper\Zend2
11
+ */
12
+ class GenericVoidTag extends ZendGenericVoidTag implements Zend \View \Helper \HelperInterface
13
+ {
14
+ use Zend2HelperTrait;
15
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \MUIH \Bridge \ZendViewHelper \Zend2 ;
4
+
5
+ use MyCLabs \MUIH \Bridge \ZendViewHelper \Image as ZendImage ;
6
+
7
+ /**
8
+ * @author valentin-mcs
9
+ * @package MyCLabs\MUIH
10
+ * @subpackage ZendViewHelper\Zend2
11
+ */
12
+ class Image extends ZendImage implements Zend \View \Helper \HelperInterface
13
+ {
14
+ use Zend2HelperTrait;
15
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MyCLabs \MUIH ;
4
+
5
+ use MyCLabs \MUIH \Interfaces \TitleEnhancementInterface ;
6
+ use MyCLabs \MUIH \Traits \TitleEnhancementTrait ;
7
+
8
+ /**
9
+ * @author valentin-mcs
10
+ * @package MyCLabs\MUIH
11
+ */
12
+ class Image extends GenericVoidTag implements TitleEnhancementInterface
13
+ {
14
+ use TitleEnhancementTrait;
15
+
16
+
17
+ /**
18
+ * @param string $src
19
+ * @param string $alt
20
+ * @param bool $withSelfClosing
21
+ */
22
+ public function __construct ($ src , $ alt ='' , $ withSelfClosing =false )
23
+ {
24
+ $ this ->setAttribute ('src ' , $ src );
25
+ $ this ->setAttribute ('alt ' , $ alt );
26
+
27
+ parent ::__construct ('img ' , $ withSelfClosing );
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MUIHTest \MUIH ;
4
+
5
+
6
+ use MyCLabs \MUIH \Image ;
7
+
8
+ /**
9
+ * @covers MyCLabs\MUIH\Image
10
+ */
11
+ class ImageTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function testDefault ()
14
+ {
15
+ $ tag = new Image ('foo ' );
16
+
17
+ $ this ->assertEquals (
18
+ '<img src="foo" alt=""> ' ,
19
+ $ tag ->getHTML ()
20
+ );
21
+ }
22
+
23
+ public function testConstructor ()
24
+ {
25
+ $ tag = new Image ('foo ' , 'bar ' , true );
26
+
27
+ $ this ->assertEquals (
28
+ '<img src="foo" alt="bar" /> ' ,
29
+ $ tag ->getHTML ()
30
+ );
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments