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
For classes requiring specific instantiation logic, the `DependencyInjector` offers a `delegate` method. This method allows you to specify a custom callback for creating instances of a specific class, providing greater control over the object creation process.
104
+
105
+
```php
106
+
<?php
107
+
108
+
require_once 'vendor/autoload.php';
109
+
110
+
use CommonPHP\DependencyInjection\DependencyInjector;
111
+
112
+
class SpecificClass {
113
+
private string $customArg1;
114
+
private string $customArg2;
115
+
116
+
public function __construct(string $customArg1, string $customArg2) {
117
+
// Custom construction logic here
118
+
}
119
+
}
120
+
121
+
$injector = new DependencyInjector();
122
+
123
+
// Delegate instantiation of SpecificClass to a custom callback
0 commit comments