Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding AbstractResourceTransformer->transformAttributesObject() #8

Closed
dimvic opened this issue Feb 19, 2016 · 3 comments
Closed

Comments

@dimvic
Copy link
Contributor

dimvic commented Feb 19, 2016

Is there a reason why the methods in AbstractResourceTransformer are private? It causes some problems overriding them, for example you can't override transformAttributesObject() because it is being called elsewhere in the same scope and you need to override those private methods as well.

For the record, what I want to do is extend the class and have this:

public function getAttributes($domainObject)
    {
        $ret = [];
        foreach ($domainObject->attributes as $k=>$v) {
            if ($k!=$domainObject->primaryKey()) {
                $ret[$k] = function(CActiveRecord $domainObject, $attr) { return $domainObject->{$attr}; };
            }
        }
        return $ret;
    }

I actually believe the fingerprint for the closure there could include the attribute name by default, but that's something you might have considered and rejected already so...

@kocsismate
Copy link
Member

I appreciate your Pull Request and I also support the idea to include the attribute name in the anonymous function. I can't really remember why I made those methods private, but probably I just didn't think anyone would override them - but it's interesting to get to know a legal use-case which needs it!

So as soon as you fix that small typo, and I'll accept your PR!

@dimvic
Copy link
Contributor Author

dimvic commented Feb 19, 2016

Thanks a lot, I updated it, sorry about that, I only edited the file in github...

@kocsismate
Copy link
Member

OK, no problem! :) I'll release Yin 0.10.2 during the weekend with this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants