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

Add class-level attributes on woven files #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

denise-kao
Copy link
Contributor

@denise-kao denise-kao commented Nov 1, 2024

The class-level attributes are missing when building woven files.

I have a class like this

<?php
namespace App\Http\Controllers;

use Aspects\MyClassAttribute;
use Aspects\MyMethodAttribute;

#[MyClassAttribute]
class TestController extends Controller
{
    #[MyMethodAttribute]
    public function test(Request $request)
    {
        .....
    }
}

I expect the woven file is like this, so I can get get class-level attributes correctly.

<?php
namespace App\Http\Controllers;

use Okapi\Aop\Core\JoinPoint\JoinPointInjector;
use Okapi\CodeTransformer\Core\DI;

#[\Aspects\MyClassAttribute]
class TestController extends TestController__AopProxied
{
	private static array $__joinPoints = ['method' => ['test' => ['Aspects\MyMethodAttribute::aroundMethod']]];

	#[\Aspects\MyMethodAttribute]
	public function test(\Illuminate\Http\Request $request)
	{
		return call_user_func_array(self::$__joinPoints['method']['test'], [$this, ['request' => $request]]);
	}
}

DI::get(JoinPointInjector::class)->injectJoinPoints(TestController::class);

But it is created like this (class-level attribute is missing)

<?php
namespace App\Http\Controllers;

use Okapi\Aop\Core\JoinPoint\JoinPointInjector;
use Okapi\CodeTransformer\Core\DI;

class TestController extends TestController__AopProxied
{
	private static array $__joinPoints = ['method' => ['test' => ['Aspects\MyMethodAttribute::aroundMethod']]];

	#[\Aspects\MyMethodAttribute]
	public function test(\Illuminate\Http\Request $request)
	{
		return call_user_func_array(self::$__joinPoints['method']['test'], [$this, ['request' => $request]]);
	}
}

DI::get(JoinPointInjector::class)->injectJoinPoints(TestController::class);

@denise-kao
Copy link
Contributor Author

Hi @WalterWoshid,
need you to have a look with this. Thanks :)

@denise-kao
Copy link
Contributor Author

Hi @WalterWoshid
Do you have any comment about this PR ? Or just no time to process ?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant