BobRay / MyComponent

Development environment for creating MODX extras
https://bobsguides.com/mycomponent-tutorial.html
23 stars 13 forks source link

Setup-Options not working for me #20

Closed AugmentBLU closed 10 years ago

AugmentBLU commented 10 years ago

Hi Bob,

I've tried to get the setup-options working with MyComponent for a CMP I've already built but no matter what I do it doesn't work.

Many of the CMPs have a setup-options.php file in the root of transport package, does MyComponent follow the same method for this file structure?

Basically my CMP needs some inputs that are sent to the system settings which I want done before the install, I checked the examples but I don't anything similar to that.

Any help would be great.

Thanks!

BobRay commented 10 years ago

Yes, the example project has exactly what you need.

Notice the specification of 'install.options' in the project config file.

Here is the form for interacting with the user: https://github.com/BobRay/MyComponent/blob/master/_build/install.options/user.input.php

The third section of the "install" part of this resolver file shows how to set the system settings:

https://github.com/BobRay/MyComponent/blob/master/_build/resolvers/install.script.php

AugmentBLU commented 10 years ago

Thanks for the prompt reply.

I checked that out, ran the scripts and it creates the all the files expected but when building the transport zip there's no setup-options.php file?

I see the install.options directory with the user.input.php file but don't quite see why the setup-options.php is not being created.

BobRay commented 10 years ago

Make sure that the 'install.options' member in your project config file is not set to an empty string.

the setup-options.php file is a resolver. You can either list it in the 'resolvers' member of the array (though it will have a slightly different name), or you can use the default resolver. The options from the user input form will be available in all the resolvers so you can do it anywhere.

This is probably a better example, because it does exactly what you want in the default resolver: https://github.com/BobRay/MandrillX/blob/master/_build/resolvers/mandrillx.resolver.php

On Wed, Mar 19, 2014 at 1:20 PM, AugmentBLU notifications@github.comwrote:

Thanks for the prompt reply.

I checked that out, ran the scripts and it creates the all the files expected but when building the transport zip there's no setup-options.php file?

I see the install.options directory with the user.input.php file but don't quite see why the setup-options.php is not being created.

Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/20#issuecomment-38080553 .

AugmentBLU commented 10 years ago

Yeah I tried all that and the resolver file is created which I edit to suit my requirements and I build the transport zip. When I go to install it, there's no setup options button or window appearing for the system settings to be input before installing, there's only a continue button and when pressed it just goes on to installing the CMP.

If I manually drop a setup-options.php file in the unzipped package folder I see the settings popup and it goes on to install as I want.

BobRay commented 10 years ago

Do you have this in your build.transport.php file?

if ($hasSetupOptions && !empty($props['install.options'])) { $attr['setup-options'] = array( 'source' => $sources['install_options'] . 'user.input.php', ); }

That's what should be there. If the _build/data/install.options directory exists and the 'install.options' member in the config file is not empty, the _build/data/install.options/user.input.php file should be in the package and its form shown to the user during the install.

On Wed, Mar 19, 2014 at 4:05 PM, AugmentBLU notifications@github.comwrote:

Yeah I tried all that and the resolver file is created which I edit to suit my requirements and I build the transport zip. When I go to install it, there's no setup options button or window appearing for the system settings to be input before installing, there's only a continue button and when pressed it just goes on to installing the CMP.

If I manually drop a setup-options.php file in the unzipped package folder I see the settings popup and it goes on to install as I want.

Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/20#issuecomment-38100095 .

AugmentBLU commented 10 years ago

I have doubled checked the config and the 'install.options' is not empty, I run bootstrap and it creates the install.options directory in the _build root, not _build/data/. Is this the issue perhaps?

The _build folder has the following directories in the root.

config data install.options resolvers utilities

There's 2 files as well, build.config.php and build.transport.php.

The following is in the build.transport.php file as expected.

if ($hasSetupOptions && !empty($props['install.options'])) { $attr['setup-options'] = array( 'source' => $sources['install_options'] . 'user.input.php', ); }

I'm using Revo 2.2.13 if that helps any.

Thanks!

BobRay commented 10 years ago

Try moving the install.options directory and its contents under _build/data. Then run build.

On Wed, Mar 19, 2014 at 4:39 PM, AugmentBLU notifications@github.comwrote:

I have doubled checked the config and the 'install.options' is not empty, I run bootstrap and it creates the install.options directory in the _build root, not _build/data/. Is this the issue perhaps?

The _build folder has the following directories in the root.

config data install.options resolvers utilities

There's 2 files as well, build.config.php and build.transport.php.

The following is in the build.transport.php file as expected.

if ($hasSetupOptions && !empty($props['install.options'])) { $attr['setup-options'] = array( 'source' => $sources['install_options'] . 'user.input.php', ); }

I'm using Revo 2.2.13 if that helps any.

Thanks!

Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/20#issuecomment-38103732 .

AugmentBLU commented 10 years ago

Thanks Bob,

nearly there. I now see the setup options button but in the popup it has mynewcmp-1pl-2/setup-options.php. I checked the manifest and it has 'setup-options' => 'mynewcmp-1pl-2/setup-options.php'` which isn't in the unpacked package.

In my config I have the following 'resolvers' => array( 'setup-options', )

Like I said, nearly there... :D

AugmentBLU commented 10 years ago

I see an error in the output log which I wasn't checking...

xPDOCacheManager->copyFile(): Could not copy file /assets/mycomponents/mynewcmp/_build/install.options/user.input.php to /core/packages/mynewcmp-1pl-2/setup-options.php

BobRay commented 10 years ago

I think I went the wrong way on the fix. Instead of moving the file, we should have just changed this line in build.transport.php.

$hasSetupOptions = is_dir($sources['data'] . 'install.options');

to

$hasSetupOptions = is_dir($sources['build'] . 'install.options');

and leave the user input file under _build/install.options/ where it was to begin with.

On Thu, Mar 20, 2014 at 5:05 AM, AugmentBLU notifications@github.comwrote:

I see an error in the output log which I wasn't checking...

xPDOCacheManager->copyFile(): Could not copy file /assets/mycomponents/mynewcmp/_build/install.options/user.input.php to /core/packages/mynewcmp-1pl-2//setup-options.php

Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/20#issuecomment-38146394 .