AutoloadFileWriter.php
11 months ago
AutoloadGenerator.php
11 months ago
AutoloadProcessor.php
11 months ago
CustomAutoloaderPlugin.php
11 months ago
ManifestGenerator.php
11 months ago
autoload.php
11 months ago
class-autoloader-handler.php
11 months ago
class-autoloader-locator.php
11 months ago
class-autoloader.php
11 months ago
class-container.php
11 months ago
class-hook-manager.php
11 months ago
class-latest-autoloader-guard.php
11 months ago
class-manifest-reader.php
11 months ago
class-path-processor.php
11 months ago
class-php-autoloader.php
11 months ago
class-plugin-locator.php
11 months ago
class-plugins-handler.php
11 months ago
class-shutdown-handler.php
11 months ago
class-version-loader.php
11 months ago
class-version-selector.php
11 months ago
index.php
11 months ago
class-manifest-reader.php
47 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | // phpcs:ignore |
| 4 | class Manifest_Reader { |
| 5 | private $version_selector; |
| 6 | public function __construct( $version_selector ) { |
| 7 | $this->version_selector = $version_selector; |
| 8 | } |
| 9 | public function read_manifests( $plugin_paths, $manifest_path, &$path_map ) { |
| 10 | $file_paths = array_map( |
| 11 | function ( $path ) use ( $manifest_path ) { |
| 12 | return trailingslashit( $path ) . $manifest_path; |
| 13 | }, |
| 14 | $plugin_paths |
| 15 | ); |
| 16 | foreach ( $file_paths as $path ) { |
| 17 | $this->register_manifest( $path, $path_map ); |
| 18 | } |
| 19 | return $path_map; |
| 20 | } |
| 21 | protected function register_manifest( $manifest_path, &$path_map ) { |
| 22 | if ( ! is_readable( $manifest_path ) ) { |
| 23 | return; |
| 24 | } |
| 25 | $manifest = require $manifest_path; |
| 26 | if ( ! is_array( $manifest ) ) { |
| 27 | return; |
| 28 | } |
| 29 | foreach ( $manifest as $key => $data ) { |
| 30 | $this->register_record( $key, $data, $path_map ); |
| 31 | } |
| 32 | } |
| 33 | protected function register_record( $key, $data, &$path_map ) { |
| 34 | if ( isset( $path_map[ $key ]['version'] ) ) { |
| 35 | $selected_version = $path_map[ $key ]['version']; |
| 36 | } else { |
| 37 | $selected_version = null; |
| 38 | } |
| 39 | if ( $this->version_selector->is_version_update_required( $selected_version, $data['version'] ) ) { |
| 40 | $path_map[ $key ] = array( |
| 41 | 'version' => $data['version'], |
| 42 | 'path' => $data['path'], |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 |