-
Notifications
You must be signed in to change notification settings - Fork 1
File Structure
Q edited this page Aug 17, 2020
·
20 revisions
The location and structure of certain files are very important to how Willow works, so understand the lookup process is equally important.
As Willow contexts can be extended, it is also required to allow plugins to extend the configuration lookup locations, this can be achieved by adding the lookup parameters to the context extension callback, as shown in the following example:
public static function __run() {
// check for willow ##
if( ! class_exists( 'q_willow' ) ){ return false; }
$class = new \ReflectionClass( __CLASS__ );
$methods = $class->getMethods( \ReflectionMethod::IS_PUBLIC );
foreach( $methods as $key ){ $public_methods[] = $key->name; } // match format returned by get_class_methods() ##
// register new class methods ##
\add_action( 'after_setup_theme', function() use ( $public_methods ) {
\q\willow\context\extend::register([
'context' => 'user',#str_replace( __NAMESPACE__.'\\', '', __CLASS__ ),
'lookup' => \q_user::get_plugin_path( 'library/view/context/' ), // allow for extended .willow lookups ##
'class' => __CLASS__,
'methods' => $public_methods // public only
]);
}, 2 );
}
In this example, we are telling Willow to also look in the path library/view/context/ when running checks for willow configuration files.