- rand: documentation ( source)
<?php
// The controller
class Controller
{
public function indexAction(MyLibrary $obj)
{
$variable = rand(1,10); // this is the variable my library needs
// But this is NOT DI'd as it's only decided here
}
}
// A random object that is a dependency of MyLibrary
class AnotherObject { }
// This is what is DI'd into my controller
class MyLibrary
{
public function __construct(AnotherObject $obj2, $variable) { }
}
// Auryn won't know about the $variable until my controller gets it