Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    bug Encapsulated Plugins

    Maybe I am misunderstanding.

    I thought that I could simply reproduce the admin structure in the plugin package. So, I could put extra_functions in

    /zc_plugins/package/version1/admin/functions/extra_functions

    and they would get loaded. This does not happen.

    Here's the relevant code from application_bootstrap.php

    This does not work for functions

    Code:
    $fs = FileSystem::getInstance();
    $fs->setInstalledPlugins($installedPlugins);
    $fs->loadFilesFromPluginsDirectory($installedPlugins, 'admin/includes/extra_configures', '~^[^\._].*\.php$~i');
    $fs->loadFilesFromPluginsDirectory($installedPlugins, 'admin/includes/extra_datafiles', '~^[^\._].*\.php$~i');
    If I do this then it works for functions

    Code:
    $fs = FileSystem::getInstance();
    $fs->setInstalledPlugins($installedPlugins);
    $fs->loadFilesFromPluginsDirectory($installedPlugins, 'admin/includes/extra_configures', '~^[^\._].*\.php$~i');
    $fs->loadFilesFromPluginsDirectory($installedPlugins, 'admin/includes/extra_datafiles', '~^[^\._].*\.php$~i');
    $fs->loadFilesFromPluginsDirectory($installedPlugins, 'admin/includes/functions/extra_functions', '~^[^\._].*\.php$~i');
    I am reluctant to do a PR because I don't really know the bigger picture here. But am happy to do so if required.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Encapsulated Plugins

    So, I overcame that "issue" by doing a check for a function that I expected would be relatively "constant"/remain and if it was not present then to load the associated extra_functions file using the associated relative path to load it from this plugin, but... I see the "preferred" fix as placing the function into a class that is used/called by the code instead of being a "global" function loaded for all to access...

    That said, it appears that the documentation specifically omits discussion of admin/includes/functions, though that possibly also is because it is following what has been designed not necessarily what is desired... (https://docs.zen-cart.com/dev/plugin...ory_structure/) That said also though, there is no "warning" about conversion concerns for those that use the admin's extra_functions folder... (https://docs.zen-cart.com/dev/plugin...ns/converting/)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

    Default Re: Encapsulated Plugins

    considering we are within an encapsulated plugin, what is the downside to putting any needed functions into the extra_datafiles directory?
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  4. #4
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Encapsulated Plugins

    Hmm, well, it is easy enough to sidestep and find some way to make the code work. It may be that there is a "preferred" way to do this.

    Conceptually, the idea seems to be that the structure and functionality in the plugin admin directory is the same as that in the main admin directory. That is a simple and easy concept to understand. If the functionality was different in the two directories - as it is currently - I would say that is sub-optimal.

    Whether or not it is better to use class methods or functions is a discussion that goes on forever and isn't relevant here. If the architecture forces one to go the class route in the plugin admin, then are we moving that way in the 'real' admin. If we are not then there is an inconsistency that is a bigger problem than "class or function". The reason that it is a bigger problem is that it takes a lot more knowledge of the architecture to explain it than it does to explain 'we only use class methods' . You have to say something like " we normally allow functions but there are some cases in which we don't and you have to look those up or know them from experience". My vote is for architectural consistency.

  5. #5
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

    Default Re: Encapsulated Plugins

    hmm... the discussion is not really about class v function... if it were, i am so much more a fan of classes, which can be extended, than functions, which seems to be more of the ZC way of doing things. but as you say, this is not what this discussion is about...

    the question is whether the inclusion of functions in the extra_datafiles (or extra_configures) directory represents a problem or not....

    i agree with you that, ideally, everything should be consistent.

    i know that for my clients, when i do modifications that include extra functions, i put them all in one file in the extra_datafiles directory. so at least i am being consistent!
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  6. #6
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,622
    Plugin Contributions
    123

    Default Re: Encapsulated Plugins

    This might be a bug - I'm not sure. Would you please open an issue on Github with repro instructions? Thanks.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  7. #7
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Encapsulated Plugins

    Thanks Scott, done.

 

 

Similar Threads

  1. v157 encapsulated plugins require question....
    By carlwhat in forum All Other Contributions/Addons
    Replies: 19
    Last Post: 13 Oct 2020, 12:22 AM
  2. v151 Downloading of plugins
    By charles121 in forum Installing on a Linux/Unix Server
    Replies: 5
    Last Post: 22 Oct 2013, 02:01 AM
  3. v150 V1.5.0 and plugins
    By dkhoward in forum General Questions
    Replies: 3
    Last Post: 3 Jul 2012, 12:40 PM
  4. installing plugins
    By maraud in forum General Questions
    Replies: 0
    Last Post: 7 Oct 2007, 03:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR