Solved: addLocation for addons


#1

Since I am an absolute newbie on ATK4 I might be wrong about this. If so, please correct me.

I installed (tried to install …) the TimePicker add-on. (The first application I have to develop needs a timepicker, that’s why). After installation, I added the location for addons, but to no avail. Whatever I added, I received this attempted search path:

attempted_locations: 0: phar://…/agiletoolkit-sandbox.phar/addons/timepicker/lib/Form/Field/TimePicker.php

Now I found numerous directions on how to add a path, and they were all a variation on this:

$this->api->pathfinder->addLocation(’.’,array(
‘addons’=>array(‘my_addons’,’.’),
));
)->setParent($this->pathfinder->base_location);

Note the first parameter in addLocation(). I think this is the reason for no paths being added.

This is what works:

   $this->api->pathfinder->addLocation(array(
        'addons'=> array('addons', 'vendor'),
    )) ->setBasePath($this->pathfinder->base_location->getPath() .'/..')

Now the addons are expected here:

agiletoolkit \
             |- addons
             |- admin  

This is when the standard installation is downloaded and placed in the webroot. Obviously when omitting the ‘/…’ from setBasePath the addons will be expected in admin/addons. That is no big deal.

This method of adding a location came from one of Romans’ video tutorials while he was adding a different add-in: https://youtu.be/mJY-xUTeOKw

I have looked at the source code of addLocation(), and it seems that the function of the parameters has changed since version 4.2.

Anyway, this worked for me. I hope it helps someone else.

jlinkels


#2

Hi. Wanted to add the following two links here:

http://sink.agiletoolkit.org/js/timepicker

which demonstrate the integration with time picker.

Thanks for sharing!