Zend Framework

Impossible to set same method name in two differents services

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7.0
  • Fix Version/s: 1.7.2
  • Component/s: Zend_Amf
  • Labels:
    None

Description

It is impossible to set same method name in two different services:
If I set getMenu in ServiceA and in ServiceB I can't call ServiceA.getMenu or ServiceB.getMenu.

The Zend_Amf_Server_Exception message is 'Duplicate method registered: getMenu'

My gateway.php

$server = new Zend_Amf_Server();
$server->setProduction(true);

$server->addDirectory(dirname(__FILE__) .'/services/');
$server->setClass('ServiceA');
$server->setClass('ServiceB');

echo $server->handle();

My two classes:
ServiceA.php

<?php
class ServiceA {	
	
    function __construct() {        
        //Construction...
    }
    
    /**
     * @return string
     */
    public function getMenu( )
    {
        return 'myMenuA';
    }
}
?>

ServiceB.php

<?php
class ServiceB {	
	
    function __construct() {        
        //Construction...
    }
    
    /**
     * @return string
     */
    public function getMenu( )
    {
        return 'myMenuB';
    }
}
?>

Activity

Hide
Wade Arnold added a comment -

I have the issue reproduce and working on a solution. Thanks for submitting the bug.

Show
Wade Arnold added a comment - I have the issue reproduce and working on a solution. Thanks for submitting the bug.
Hide
Wade Arnold added a comment -

Update to add a default namespace based on the class name so that there are no long conflict issues with reflection of classes with the same method names.

Show
Wade Arnold added a comment - Update to add a default namespace based on the class name so that there are no long conflict issues with reflection of classes with the same method names.
Hide
Francisco Herrero added a comment -

Hello!, sorry about my english but i'm spanish and my english in poor.

I explain my problem.. i have a project, that project have 3 classes: OtherProductDelegate.php, wineProductDelegate.php and ProductDelegate.php. The last class is a parent class, otherproduct and wineproduct are children from product.

class ProductDelegate
class OtherProductDelegate extends ProductDelegate
class WineProductDelegate extends ProductDelegate

ProductDelegate has a method function InsertProduct( $productVO ), and the derivated classes have the methods:

WineProductDelegate
function InsertWineProduct( $wineproductVO )
{
parent::InsertProduct( $wineproductVO );
}

OtherProductDelegate
function InsertOtherProduct( $otherproductVO )
{
parent::InsertProduct( $otherproductVO );
}

When i had only derived class all work fine, but when i created the second derivated class i have this error:

Fatal error: Uncaught exception 'Zend_Amf_Server_Exception' with message 'Duplicate method registered: InsertProduct' in C:\AppServ\www\webElMananServer\zend_framework\library\Zend\Amf\Server.php:543 Stack trace: #0 C:\AppServ\www\webElMananServer\zend_framework\library\Zend\Amf\Server.php(447): Zend_Amf_Server->_buildDispatchTable() #1 C:\AppServ\www\webElMananServer\index.php(17): Zend_Amf_Server->setClass('OtherProductDel...') #2 {main} thrown in C:\AppServ\www\webElMananServer\zend_framework\library\Zend\Amf\Server.php on line 543

I have read that this problem is resolved, i don't know if i have the same problem.

I hope you can help me, please.

Show
Francisco Herrero added a comment - Hello!, sorry about my english but i'm spanish and my english in poor. I explain my problem.. i have a project, that project have 3 classes: OtherProductDelegate.php, wineProductDelegate.php and ProductDelegate.php. The last class is a parent class, otherproduct and wineproduct are children from product. class ProductDelegate class OtherProductDelegate extends ProductDelegate class WineProductDelegate extends ProductDelegate ProductDelegate has a method function InsertProduct( $productVO ), and the derivated classes have the methods: WineProductDelegate function InsertWineProduct( $wineproductVO ) { parent::InsertProduct( $wineproductVO ); } OtherProductDelegate function InsertOtherProduct( $otherproductVO ) { parent::InsertProduct( $otherproductVO ); } When i had only derived class all work fine, but when i created the second derivated class i have this error: Fatal error: Uncaught exception 'Zend_Amf_Server_Exception' with message 'Duplicate method registered: InsertProduct' in C:\AppServ\www\webElMananServer\zend_framework\library\Zend\Amf\Server.php:543 Stack trace: #0 C:\AppServ\www\webElMananServer\zend_framework\library\Zend\Amf\Server.php(447): Zend_Amf_Server->_buildDispatchTable() #1 C:\AppServ\www\webElMananServer\index.php(17): Zend_Amf_Server->setClass('OtherProductDel...') #2 {main} thrown in C:\AppServ\www\webElMananServer\zend_framework\library\Zend\Amf\Server.php on line 543 I have read that this problem is resolved, i don't know if i have the same problem. I hope you can help me, please.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: