After trying around a bit with the ManiaConnect feature, I want to make a suggestion regarding the use of PHP session.
The Problem:
In my projects, I never use PHP sessions to store any data. The reason is, that I mostly work with forum softwares (like vBulletin on mania-community.de), which bring their own session system based on the database.
Currently I am able to use an own session system by deriving the ManiaConnect\Player class and by overwriting the five methods getVariable(), setVariable(), deleteVariable(), logout() and __construct().
The constructor is the problem: I cannot call parent::__construct() to initialize the parent classes, as this would initialize the PHP session. But I still have to call the HTTPClient's constructor... (Using \Maniaplanet\WebServices\HTTPClient::__construct($username, $password); in my class' constructor works fine, but I don't really like the idea of skipping a constructor, as the code may break as soon as the Client's constructor changes.)
The Suggestion:
Introduce a new (protected) method called e.g. initSesstion(), which can be overwritten by any child class to use the own session system, without having to overwrite the constructor.
(You may think about the same for the session_destroy() call in logout().)
[Fixed] Uncouple ManiaConnect from PHP sessions
Moderator: NADEO
Re: [Suggestion] Uncouple ManiaConnect from PHP sessions
I thought about that, but in the end I tought no one would need it. I was wrong 
I can indeed add initSession() and destroySession methods, but the problem is you would need to extend the Client, and then extend again your class to make the equivalent of the Player class.
So I think I'm going to do a system so you can write you're own class and plug it directly on the client to replace the default behaviour, that way you can still use the Player class as is.

I can indeed add initSession() and destroySession methods, but the problem is you would need to extend the Client, and then extend again your class to make the equivalent of the Player class.
So I think I'm going to do a system so you can write you're own class and plug it directly on the client to replace the default behaviour, that way you can still use the Player class as is.
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 

Re: [Suggestion] Uncouple ManiaConnect from PHP sessions
Okay I just comitted that. We use the Dependency Injection design pattern to do that.
First there is a "Persistance" interface which implements the methods we need:
http://code.google.com/p/maniaplanet-ws ... stance.php
Then the Session object which is the default Persistance implementation using the PHP Sessions:
http://code.google.com/p/maniaplanet-ws ... ession.php
And in the Client you have a static setPersistance() method to pass an instance of your own Persistance implementation:
http://code.google.com/p/maniaplanet-ws ... ent.php#48
Note that in the constructor of the Client class, it instanciate the default Session class if no persistance instance was found, so you need to set your own persistance instance before instanciating the Client / Player class !
To sum it up:
We'll probably release a new version of the SDK in one or two weeks. In the meantime, if you want to use that you can checkout the lastest revision of the trunk (and tell me if custom persistance objects work as I didn't test that
)
First there is a "Persistance" interface which implements the methods we need:
http://code.google.com/p/maniaplanet-ws ... stance.php
Then the Session object which is the default Persistance implementation using the PHP Sessions:
http://code.google.com/p/maniaplanet-ws ... ession.php
And in the Client you have a static setPersistance() method to pass an instance of your own Persistance implementation:
http://code.google.com/p/maniaplanet-ws ... ent.php#48
Note that in the constructor of the Client class, it instanciate the default Session class if no persistance instance was found, so you need to set your own persistance instance before instanciating the Client / Player class !
To sum it up:
- Create your own persistant mechanism by implementing the Maniaplanet\WebServices\ManiaConnect\Persistance interface
- Pass an instance of your created class to Maniaplanet\WebServices\ManiaConnect\Client::setPersistance()
- Instanciate the Player class
We'll probably release a new version of the SDK in one or two weeks. In the meantime, if you want to use that you can checkout the lastest revision of the trunk (and tell me if custom persistance objects work as I didn't test that

Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 

Re: [Suggestion] Uncouple ManiaConnect from PHP sessions
Thank you very much for this feature, I took a quick look on this, and it looks very nice so far
I will try to use these new classes in some days, and will report if there are any problems

I will try to use these new classes in some days, and will report if there are any problems

Re: [Suggestion] Uncouple ManiaConnect from PHP sessions
I now had the time to do a little test, and my own implementation of the Persistance interface worked fine 

Re: [Suggestion] Uncouple ManiaConnect from PHP sessions

Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 

Who is online
Users browsing this forum: No registered users and 1 guest