protected $origin = self::ORIGIN_CORE_SITEWIDE;
- /** @var ResourceLoaderImage[]|null */
+ /** @var ResourceLoaderImage[][]|null */
protected $imageObjects = null;
/** @var array */
protected $images = [];
$this->definition = null;
if ( isset( $options['data'] ) ) {
- $dataPath = $this->localBasePath . '/' . $options['data'];
+ $dataPath = $this->getLocalPath( $options['data'] );
$data = json_decode( file_get_contents( $dataPath ), true );
$options = array_merge( $data, $options );
}
$this->images[$skin] = $this->images['default'] ?? [];
}
foreach ( $this->images[$skin] as $name => $options ) {
- $fileDescriptor = is_string( $options ) ? $options : $options['file'];
+ $fileDescriptor = is_array( $options ) ? $options['file'] : $options;
$allowedVariants = array_merge(
( is_array( $options ) && isset( $options['variants'] ) ) ? $options['variants'] : [],
return array_map( [ __CLASS__, 'safeFileHash' ], $files );
}
+ /**
+ * @param string|ResourceLoaderFilePath $path
+ * @return string
+ */
+ protected function getLocalPath( $path ) {
+ if ( $path instanceof ResourceLoaderFilePath ) {
+ return $path->getLocalPath();
+ }
+
+ return "{$this->localBasePath}/$path";
+ }
+
/**
* Extract a local base path from module definition information.
*