本文整理汇总了PHP中Silex\Application::keys方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::keys方法的具体用法?PHP Application::keys怎么用?PHP Application::keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testItCanBeRegisteredAndBooted
public function testItCanBeRegisteredAndBooted()
{
$restProvider = new RestProvider();
$app = new Application();
$defaultServices = $app->keys();
$app->register($restProvider);
$app->boot();
$definedByProvider = array_values(array_diff($app->keys(), $defaultServices));
$expectedServices = ['alchemy_rest.debug', 'alchemy_rest.fractal_manager', 'alchemy_rest.transformers_registry', 'alchemy_rest.array_transformer', 'alchemy_rest.exception_transformer', 'alchemy_rest.exception_listener', 'alchemy_rest.date_parser.timezone', 'alchemy_rest.date_parser.format', 'alchemy_rest.date_parser', 'alchemy_rest.date_request_listener', 'alchemy_rest.paginate_options.offset_parameter', 'alchemy_rest.paginate_options.limit_parameter', 'alchemy_rest.paginate_options_factory', 'alchemy_rest.paginate_request_listener', 'alchemy_rest.sort_options.sort_parameter', 'alchemy_rest.sort_options.direction_parameter', 'alchemy_rest.sort_options.multi_sort_parameter', 'alchemy_rest.sort_options_factory', 'alchemy_rest.sort_request_listener', 'alchemy_rest.transform_response_listener'];
$undefinedServices = array_diff($expectedServices, $definedByProvider);
$this->assertEquals([], $undefinedServices);
}
示例2: connect
/**
* Returns routes to connect to the given application.
*
* @param Application $app An Application instance
*
* @return ControllerCollection A ControllerCollection instance
*/
public function connect(Application $app)
{
/** @var ControllerCollection $controllers */
$controllers = $app['controllers_factory'];
$controllers->get('/', function () use($app) {
$keys = $app->keys();
sort($keys);
$doc = array();
foreach ($keys as $key) {
try {
$val = $app[$key];
if (is_scalar($val)) {
$doc[$key] = array('Scalar', var_export($val, true));
} elseif (is_array($val)) {
$doc[$key] = array('Array', count($val));
} elseif (is_object($val)) {
$doc[$key] = array('Object', get_class($val));
} else {
}
} catch (\Exception $e) {
$doc[$key] = array('Exception', $e->getMessage());
}
}
ob_start();
require __DIR__ . "/../../../templates/containerdoc.html";
return ob_get_clean();
});
return $controllers;
}
示例3: assertRequiredKeysExist
/**
* @param Application $app
*
* @throws \RuntimeException
*
* @return void
*/
protected function assertRequiredKeysExist(Application $app)
{
$required = ['path.base'];
$missingKeys = array_diff($required, $app->keys());
if (false === empty($missingKeys)) {
$message = 'Missing required config parameters (' . implode(', ', $missingKeys) . ')';
throw new \RuntimeException($message);
}
}
示例4: canResolve
public function canResolve($name)
{
return in_array($name, $this->app->keys());
}