mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-15 20:05:13 +02:00
[pitboss/grind] deferred session-0003 (20260522T043516Z-29b8)
This commit is contained in:
parent
ebe3a4fca0
commit
987fc1d89f
8 changed files with 539 additions and 19 deletions
|
|
@ -19,8 +19,8 @@ use crate::symbol::Lang;
|
|||
use tree_sitter::Node;
|
||||
|
||||
use super::php_routes::{
|
||||
bind_php_path_params, find_php_function, first_php_string_arg, iter_php_attributes,
|
||||
methods_named_arg, php_formal_names, source_imports_symfony,
|
||||
bind_php_path_params, collect_php_middleware, find_php_function, first_php_string_arg,
|
||||
iter_php_attributes, methods_named_arg, php_formal_names, source_imports_symfony,
|
||||
};
|
||||
|
||||
pub struct PhpSymfonyAdapter;
|
||||
|
|
@ -84,6 +84,7 @@ impl FrameworkAdapter for PhpSymfonyAdapter {
|
|||
let path = join_route_path(&class_prefix, &method_path);
|
||||
let formals = php_formal_names(func_node, file_bytes);
|
||||
let request_params = bind_php_path_params(&formals, &path);
|
||||
let middleware = collect_php_middleware(ast, file_bytes);
|
||||
|
||||
Some(FrameworkBinding {
|
||||
adapter: ADAPTER_NAME.to_owned(),
|
||||
|
|
@ -94,7 +95,7 @@ impl FrameworkAdapter for PhpSymfonyAdapter {
|
|||
}),
|
||||
request_params,
|
||||
response_writer: None,
|
||||
middleware: Vec::new(),
|
||||
middleware,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -161,6 +162,23 @@ mod tests {
|
|||
assert_eq!(route.path, "/x");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn populates_middleware_from_is_granted_attribute() {
|
||||
let src: &[u8] = b"<?php\nuse Symfony\\Component\\Routing\\Annotation\\Route;\nclass C {\n #[Route('/x')]\n #[IsGranted('ROLE_USER')]\n public function show() { return 1; }\n}\n";
|
||||
let tree = parse(src);
|
||||
let binding = PhpSymfonyAdapter
|
||||
.detect(&summary("show"), tree.root_node(), src)
|
||||
.expect("binding");
|
||||
assert!(
|
||||
binding
|
||||
.middleware
|
||||
.iter()
|
||||
.any(|m| m.name == "#[IsGranted]"),
|
||||
"got {:?}",
|
||||
binding.middleware
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skips_when_symfony_not_imported() {
|
||||
let src: &[u8] = b"<?php\n#[Route('/x')]\nfunction f() { return 1; }\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue