L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 12, 2008, 10:52:23 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Tranferring data between modules
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Tranferring data between modules  (Read 426 times)
0 Members and 1 Guest are viewing this topic.
onekman
Freshman
*
Offline Offline

Posts: 8


Tranferring data between modules
« on: April 23, 2008, 10:04:30 AM »

Since I'm not the world biggest PHP genious, I need help with following :

I got a own developed class, let's call it ClassA. From this class I set a Flag(true/false), and I need this value to be accessable from ClassB.

How is it doable in a propper way ?

regards
1k
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1061


Re: Tranferring data between modules
« Reply #1 on: April 23, 2008, 11:10:49 AM »

You have to register a link in the Bot class, either directly with a line like below in 0.4
Code:
$classvar = new ClassA(&$bot);
$bot -> linktoa = &$classvar;

class ClassA {}
Then you can simple do $this -> bot -> linktoa -> variablename to access the field.

In SVN we got a dedicated function to register those links.
Logged
Glarawyn
BeBot Developer
Champion
********
Offline Offline

Posts: 399



Re: Tranferring data between modules
« Reply #2 on: April 23, 2008, 05:25:25 PM »

You could also use the settings interface if that makes sense for you.

See the BeBot Developer's Handbook
Logged
onekman
Freshman
*
Offline Offline

Posts: 8


Re: Tranferring data between modules
« Reply #3 on: April 24, 2008, 09:49:54 AM »

Alreadythere : You wrote I had to register a link in the Bot class. When you says Botclass you mean the class I made or in the Bot main module ?

Logged
Temar
BeBot Developer
Grandmaster
********
Online Online

Gender: Male
Posts: 783



WWW
Re: Tranferring data between modules
« Reply #4 on: April 24, 2008, 10:03:47 AM »

put

Code:
$bot -> linktoa = &$classvar;

renameing linktoa to wateva u want
and classvar to the class name

and put this in your module before the class so its outside the class but after the line

Code:
$classvar = new ClassA(&$bot);

then u can call function in the class from other classes useing $this -> bot -> linktoa
Logged
Blueeagle
Omnipotent
BeBot Developer
Expert
********
Offline Offline

Gender: Male
Posts: 313



Re: Tranferring data between modules
« Reply #5 on: May 17, 2008, 11:52:07 AM »

It is my opinion that values that more than one module need access to should have this stored in a core module and export the value via the regular api $this->bot->core('module')

The prefered method is to use settings or preferences. If the flag is of a global nature it should use settings and if it's a flag that's set on a per user basis it should use a preference.

You can create your own database table to hold the value ofcourse, but the framework for settings and preferences are in place so we think they should be used.
Logged

The only problem that can't be solved by adding another wrapper is having too many wrappers.
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Coding and development discussion > Topic: Tranferring data between modules
« previous next »
 
Jump to:  

Recent
Bossloot for 5.2
by Brac
[Today at 04:45:17 PM]

!security Levels
by Nytridr
[Today at 02:00:16 PM]

Ported Modules
by Jiheld
[Today at 09:00:13 AM]

raid/point system suggest...
by Temar
[October 11, 2008, 11:45:40 PM]

!timers suggestions: alts...
by Alreadythere
[October 11, 2008, 03:19:46 PM]

!server does not work
by Alreadythere
[October 11, 2008, 06:54:38 AM]

TWC
by clashbot
[October 10, 2008, 08:52:57 AM]

Using Bebot in AoC Raid c...
by IKShadow
[October 09, 2008, 02:38:50 PM]

!items database
by cthulhu
[October 09, 2008, 08:00:27 AM]

File upload issue
by GBH
[October 08, 2008, 10:33:40 AM]
Stats
Members
Total Members: 988
Latest: Talmahera
Stats
Total Posts: 10808
Total Topics: 1458
Online Today: 15
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 2
Guests: 16
Total: 18
Zeephonz
Temar

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.63 seconds with 28 queries. (Pretty URLs adds 0.16s, 4q)
Loading...