Comments (8)
@Gappa I'm not sure yet, I'll let you know
from di.
It looks like the TestExtensionConfigDTO
object can't be simply created, so it is created in the container using Dumper::createObject()
, i.e. using serialization+unserialization, which is a pretty dirty way.
But I understand why you use it that way, let's try to find a solution.
The solution I can think of is that TestExtensionConfigDTO
will have a constructor (and all properties will be promoted parameters), so such an object can be easily created. But that's not enough, some information will still have to be added for the DI compiler to use that constructor…
from di.
I am confused what does it have to do with DI compiler. Isn't config schema used just to access config values of the extension? They are not passed to generated DIC
For objects that are passed to generated DIC, I am using explicit serialization, which is fine as long as changing the object forces DIC to regenerate (can be done by adding object to compiler dependencies) https://github.com/orisai/localization/blob/ae99720c58b10408b099e68c9692f75a45c4b627/src/Bridge/NetteDI/LocalizationExtension.php#L131-L136
from di.
@mabar I suppose @Gappa will then pass the $this->config
to some service. Right?
from di.
@mabar I suppose @Gappa will then pass the
$this->config
to some service. Right?
Yes, that is correct.
from di.
I think having some better decision making when triggering error would be fine? Plus some changes in Dumper::createObject
logic to avoid unserialization. Maybe some similar logic to form values? https://github.com/nette/forms/blob/d42a22b451fcdf267e7c485309370506a8731d56/src/Forms/Container.php#L137
If I have simple class like this
class Data {
public string $url;
public string $query;
}
I would say it is really close to \stdClass
, but it is not accepted
c257fa9#diff-b01fda112fb0df465a70dd098f3843dd90fc3a0ce514c37ef38d620e7f7cc718R184
from di.
I don't know how to dump this object:
class Data {
public string $url;
public string $query;
}
but I can dump this one:
class Data {
function __construct(
public string $url,
public string $query,
) {}
}
from di.
Tried it with 6b9910cece1e074ad1d1babc6a62c48dfa9ea870 and it works now - thanks. 👍
However, would it be better if I changed those DTOs to classes with private properties and a constructor?
from di.
Related Issues (20)
- Multifactory does not work
- Dynamic parameter does not work in static parameter HOT 27
- SearchExtension: compatible with trait Nette\StaticClass HOT 1
- Parent method with static type, has a badly evaluated return type for factory method in container
- Compiler error in process schema after update to 3.1.4 HOT 2
- Circular reference detected for variables HOT 5
- wrong inject of variables after update 3.1.6 > 3.1.7 HOT 3
- "ERROR: Circular reference detected for:" instead of creating Service with array of strings as parameters HOT 5
- Nette\DI\Config\Loader::load($filePath) loads string parameter '@12345' as string '@@12345' HOT 3
- Parameters defined using function notation in neon config not available when calling getParameter HOT 4
- Support `new` in initializers HOT 1
- Some releases were deleted HOT 1
- Calling ReflectionMethod::__construct() with 1 argument is deprecated in PHP 8.4
- "Object of class DateTimeImmutable could not be converted to string" after update to 3.2.0
- DI Extensions can not use parameters from app main configuration HOT 8
- Parameter removed if static method referenced [BC break] HOT 4
- Parameters in includes
- ReflectionException: Method Nette\DI\Container::createServiceFromStaticFactory() does not exist
- Cause error: Error: Cannot access trait constant self::CONTROL_FLASH_MESSAGE directly HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from di.