You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Heads up: I don't have much experience with Nette so forgive me if this is a silly question.
For Nette Schema I want to configure a new type called path that's basically a string that transforms relative paths to an absolute path depending on where they are loaded.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Heads up: I don't have much experience with Nette so forgive me if this is a silly question.
For Nette Schema I want to configure a new type called
path
that's basically astring
that transforms relative paths to an absolute path depending on where they are loaded.Example:
The
myPath
parameter should be transformed to an absolute path, relative to the configuration file:src/Config/some-file.neon
.When the path is absolute, it should be kept as is.
PHPStan solves this by creating a Nette\DI\Config\Adapter and then process the paths like this:
https://github.com/phpstan/phpstan-src/blob/e8027e7a59ba4e70925c89df51081902aa577e03/src/DependencyInjection/NeonAdapter.php#L122-L146
The downside of this approach is that it's not generic, and when other extensions want to use it, it needs to be added.
So my thought was: why can't we register a
path
type, that takes care of this?I might be able to do this in pure PHP using transformations like this:
https://github.com/nette/schema?tab=readme-ov-file#transformation-transform
But this is how PHPStan's does it, and it loads the parametersSchema from neon, and then processes it like this:
https://github.com/phpstan/phpstan-src/blob/e8027e7a59ba4e70925c89df51081902aa577e03/src/DependencyInjection/ContainerFactory.php#L342-L351
Beta Was this translation helpful? Give feedback.
All reactions