Hii there,
I’m trying to load all traits in a directory into my class.
My class currently looks like this:
<?php
namespace App\View;
class Shortcode {
// Load all shortcodes
use Shortcode\TestShortcode;
// other code
}
And my Shortcode/TestShortcode.php
looks like this:
<?php
namespace App\View\Shortcode;
trait TestShortcode {
protected static function renderTest(array $params){
return "hello world!";
}
}
Now I want it to dynamically load all the traits that are in the View/Shortcode
directory instead of having to use the use Shortcode\...Shortcode;
all the time.
I am not able to use __construct()
for this, as I don’t use the new Shortcode()
call (instead I use the Shortcode::method()
way).
Any ideas?