We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

FR: set package path when loading extension settings page

Developer Preview

Low's avatar
Low
407 posts
about 11 years ago
Low's avatar Low

As I understand it, it’s preferable that an add-on doesn’t add its own package path. I’m starting to remove the ee->load->add_package_path(PATH_THIRD.’low_whatevs’) references, but I’m running into an issue there.

In system/expressionengine/controllers/cp/addons_extensions.php, the extension class is loaded and initiated on line #365 thusly:

$OBJ = new $class_name();

However, lots of times, my constructor loads stuff, and at this point, the package path hasn’t been added yet. It’s only loaded when settings_form is called, but the constructor has already fired by then.

Also, the path isn’t added when $OBJ->settings() is called, a few lines down.

So, perhaps change line #365 to this:

$this->load->add_package_path($ext_path, FALSE);

$OBJ = new $class_name();

$settings = method_exists($OBJ, 'settings') ? $OBJ->settings() : array();

$this->load->remove_package_path($ext_path);

…and then change the $OBJ->settings() call in the foreach to $settings.

       
Wes Baker's avatar
Wes Baker
343 posts
about 11 years ago
Wes Baker's avatar Wes Baker

Yeah, I think we’d prefer if you didn’t have to use add_package_path. There’s a few other places where we create a new instance of your Extension, on the Extensions listing page and when saving your extension settings. Are those causing problems as well?

       
Low's avatar
Low
407 posts
about 11 years ago
Low's avatar Low

Yes. Basically, anywhere you instantiate or call any file from the add-on package, the package path should be set. Not doing that is inconsistent.

       
Wes Baker's avatar
Wes Baker
343 posts
about 11 years ago
Wes Baker's avatar Wes Baker

I agree and figured as much, just wanted to double check.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.