Skip to content
Permalink
Browse files

ExtensionDefinitionsHelper: getCallableFromConfig

  • Loading branch information
mabar committed Dec 4, 2019
1 parent bee75bc commit 89dfa32b0181e67342f0323449f61ff5e8f957fa
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/Helper/ExtensionDefinitionsHelper.php
@@ -88,4 +88,24 @@ public function getDefinitionFromConfig($config, string $preferredPrefix)
return $builder->getDefinition($preferredPrefix);
}

/**
* Check if config is valid callable or callable syntax which may result in valid callable at runtime and returns an definition otherwise
*
* @param string|mixed[]|Statement $config
* @return mixed
*/
public function getCallableFromConfig($config, string $preferredPrefix)
{
if (is_callable($config)) {
return $config;
}

// Might be valid callable at runtime
if (is_array($config) && is_callable($config, true) && Strings::startsWith($config[0], '@')) {
return $config;
}

return $this->getDefinitionFromConfig($config, $preferredPrefix);
}

}

0 comments on commit 89dfa32

Please sign in to comment.
You can’t perform that action at this time.