Skip to content

Conversation

@denise-kao
Copy link
Collaborator

@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
Collaborator Author

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

@denise-kao
Copy link
Collaborator Author

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

@WalterWoshid
Copy link
Contributor

Hi @denise-kao. I had no time to maintain this project, since I am very busy currently with other work related stuff. Would you like to be added as a maintainer for this project?

@denise-kao
Copy link
Collaborator Author

Hi @WalterWoshid
Sure, I would like to be a maintainer for this project :)

@denise-kao denise-kao changed the base branch from master to develop April 30, 2025 08:55
@denise-kao denise-kao merged commit a2ac5ab into okapi-web:develop Apr 30, 2025
@denise-kao denise-kao added the bug 🐞 Something isn't working label Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants