By doing this, we can lazy-attach the backend object. This can help prevent circular references, but also ensure better internal behavior of objects that may not have been built correctly. Doing this requires adding a prop that with the internal backend type string to all VersioncontrolEntity classes, though, and requiring all backend classes to specify it in their class defs (currently only VersioncontrolRepository has to, as its a db field).

Comments

sdboyer’s picture

Plus, this'll make it NOT a huge pain in the ass to print_r() on a VersioncontrolEntity object.

marvil07’s picture

Priority: Normal » Major
Issue tags: +versioncontrol-6.x-2.0-release-blocker

cleaning api is a good thing ;-)

cvangysel’s picture

Proposed patch in attachments.

marvil07’s picture

Status: Active » Needs review

Great!

Taking a look at the patch :-)

marvil07’s picture

Assigned: Unassigned » sdboyer

After taking a look, I think the problem is the title of the issue.

This patch does the right work on replace, but the target of the issue is not well reflected on the title.

AFAIK the missing part here is about re-factor VersioncontrolEntity to remove $backend protected data member and use a getBackend() method to actually use the backend. This implies storing the backend string name on the VersioncontrolEntity class.

In the other side, now that I think a little more about it, I do not see the use of that re-factor, since I can not recall a place where we do not have the backend loaded(using lazy loading is about not having them loaded all the time), since they stay as static variable on versioncontrol_get_backends() function, and we always use that function somewhere in the flow.

I see the print_r() reason logic, but if you use devel's dpm() it prints only public data members, so not a problem really.

@sdboyer: So, do you still think this is a good idea? IMHO this is not really necessary.

sdboyer’s picture

Yes, I still think it's a good idea. It's been a while since I originally thought through this, I but I believe it had to do with making it object instanciation cheaper at some crucial point.

Regardless, having a getter for something like this is almost never a *bad* idea. It decouples code.

sdboyer’s picture

Status: Needs review » Fixed

Commushed. thanks!

Status: Fixed » Closed (fixed)
Issue tags: -versioncontrol-6.x-2.0-release-blocker

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit b54973c on 6.x-2.x, repository-families, drush-vc-sync-unlock authored by cvangysel, committed by sdboyer:
    Issue #1045464: Replace all literal $entity->backend instances with $...

  • Commit b54973c on 6.x-2.x, repository-families authored by cvangysel, committed by sdboyer:
    Issue #1045464: Replace all literal $entity->backend instances with $...