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

Missing imports when generating modeldoc for modules #19

Open
marcovtwout opened this issue Oct 15, 2014 · 5 comments
Open

Missing imports when generating modeldoc for modules #19

marcovtwout opened this issue Oct 15, 2014 · 5 comments

Comments

@marcovtwout
Copy link
Contributor

I am trying to generate modeldocs for models contained in a Yii module. One of the modules' models points to a behavior class, also contained in the module. Module components are typically imported in the module's init() function.

When I try to run modeldoc with path 'application.modules.example.models' I get the following error:

include(ExampleModuleBehavior.php): failed to open stream: No such file or directory

ModelDocCode.php line 168 creates a new model, which attempts to load the behavior.


Do you have a suggestion how to solve the missing imports when generating modeldocs for a module?

@cornernote
Copy link
Owner

You can try putting the import path into your config/main.php, eg:

return array(
    'import' => array(
        '/path/to/ExampleModule/behaviors/*',
    ),
);

@marcovtwout
Copy link
Contributor Author

That works ofcourse, but I was looking for a more generic way to improve this extension. Perhaps you can even consider scanning multiple paths: both application/models and every model folder in modules/?

@cornernote
Copy link
Owner

That won't work because the app would have to scan too many folders. I use composer and there are many things inside there that may or may not be behaviors.

@marcovtwout
Copy link
Contributor Author

What about simply initializing all the application modules?

foreach (Yii::app()->getModules() as $key=> $config) {
    Yii::app()->getModule($key); // initializes module and loads imports
}

@cornernote
Copy link
Owner

I considered it, but decided against it. Now I can't remember why because it seems it should work.

If you do a pull request and I'll test it out later today.

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

No branches or pull requests

2 participants