nayjest / di-hub Goto Github PK
View Code? Open in Web Editor NEWDependency injection library for PHP with links consistency maintaining mechanism
License: MIT License
Dependency injection library for PHP with links consistency maintaining mechanism
License: MIT License
Example: '@' means that item2 placed in outer hub.
$hub->addDefinition(new Relation('item1', '@item2', $callback));
Impl. details: SubHub should remove relations with ext. dependencies from internal hub and add corresponding relations to external hub.
Todo: Define behavior when multiple external hubs available
Example:
new ComplexRelationDefinition(
'target_id',
['source1_id', 'source2_id'],
function(&$taget, $source1, $source2) {
&$target = $source1 + $source2;
}
);
CompoundDefinition is abstract class that can add multiple items to hub.
Requirements: possibility to remove CompoundDefinition from hub
Uncomment to fail tests: https://github.com/Nayjest/di-hub/blob/v0.4-dev/tests/Integration/SubSubHubTest.php#L31
Related code: https://github.com/Nayjest/di-hub/blob/v0.4-dev/src/SubHub.php#L150
Possible solution:
Support of multiple external hubs in one SubHub.
Possible flags:
1. Value::FLAG_PRIVATE
private item
Behaviour:
Use-case:
implementation of internal items for multi-source relation definitions, see #3
2. Value::FLAG_IMMUTABLE
Value can't be changed via relations or $hub->set()
Behaviour:
Throw exceptions when trying modify item via $hub->set() or when value is used as target in relations.
Use-cases: useful when it's prohibited to modify or replace item during app lifetime
3. Value::FLAG_NOT_INITIALIZED
Draft, not implement it, design it first. (TODO)
$hub->set() should be called at least once
Case:
We have hub with $item and two dependencies: $a, $b.
Relation [a --> item] replaces $item instance (or makes $item->b not actual in any other way).
Relation [b --> item] should be always processed after calling `$hub->set('a', some_value)`.
Relation [b --> item] should use instence created in [a --> item]
If it's possible with current Di-Hub architecture, document solution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.