File tree 4 files changed +83
-4
lines changed
4 files changed +83
-4
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ function autoload679875ef60343fd604aa0fa4d353e67e($class) {
61
61
'chapterthree \\applenewsapi \\document \\components \\title ' => '/src/Document/Components/Title.php ' ,
62
62
'chapterthree \\applenewsapi \\document \\components \\tweet ' => '/src/Document/Components/Tweet.php ' ,
63
63
'chapterthree \\applenewsapi \\document \\components \\video ' => '/src/Document/Components/Video.php ' ,
64
+ 'chapterthree \\applenewsapi \\document \\captiondescriptor ' => '/src/Document/CaptionDescriptor.php ' ,
64
65
'chapterthree \\applenewsapi \\document \\contentinset ' => '/src/Document/ContentInset.php ' ,
65
66
'chapterthree \\applenewsapi \\document \\galleryitem ' => '/src/Document/GalleryItem.php ' ,
66
67
'chapterthree \\applenewsapi \\document \\layouts \\advertisinglayout ' => '/src/Document/Layouts/AdvertisingLayout.php ' ,
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * @file
5
+ * Caption Descriptor referenced property.
6
+ */
7
+ namespace ChapterThree \AppleNewsAPI \Document ;
8
+
9
+ use ChapterThree \AppleNewsAPI \Document \Components \Text ;
10
+
11
+ /**
12
+ * An Apple News Document Caption Descriptor. Used with Galleries to support
13
+ * HTML.
14
+ */
15
+ class CaptionDescriptor extends Text {
16
+
17
+ protected $ additions ;
18
+
19
+ /**
20
+ * CaptionDescriptor constructor.
21
+ *
22
+ * @param string $text
23
+ * Contains the raw caption text that needs to be displayed.
24
+ */
25
+ public function __construct ($ text ) {
26
+ $ this ->setText ($ text );
27
+ }
28
+
29
+ /**
30
+ * {@inheritdoc}
31
+ */
32
+ protected function optional () {
33
+ return array_merge (parent ::optional (), array (
34
+ // Note that CaptionDescriptor from Text components in that it is a
35
+ // referenced property, not a component. Thus we mark role as optional.
36
+ 'role ' ,
37
+ 'additions ' ,
38
+ ));
39
+ }
40
+
41
+ /**
42
+ * @return mixed
43
+ */
44
+ public function getAdditions () {
45
+ return $ this ->additions ;
46
+ }
47
+
48
+ /**
49
+ * @param mixed $additions
50
+ */
51
+ public function setAdditions ($ additions ) {
52
+ $ this ->additions = $ additions ;
53
+ }
54
+ }
Original file line number Diff line number Diff line change 7
7
8
8
namespace ChapterThree \AppleNewsAPI \Document \Components ;
9
9
10
+ use ChapterThree \AppleNewsAPI \Document \CaptionDescriptor ;
11
+
10
12
/**
11
13
* An Apple News Document ScalableImage.
12
14
*/
@@ -74,13 +76,24 @@ public function getCaption() {
74
76
/**
75
77
* Setter for caption.
76
78
*
77
- * @param string $value
79
+ * @param string|CaptionDescriptor $value
78
80
* Caption.
79
81
*
80
82
* @return $this
81
83
*/
82
84
public function setCaption ($ value ) {
83
- $ this ->caption = (string ) $ value ;
85
+ $ class = CaptionDescriptor::class;
86
+ if (is_object ($ value )) {
87
+ if ($ value instanceof $ class ) {
88
+ $ this ->caption = $ value ;
89
+ }
90
+ else {
91
+ $ this ->triggerError ("Caption not of class $ {class}. " );
92
+ }
93
+ }
94
+ else {
95
+ $ this ->caption = (string ) $ value ;
96
+ }
84
97
return $ this ;
85
98
}
86
99
Original file line number Diff line number Diff line change @@ -69,13 +69,24 @@ public function getCaption() {
69
69
/**
70
70
* Setter for caption.
71
71
*
72
- * @param string $value
72
+ * @param string|CaptionDescriptor $value
73
73
* Caption.
74
74
*
75
75
* @return $this
76
76
*/
77
77
public function setCaption ($ value ) {
78
- $ this ->caption = (string ) $ value ;
78
+ $ class = CaptionDescriptor::class;
79
+ if (is_object ($ value )) {
80
+ if ($ value instanceof $ class ) {
81
+ $ this ->caption = $ value ;
82
+ }
83
+ else {
84
+ $ this ->triggerError ("Caption not of class $ {class}. " );
85
+ }
86
+ }
87
+ else {
88
+ $ this ->caption = (string ) $ value ;
89
+ }
79
90
return $ this ;
80
91
}
81
92
You can’t perform that action at this time.
0 commit comments