← All changes
|
backend/src/Data/Transformers/PluginUpdatesTransformer.php
+53
-53
1.5.5
→
1.4.7
View file →
| @@ -1,53 +1,53 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | - | |
| 4 | -namespace FL\Assistant\Data\Transformers; | |
| 5 | - | |
| 6 | - | |
| 7 | -class PluginUpdatesTransformer { | |
| 8 | - | |
| 9 | - public function __invoke( \stdClass $plugin ) { | |
| 10 | - $update = $plugin->update; | |
| 11 | - $thumbnail = null; | |
| 12 | - $banner = null; | |
| 13 | - | |
| 14 | - if ( isset( $update->icons ) ) { | |
| 15 | - if ( isset( $update->icons['2x'] ) ) { | |
| 16 | - $thumbnail = $update->icons['2x']; | |
| 17 | - } elseif ( isset( $update->icons['1x'] ) ) { | |
| 18 | - $thumbnail = $update->icons['1x']; | |
| 19 | - } | |
| 20 | - } | |
| 21 | - | |
| 22 | - if ( isset( $update->banners ) ) { | |
| 23 | - $update->banners = (array) $update->banners; | |
| 24 | - | |
| 25 | - if ( isset( $update->banners['2x'] ) ) { | |
| 26 | - $banner = $update->banners['2x']; | |
| 27 | - } elseif ( isset( $update->banners['1x'] ) ) { | |
| 28 | - $banner = $update->banners['1x']; | |
| 29 | - } | |
| 30 | - } | |
| 31 | - | |
| 32 | - return [ | |
| 33 | - 'author' => $plugin->AuthorName, | |
| 34 | - 'authorURI' => $plugin->AuthorURI, | |
| 35 | - 'banner' => $banner, | |
| 36 | - 'bannerSizes' => isset( $update->banners ) ? $update->banners : null, | |
| 37 | - 'content' => $plugin->Description, | |
| 38 | - 'id' => $update->plugin, | |
| 39 | - 'meta' => $plugin->Version . ' by ' . $plugin->AuthorName, | |
| 40 | - 'metaUpdated' => $update->new_version . ' by ' . $plugin->AuthorName, | |
| 41 | - 'plugin' => $update->plugin, | |
| 42 | - 'thumbnail' => $thumbnail, | |
| 43 | - 'thumbnailSizes' => $update->icons, | |
| 44 | - 'title' => $plugin->Name, | |
| 45 | - 'type' => 'plugin', | |
| 46 | - 'version' => $plugin->Version, | |
| 47 | - 'updatedVersion' => $update->new_version, | |
| 48 | - 'tested' => $update->tested, | |
| 49 | - 'requiresPHP' => isset( $update->requires_php ) ? $update->requires_php : null, | |
| 50 | - 'pluginURI' => $plugin->PluginURI, | |
| 51 | - ]; | |
| 52 | - } | |
| 53 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | + | |
| 4 | +namespace FL\Assistant\Data\Transformers; | |
| 5 | + | |
| 6 | + | |
| 7 | +class PluginUpdatesTransformer { | |
| 8 | + | |
| 9 | + public function __invoke( \stdClass $plugin ) { | |
| 10 | + $update = $plugin->update; | |
| 11 | + $thumbnail = null; | |
| 12 | + $banner = null; | |
| 13 | + | |
| 14 | + if ( isset( $update->icons ) ) { | |
| 15 | + if ( isset( $update->icons['2x'] ) ) { | |
| 16 | + $thumbnail = $update->icons['2x']; | |
| 17 | + } elseif ( isset( $update->icons['1x'] ) ) { | |
| 18 | + $thumbnail = $update->icons['1x']; | |
| 19 | + } | |
| 20 | + } | |
| 21 | + | |
| 22 | + if ( isset( $update->banners ) ) { | |
| 23 | + $update->banners = (array) $update->banners; | |
| 24 | + | |
| 25 | + if ( isset( $update->banners['2x'] ) ) { | |
| 26 | + $banner = $update->banners['2x']; | |
| 27 | + } elseif ( isset( $update->banners['1x'] ) ) { | |
| 28 | + $banner = $update->banners['1x']; | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 32 | + return [ | |
| 33 | + 'author' => $plugin->AuthorName, | |
| 34 | + 'authorURI' => $plugin->AuthorURI, | |
| 35 | + 'banner' => $banner, | |
| 36 | + 'bannerSizes' => isset( $update->banners ) ? $update->banners : null, | |
| 37 | + 'content' => $plugin->Description, | |
| 38 | + 'id' => $update->plugin, | |
| 39 | + 'meta' => $plugin->Version . ' by ' . $plugin->AuthorName, | |
| 40 | + 'metaUpdated' => $update->new_version . ' by ' . $plugin->AuthorName, | |
| 41 | + 'plugin' => $update->plugin, | |
| 42 | + 'thumbnail' => $thumbnail, | |
| 43 | + 'thumbnailSizes' => $update->icons, | |
| 44 | + 'title' => $plugin->Name, | |
| 45 | + 'type' => 'plugin', | |
| 46 | + 'version' => $plugin->Version, | |
| 47 | + 'updatedVersion' => $update->new_version, | |
| 48 | + 'tested' => $update->tested, | |
| 49 | + 'requiresPHP' => isset( $update->requires_php ) ? $update->requires_php : null, | |
| 50 | + 'pluginURI' => $plugin->PluginURI, | |
| 51 | + ]; | |
| 52 | + } | |
| 53 | +} | |