Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support composer-installer-v4 #12

Closed
a-r-m-i-n opened this issue Aug 11, 2022 · 5 comments
Closed

Support composer-installer-v4 #12

a-r-m-i-n opened this issue Aug 11, 2022 · 5 comments

Comments

@a-r-m-i-n
Copy link
Owner

According to #11 (comment) the relative file paths in CSS files are not resolved correctly, when the new composer-installer v4 is involved.

@a-r-m-i-n
Copy link
Owner Author

From the README of composer-installer-v4:

The public resource URL can not be derived any more from the absolute path to the file by stripping off some path part, but only by
passing the absolute path to \TYPO3\CMS\Core\Utility\PathUtility::getAbsoluteWebPath
Example:
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName('EXT:ext_key/Resources/Public/Icons/Extension.svg'));

Currerently I'm using substr to make the absolute server path relative. That's probably the issue.

@a-r-m-i-n
Copy link
Owner Author

The problem with the new assets of composer-installer v4 is, that somehow you need to resolve the hash of the asset/symlink pointing to EXT:my_ext/Resources/Public/.

In SCSS, to address font files, I need to prepend this to every font file:

$fontPath: '../../../_assets/1031f6efa8587629b685351ed90c99bf/Fonts';

Some questions I have:

  • Does this hash change or is it basically an md5 hash of the path pointing to?
  • Is there an API existing, to resolve the path to the asset?

@Patta
Copy link

Patta commented Jan 25, 2023

@a-r-m-i-n

Does this hash change or is it basically an md5 hash of the path pointing to?

Yes, i think so. The path is always the same id in my tests.

Is there an API existing, to resolve the path to the asset?

TYPO3's internal resource resolver. EXT: ....

@brotkrueml
Copy link
Contributor

Does this hash change or is it basically an md5 hash of the path pointing to?

Yes, i think so. The path is always the same id in my tests.

The hash is derived from the relative composer path of the extension:
https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/Utility/PathUtility.php#L65-L70

So, it may be, for example: /vendor/typo3/cms-core/ for $relativePrefix which is then hashed.

But beware: The vendor folder can be configured in a Project's composer.json: https://getcomposer.org/doc/06-config.md#vendor-dir
So one should not really rely on the hash in general. For one project (where this configuration is under control) it may be okay when you're knowing what you're doing.

@a-r-m-i-n
Copy link
Owner Author

Related to #18

@a-r-m-i-n a-r-m-i-n closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants