joomla-projects / webservices

Webservices working group repository
GNU General Public License v2.0
16 stars 9 forks source link

Get component working and rework the ConfigurationHelper #20

Closed wilsonge closed 9 years ago

wilsonge commented 9 years ago

I haven't tested everything fully but I think this should get the basis of the component working.

Note that the code used to get the component working with the app at best should be described as hacky and it needs a COMPLETE REWORK really. However I think it does work so we can actually run tests and stuff

Note that the webservice table is still created in the CMS however it is UNUSED - it will use the one you need to set up as part of the application.

To install the component simply change the path in components/admin/webservices.php of the $applicationPath variable to point to the root of your webservices app and then zip everything up inside the GIT_ROOT/components directory and install through Joomla as usual

HermanPeeren commented 9 years ago

OK I see, you are right! The properties are added in JTable, by getting the database columns with getFields() (and the getters and setters in the deprecated JObject). Putting them explicitly there doesn't save the roundtrip to the db, so indeed, it is no use to declare those variables explicitly as long as we use JTable.

It is probably more a matter that I'm used to making things as explicit as possible (and in Doctrine ORM db-schemas are generated by the mapping, on one spot for all supported databases, not this reversed order we use in Joomla and Nooku).

An other example of making things explicit: I always put all used references to other classes in a use clause on top (and then don't use the FQN in the code itself); in that way I can easily see what the dependencies are and namespaces can be easily changed if necessary, without going through the rest of the code. In your index.php for instance I would have: use Joomla\Webservices\Service\ConfigurationProvider on top and then registerServiceProvider(new ConfigurationProvider) in the code. Dependencies are the sauce of the spaghetti-code. I also have some concerns about the use of that service container and even put some question marks at some autoloading practices. Convenient, but so was global $mainframe...

wilsonge commented 9 years ago

I deprecated JObject in 3.4 partly for that reason :P Long term (read Joomla 4) I expect we'll end up with explicit magic getters and setters in models for the properties of the objects as similar thing to what happens in FOF 3

FWIW in this specific use case we need to remove JTable from this component anyhow long term because it's really designed to take a JDatabaseDriver object and I'm forcing a DatabaseDriver object into it. @chrisdavenport just wanted a functional component so that people could continue to incrementally improve stuff :) - which is what this PR does

HermanPeeren commented 9 years ago

O yeah, Michael mentioning PHP version: this webservices implementation is for J! 3.6 and should unfortunately be >=PHP5.3.10, so no traits: https://github.com/joomla-projects/webservices/blob/develop/src/Application.php#L39

Which reminds me of a trait being used in FlySystem (for their plugins), so in order to backport that to J!3.x I have to get rid of that too... :-(

fastslack commented 9 years ago

@wilsonge do you have any small explanation of how to test it? I'm excited to try this great job

wilsonge commented 9 years ago

This is just a hack together of the existing red component. If you have used that - just try and use this the same way. To be honest I think the important thing is you can install/uninstall the XML files on the server and create your own dynamically

fastslack commented 9 years ago

@wilsonge yes, i ask because when i updated and applied your patch i receive this:

Warning: require_once(/vendor/autoload.php): failed to open stream: No such file or directory in /home/fastslack/mtwProjects/webservices/component/admin/webservices.php on line 14

It looks like I'm skipping a step, maybe related with composer

wilsonge commented 9 years ago

Did you follow the step about changing the path to the application in the last paragraph of the main Pull Request?

To install the component simply change the path in components/admin/webservices.php of the $applicationPath variable to point to the root of your webservices app and then zip everything up inside the GIT_ROOT/components directory and install through Joomla as usual
fastslack commented 9 years ago

Seems not, where i can found it?

wilsonge commented 9 years ago

In the main description of the Pull Request. I also have edited it into my description above. Basically you need to change the variable $applicationPath in components/admin/webservices.php to point to your webservices application

fastslack commented 9 years ago

@test ok, created a new site webservice for categories, install ok. https://github.com/wilsonge/webservices/pull/1

Btw, i created a script to create webservices xml fields reading db table directly:

https://github.com/fastslack/joomla-cli-tools/tree/master/CreateWebservicesXML

I still have not tried anything related about request to plugin.