Frage

I'm developing on an open source CRM platform call Zurmo. It uses Yii Framework along with RedBean. Im trying to "extend?" or make changes to a function within a particular "module". I want to know if it is possible to create a separate file in which I would be able to change any variables or arrays within the original function.

I am still having trouble defining classes and class functions in an external file. I created a file within accounts/models/ called AccountExtend.php and loaded it thought the AccountsModule.php on line 53 like this:

public function getRootModelNames()
    {
        return array('Account, AccountExtend');
    }

Within the AccountExtend.php file I have this function which is changing the label from the default "Billing Address" to say "Property Address"

class AccountExtend extends Account implements StarredInterface
{
     protected static function translatedAttributeLabels($language)
    {
        $params = LabelUtil::getTranslationParamsForAllModules();
        $paramsForAffiliations = $params;

        return array_merge(OwnedSecurableItem::translatedAttributeLabels($language),
            array(

                'billingAddress'         => Zurmo::t('AccountsModule',      'Property Address',                     array(), null, $language),

            )
        );

    }

So above I merge this array with the class "OwnedSecurableItem" formerly being merged in the extended Account.php and replaced "OwnedSecurableItem" with "AccountExtend" within the Account.php model and did a "merge_diff" php function to overwrite the default label.

Now my question is this, Is this the best way to do this? any tips or advice? My next struggle is trying to extend a function within the Account.php module to say add a custom relational drop down field or to add any other functionality. How can I go about this since these are more complex arrays that contain elements?

War es hilfreich?

Lösung

If a method is public or protected it can be overwritten in the new class, for example:

class Your_New_Class extends Account
{    

    protected static function translatedAttributeLabels($language)
    {

        //Your new logic

    }

}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top