# disco/1.3.51/vendor/inpsyde/assets/src/Loader/WebpackManifestLoader.php

Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO, version 1.3.51. 53 lines.

- Page: https://pluginprobe.com/plugins/disco/1.3.51/code/vendor/inpsyde/assets/src/Loader/WebpackManifestLoader.php
- Raw: https://pluginprobe.com/plugins/disco/1.3.51/raw/vendor/inpsyde/assets/src/Loader/WebpackManifestLoader.php
- Modified: 2024-09-18T11:17:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/disco/1.3.51/code/vendor/inpsyde/assets/src/Loader/WebpackManifestLoader.php#L10-L20`.

```php
<?php

/*
 * This file is part of the Assets package.
 *
 * (c) Inpsyde GmbH
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Inpsyde\Assets\Loader;

/**
 * Implementation of Webpack manifest.json parsing into Assets.
 *
 * @link https://www.npmjs.com/package/webpack-manifest-plugin
 *
 * @package Inpsyde\Assets\Loader
 */
class WebpackManifestLoader extends AbstractWebpackLoader
{
    /**
     * {@inheritDoc}
     */
    protected function parseData(array $data, string $resource): array
    {
        $directory = trailingslashit(dirname($resource));
        $assets = [];
        foreach ($data as $handle => $file) {
            // It can be possible, that the "handle"-key is a filepath.
            $handle = pathinfo($handle, PATHINFO_FILENAME);

            $sanitizedFile = $this->sanitizeFileName($file);

            $fileUrl = (! $this->directoryUrl)
                ? $file
                : $this->directoryUrl . $sanitizedFile;

            $filePath = $directory . $sanitizedFile;

            $asset = $this->buildAsset($handle, $fileUrl, $filePath);
            if ($asset !== null) {
                $assets[] = $asset;
            }
        }

        return $assets;
    }
}

```
