73 : ?Apps
74 {
75 if (!$this->
validate($discovery_url)) {
76 return null;
77 }
78
79
80 $apps = [];
81 foreach ($this->xml_app_elements as $app) {
82 $actions = [];
83 foreach ($app->action as $action) {
84 $action_name = $action['name'] ?? null;
85 $action_ext = $action['ext'] ?? null;
86 $action_urlsrc = $action['urlsrc'] ?? null;
87 $target_text = isset($action['targetext']) ? (string) $action['targetext'] : null;
88 if (!$action_name instanceof \SimpleXMLElement) {
89 continue;
90 }
91 if (!$action_ext instanceof \SimpleXMLElement) {
92 continue;
93 }
94 if (!$action_urlsrc instanceof \SimpleXMLElement) {
95 continue;
96 }
97
98 if (!in_array((string) $action_name, $this->crawl_actions, true)) {
99 continue;
100 }
101
102 $uri_string = rtrim((string) $action_urlsrc, '?');
103
104 $uri = explode('?', $uri_string);
105 $uri_string = $uri[0];
107 0,
108 (string) $action_name,
109 (string) $action_ext,
110 new URI($uri_string),
111 $uri[1] ?? null,
112 $target_text
113 );
114 }
115 if ($actions === []) {
116 continue;
117 }
118
119 $app_name = $app['name'] ?? null;
120 if ($app_name === null) {
121 continue;
122 }
123 $app_fav_icon_url = $app['favIconUrl'] ?? null;
124 $apps[] = new App(
125 0,
126 (string) $app_name,
127 $actions,
128 $app_fav_icon_url === null ? null : new URI((string) $app_fav_icon_url)
129 );
130 }
131 return new Apps($apps);
132 }
validate(URI $discovery_url)