Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit called object before call it #796

Open
visonforcoding opened this issue Oct 9, 2021 · 0 comments
Open

edit called object before call it #796

visonforcoding opened this issue Oct 9, 2021 · 0 comments
Labels

Comments

@visonforcoding
Copy link

visonforcoding commented Oct 9, 2021

I use php-di make my framework , and i integration the Ray.Aop to get aop feature.

bose the php-di and ray.aop need call the function or method in the end.

the ray.aop produce new php souce code ,then call it.

so i use php-di call the new code.

code like

                $bind = (new Bind())->bind($handler[0], $this->container->get('pointCut'));
                if ($bind->getBindings()) {
                    $compiler = new Weaver($bind, TMP_DIR);
                    $handler[0] = $compiler->weave($handler[0]);
                }
              // ray.aop need set bindings,but i don`t want edit the ray.aop source code to inject property
                $instance = $this->container->get($handler[0]);
                $instance->bindings = $bind->getBindings();
                $body = call_user_func_array([$instance, $handler[1]], [$vars]);  // so i get object use php-di container,and call it use call_user_func_array
//                $body = $this->container->call($handler, [$vars]);
                if ($body instanceof ServerResponse) {
                    $response = $body;
                }

it seem work!
but I don't know whether there are any problems.
and is there any better way?

@mnapoli mnapoli added the support label Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants