Re: PHP to a COM object




"Alex" <d_keyoke@xxxxxxxxxxx> wrote in message
news:473b3f32$0$29354$426a74cc@xxxxxxxxxxxxxxx

"Alex" <d_keyoke@xxxxxxxxxxx> wrote in message
news:473b3bee$0$30024$426a74cc@xxxxxxxxxxxxxxx
"Steve" <no.one@xxxxxxxxxxx> wrote in message
news:odG_i.89$qJ1.84@xxxxxxxxxxxxxxx
It's from a software vendor. I meant to say that I have doc with the
object, but all the examples of object usage are in VB, which I have
long forgotten. They use lists, for example all around the place, and I
don't remember how to translate this to PHP :)

so, you know the object's interfaces...just not how to code it in php?
same way as any other object...

$o->interface;
$o->interface(param);

etc.

am i missing something?

I'm pretty sure you're missing a lot less than I do :)

But it's getting better. I replaced "new COM()" by com_load() and now I
can use com_print_typeinfo which returns all the innards of the object. I
don't really know why com_load works better, but it is the case.

I also got to access one of the lists in the object. $....->item($i) .
I'm not sure whether it's a special syntax instead of item[$i] or those
item()s are really functions.

So things are getting better :)


However, my next blocking point is something called a factory. It is a
property of my COM object that is itself an ever-existing instance of a
class containing other objects. I think it is instanciated automatically
by the COM server when I create the object.

Everytime I put its name in my code ( $a =$obj->Factory; nothing more ),
Apache bombs with no explanation.

I have put the memory limit for PHP to 128M just to see but it doesnt
change anything.

Oh there's something I just realized.

This "factory" object is an instance of a class called Factory. But the
doc also makes mention of something called an interface (IFactory) who has
the same methods/Properties of the class. When I do a com_print_typeinfo
on the Factory, I get almost nothing :
class Factory { /* GUID={F4E856D4-FCD7-11D4-9D8A-0001029DEAF5} */
}When I do it on the interface, I get all my object's properties.

There HAS to be a difference :)

a difference, yes. something that will make your code quit bombing and still
get the Factory functionality...probably not. all an interface (IFactory in
this case) is, is a contract...a definition of what *all usable* objects
that *implement* that interface will provide a caller, i.e. your php code.
make sense? IFactory will provide you no other functionality than that.
here's an example in vb.

public interface iFactory
public property foo as integer
end interface

public class sawMill
implements iFactory
public property get foo() implements iFactory.foo
get
return 666
end get
set (byval value as integer)
# do nothing...however, set is *required*
# because iFactory is read/write
end property
public function saw()
debug.print "sawing..."
end function
end class

public class brewery
implements iFactory
private myFoo as integer
public property get foo() implements iFactory.foo
get
return myFoo
end get
set (byval value as integer)
myFoo = value
end property
public function brew()
debug.print "brewing " & myFoo
end function
end class

in the above, both completely unrelated classes (sawMill and brewery) have
iFactory.foo as part of their definition. how they implement them is
different, but each must have a read and write foo.

if i simply say:

private myFactory as iFactory

and then try:

myFactory.foo()

it will do nothing. myFactory is an interface that has no working parts.
however, if i do:

private myFactory as iFactory = new brewery
myFactory.foo = 15

i'll get somewhere. notice that the above works whether or not i set
myFactory to new brewery OR sawMill. both have a foo interface. however, if
i continue the above code with:

myFactory.saw()

it'll blow up. both saw and brew are specific interfaces defined by each
class respectively...not by iFactory. let's say that myFactory is set
somewhere unbeknownst to me, how would i take specific action?

public function factoryToString(byval factory as iFactory, byval fooValue as
integer)
factory.foo = fooValue
if typeof factory is sawMill then
factory.saw()
end if
if typeof factory is brewery then
factory.brew()
end if
end function

anyway...i think i got off track, but does that help you know that you're
going to have to get at an actual Factory object in the list...which doesn't
solve your memory problem?


.



Relevant Pages

  • Re: PHP to a COM object
    ... get the Factory functionality...probably not. ... that *implement* that interface will provide a caller, ... IFactory will provide you no other functionality than that. ... myFactory is an interface that has no working parts. ...
    (comp.lang.php)
  • Re: PHP to a COM object
    ... get the Factory functionality...probably not. ... that *implement* that interface will provide a caller, ... IFactory will provide you no other functionality than that. ... myFactory is an interface that has no working parts. ...
    (comp.lang.php)
  • Re: Dynamic inheritance
    ... >I've been reading the Factory and Abstract Factory patterns - and finding ... It seems the problem boils down to where/when to instantiate ... We have an interface named DeviceFactory. ... >Since most devices would be Cisco devices the 'cisco device' subclass would ...
    (comp.object)
  • Re: Dynamic inheritance
    ... >I've been reading the Factory and Abstract Factory patterns - and finding ... It seems the problem boils down to where/when to instantiate ... We have an interface named DeviceFactory. ... >Since most devices would be Cisco devices the 'cisco device' subclass would ...
    (comp.programming)
  • Re: Design Question
    ... You could advocate that all public methods should be declared in an interface, such that you would have no concrete class that did not implement at least one interface. ... You will have to add new getters and setters to the interface just as you would to the class, and factory method signatures will change just like constructor signatures would. ... In the approach I was advocating, the Record class would have no knowledge of persistence. ...
    (comp.lang.java.programmer)