本文整理汇总了PHP中Auryn\Injector::defineParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Injector::defineParam方法的具体用法?PHP Injector::defineParam怎么用?PHP Injector::defineParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auryn\Injector
的用法示例。
在下文中一共展示了Injector::defineParam方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addToInjector
public function addToInjector(Injector $injector)
{
foreach ($this->shares as $share) {
$injector->share($share);
}
foreach ($this->aliases as $original => $alias) {
$injector->alias($original, $alias);
}
foreach ($this->definitions as $name => $args) {
$injector->define($name, $args);
}
foreach ($this->params as $param => $value) {
$injector->defineParam($param, $value);
}
foreach ($this->delegates as $param => $callable) {
$injector->delegate($param, $callable);
}
foreach ($this->prepares as $class => $callable) {
$injector->prepare($class, $callable);
}
}
示例2: createControl
function createControl(PageInfo $pageInfo, Injector $injector)
{
list($controlClassname, $params) = CategoryInfo::getDIInfo($pageInfo);
foreach ($params as $name => $value) {
$injector->defineParam($name, $value);
}
$control = $injector->make($controlClassname);
$params = $control->getFullParams();
foreach ($params as $name => $value) {
$injector->defineParam($name, $value);
}
return $control;
}
示例3: getCustomImageResponse
/**
* @param \Auryn\Injector $injector
* @param $customImageFunction
* @param \ImagickDemo\Example $exampleController
* @param \ImagickDemo\Control $control
* @return mixed
* @throws \Exception
*/
function getCustomImageResponse(CategoryNav $categoryNav, \Auryn\Injector $injector, $customImageFunction, \ImagickDemo\Example $exampleController, \ImagickDemo\Control $control)
{
$injector->defineParam('imageFunction', $customImageFunction);
$params = $control->getFullParams($exampleController->getCustomImageParams());
$defaultCustomParams = array('customImage' => true);
$params = array_merge($defaultCustomParams, $params);
return $this->getImageResponseInternal($categoryNav, $injector, $params);
}
示例4: execute
/**
*
*/
public function execute()
{
//Figure out what Command was requested.
try {
$parsedCommand = $this->console->parseCommandLine();
} catch (ConfiguratorException $ce) {
echo "Problem running configuration: " . $ce->getMessage();
exit(-1);
} catch (\Exception $e) {
//@TODO change to just catch parseException when that's implemented
$output = new BufferedOutput();
$this->console->renderException($e, $output);
echo $output->fetch();
exit(-1);
}
//Run the command requested, or the help callable if no command was input
try {
$output = $parsedCommand->getOutput();
$formatter = $output->getFormatter();
$formatter->setStyle('question', new OutputFormatterStyle('blue'));
$formatter->setStyle('info', new OutputFormatterStyle('blue'));
$questionHelper = new QuestionHelper();
$questionHelper->setHelperSet($this->console->getHelperSet());
// We currently have no config, so fine to create this directly.
$injector = new Injector();
$injector->alias('Configurator\\Writer', 'Configurator\\Writer\\FileWriter');
$injector->defineParam('originalArgs', $this->originalArgs);
foreach ($parsedCommand->getParams() as $key => $value) {
$injector->defineParam($key, $value);
}
$injector->execute($parsedCommand->getCallable());
} catch (ConfiguratorException $ce) {
echo "Error running task: \n";
echo $ce->getMessage();
exit(-1);
} catch (\Exception $e) {
echo "Unexpected exception of type " . get_class($e) . " running configurator`: " . $e->getMessage() . PHP_EOL;
echo $e->getTraceAsString();
exit(-2);
}
}
示例5: testTypelessDefineForAliasedDependency
public function testTypelessDefineForAliasedDependency()
{
$injector = new Injector();
$injector->defineParam('val', 42);
$injector->alias('Auryn\\Test\\TestNoExplicitDefine', 'Auryn\\Test\\ProviderTestCtorParamWithNoTypehintOrDefault');
$obj = $injector->make('Auryn\\Test\\ProviderTestCtorParamWithNoTypehintOrDefaultDependent');
}
示例6: addInjectionParams
function addInjectionParams(Injector $injector, Tier $tier)
{
$injectionParams = $tier->getInjectionParams();
if (!$injectionParams) {
return;
}
foreach ($injectionParams->getAliases() as $original => $alias) {
$injector->alias($original, $alias);
}
foreach ($injectionParams->getShares() as $share) {
$injector->share($share);
}
foreach ($injectionParams->getParams() as $paramName => $value) {
$injector->defineParam($paramName, $value);
}
foreach ($injectionParams->getDelegates() as $className => $callable) {
$injector->delegate($className, $callable);
}
}