Inpsyde\MultilingualPress\Asset\DebugAwareScript::from_location PHP Method

from_location() public static method

Returns a new script object, instantiated according to the given arguments.
Since: 3.0.0
public static from_location ( string $handle, AssetLocation $location, array $dependencies = [], string | null $version = '' ) : static
$handle string The handle.
$location AssetLocation Location object.
$dependencies array Optional. The dependencies. Defaults to empty array.
$version string | null Optional. Version of the file. Defaults to empty string.
return static Script object.
    public static function from_location($handle, AssetLocation $location, array $dependencies = [], $version = '')
    {
        $url = DebugAwareAssetURL::from_location($location);
        if (null !== $version) {
            $version = $version ?: $url->version();
        }
        return new static($handle, (string) $url, $dependencies, $version);
    }

Usage Example

 /**
  * Returns a new script object, instantiated according to the given arguments.
  *
  * @since 3.0.0
  *
  * @param string      $handle       The handle.
  * @param string      $file         File name.
  * @param string[]    $dependencies Optional. The dependencies.
  * @param string|null $version      Optional. Version of the file. Defaults to empty string.
  *
  * @return Script Script object.
  */
 public function create_internal_script($handle, $file, array $dependencies = [], $version = '')
 {
     return DebugAwareScript::from_location($handle, new AssetLocation($file, $this->internal_script_path, $this->internal_script_url), $dependencies, $version);
 }