Results 1 to 10 of 20

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,915
    Plugin Contributions
    13

    Default Re: encapsulated plugins require question....

    Quote Originally Posted by mc12345678 View Post
    Challenge accepted?! :)


    The second link provides functionality that would get you to the point of loading and instantiating an observer class through the use of the auto_loaders type structure. Basically whatever "function" you wanted to be done would be the 'autoType' in the auto_loaders file. Effectively the method called within the InitSystem is 'processAutoLoader' . $var['autoType'] (yes there is some case play, but lets say you wanted to load a class file (such as an observer), then the 'autoType' would be 'class' to load the class, then 'classInstantiate' to initialize the class (calling its __construct method).)

    To "simply" require a file would in fact need some "path" information as discussed above about "finding" where things are currently located so that the associated processAutoLoaderRequire method could pull in the correct file(s).

    For loading a class would likely have the autoloader look something like:
    Code:
    <?php
    if (!defined('IS_ADMIN_FLAG')) {
        die('Illegal Access');
    }
    
    $autoLoadConfig[200][] = [
        'autoType'  => 'class',
        'classPath' => 'observers/',
        'loadFile'  => 'new_observer.php',
        ];
    $autoLoadConfig[200][] = [
        'autoType'  => 'classInstantiate',
        'className' => 'zcObserverNewObserverClass',
        'objectName' => 'myObsVariable',
        'classSession' => false,
        'checkInstantiated' => false,
        ];
    This seems as if it would load an observers class in the admin directory of the plugins section for "this" version of the plugin.

    The last two variables of the classInstantiate section are not required, but at least provide a template for what might be expected in instantiating a class through the plugin controller...
    thank you.

    this works here:

    PHP Code:
    $autoLoadConfig[200][] = [
        
    'autoType'  => 'class',
        
    'classPath' => 'includes/classes/observers/',
        
    'loadFile'  => 'my_bloody_observer.php',
        ]; 
    much appreciated!
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

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

    Default Re: encapsulated plugins require question....

    Quote Originally Posted by carlwhat View Post
    thank you.

    this works here:

    PHP Code:
    $autoLoadConfig[200][] = [
        
    'autoType'  => 'class',
        
    'classPath' => 'includes/classes/observers/',
        
    'loadFile'  => 'my_bloody_observer.php',
        ]; 
    much appreciated!
    Hmmm, because I was going to make a suggestion of a potential alteration to the above path, wanted to ask/confirm that the observer is in fact in the plugin and not installed to the "core" fileset, correct?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,915
    Plugin Contributions
    13

    Default Re: encapsulated plugins require question....

    Quote Originally Posted by mc12345678 View Post
    Hmmm, because I was going to make a suggestion of a potential alteration to the above path, wanted to ask/confirm that the observer is in fact in the plugin and not installed to the "core" fileset, correct?
    correct. yes.

    Code:
    [236] => Auto Type Method - processAutoTypeClass
    [237] => processing class - /var/www/base157/zc_plugins/shipAdmin/1.0.0/admin/includes/classes/observers/my_bloody_observer.php
    [238] => loading class - /var/www/base157/zc_plugins/shipAdmin/1.0.0/admin/includes/classes/observers/my_bloody_observer.php - SUCCESS
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: encapsulated plugins require question....

    Quote Originally Posted by carlwhat View Post
    correct. yes.

    Code:
    [236] => Auto Type Method - processAutoTypeClass
    [237] => processing class - /var/www/base157/zc_plugins/shipAdmin/1.0.0/admin/includes/classes/observers/my_bloody_observer.php
    [238] => loading class - /var/www/base157/zc_plugins/shipAdmin/1.0.0/admin/includes/classes/observers/my_bloody_observer.php - SUCCESS
    Seems like it would be a good idea in the docs to indicate that constants such as DIR_WS_INCLUDES should not be used in plugins when referring to directories such as the classes and/or other "defined" paths...

    Reason? those particular constants are associated with the store and not with the plugins where plugins should be developed to be applicable to "any" store's configuration. Meaning, the path used should be relative to the plugin's directory structure and not the store's directory structure when referencing items within the plugin's folder...

    I was otherwise going to suggest actually using DIR_WS_CLASSES (which I thought was going to be used by the plugin loader path until you made the change identified above and showing the processed path here).

    Btw, in line with DrByte's previous statement about loading a class file, using the above 'class'/'classInstantiate' would allow you to declare a variable name that can be used within your other plugin areas. That variable is the 'objectName'. In this way you don't have to "chase" down the current path for the file being loaded, just load the class as part of your plugin and reference it from within the plugin...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,915
    Plugin Contributions
    13

    Default Re: encapsulated plugins require question....

    Quote Originally Posted by mc12345678 View Post
    Btw, in line with DrByte's previous statement about loading a class file, using the above 'class'/'classInstantiate' would allow you to declare a variable name that can be used within your other plugin areas. That variable is the 'objectName'. In this way you don't have to "chase" down the current path for the file being loaded, just load the class as part of your plugin and reference it from within the plugin...
    interesting. perhaps i will look into it.

    next hurdle to jump over is some javascript files that need to get loaded on the page load. again trying to keep everything within the encapsulated plugin directory. i suppose i could load the contents into the page load as opposed to a reference to the file (which would necessitate being outside of the plugin). but i am open to other ideas.
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: encapsulated plugins require question....

    Quote Originally Posted by carlwhat View Post
    interesting. perhaps i will look into it.

    next hurdle to jump over is some javascript files that need to get loaded on the page load. again trying to keep everything within the encapsulated plugin directory. i suppose i could load the contents into the page load as opposed to a reference to the file (which would necessitate being outside of the plugin). but i am open to other ideas.
    Umm. there's already script to load a plugin's javascript:

    admin/includes/javascript_loader.php Starting at about line 54... Appears that there is "no magic" necessary. Filenaming may be the only "trigger" issue of concern.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,915
    Plugin Contributions
    13

    Default Re: encapsulated plugins require question....

    Quote Originally Posted by mc12345678 View Post
    Umm. there's already script to load a plugin's javascript:

    admin/includes/javascript_loader.php Starting at about line 54... Appears that there is "no magic" necessary. Filenaming may be the only "trigger" issue of concern.
    ok, thanks for this. it seems that i had some difficulty with file names that had multiple words in them. for example, if my filename was bloody.php, includes/javascript/bloody.js would load as well as includes/javascript/bloody_rsvp-min-3.1.0.min.js. if, my filename was bloody_mask.php; i had some difficulty getting the .js files to load.

    could be me.

    but, again, i do appreciate the help. using the ZC file naming for loading javascript works out better here.

    best.
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 

Similar Threads

  1. v150 Security Question - Letting someone else install plugins
    By mrdmorrison in forum General Questions
    Replies: 6
    Last Post: 5 Aug 2012, 03:44 PM
  2. How do I require an account to use my ask a question addon?
    By eric engler in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 2 Mar 2012, 11:05 PM
  3. Require login to browse question
    By ebaobao in forum General Questions
    Replies: 14
    Last Post: 18 Sep 2010, 07:25 PM
  4. Require new registrants to answer secret question?
    By tsav87 in forum Basic Configuration
    Replies: 2
    Last Post: 21 Jul 2010, 05:30 PM
  5. Adding 'When do you require your order?' question
    By helenthemum in forum Customization from the Admin
    Replies: 0
    Last Post: 11 Oct 2007, 10:22 PM

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