I am building more Service classes and want to improve the UI.

I was able to add a simple "name" property to the hostingService classes, then output that in the form.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jon Pugh created an issue. See original summary.

  • Jon Pugh committed d486e54 on 2714561-hostingService-name
    Issue #2714561: Add "name" property to HostingService classes to allow...
Jon Pugh’s picture

  • Jon Pugh committed 5c70642 on 2714561-hostingService-name
    Issue #2714561: Fixing incorrect option keys.
    
Jon Pugh’s picture

gboudrias’s picture

Seems like a great idea, but does it require updating the hook_hosting_services() implementations? eg this.

I'm guessing we don't need to, but just making sure.

Jon Pugh’s picture

Nope, in fact you can't mess with hook_hosting_service() without major refactoring.

That hook is where I started. Had to really hack up the module_invoke() when it hit me that we should just keep the metadata in the class itself.

gboudrias’s picture

Yeah, figures. I don't see a problem with this patch but I'd like others to comment if possible since it's a complicated area of the code.

helmo’s picture

Status: Active » Needs work

I get a number of these warnings after merging this branch....

Warning: Missing argument 1 for hostingService::__construct(), called in /var/aegir/hostmaster-2016-04-19_13-56/profiles/hostmaster/modules/aegir/hosting/server/hosting_server.module on line 406 and defined in __construct() (line 15 of /var/aegir/hostmaster-2016-04-19_13-56/profiles/hostmaster/modules/aegir/hosting/server/hosting_server.service.inc).

The constructor currently likes to get a $node parameter ....

helmo’s picture

+1 otherwise though

  • Jon Pugh committed b0521b8 on 2714561-hostingService-name
    Progress on Issue #2714561: Prevent warnings from missing parameter in...
Jon Pugh’s picture

Status: Needs work » Needs review

Added $node argument.

      $serviceClass = new $class_name($node);
ergonlogic’s picture

    foreach ($service['types'] as $type => $class_name) {
      $serviceClass = new $class_name;
      $options[$type] = isset($serviceClass->name)? $serviceClass->name: $type;
    }

Why are we instantiating the classes again? If the node exists, $node->services ought to contain service objects. Otherwise, they're already being instantiated a little further down in hosting_services_new_object().

Could we default $serviceClass->name to $type in hostingService::__construct? Or perhaps add a getter function for that (e.g., hostingService::getName())? That way, it'd consistently be set within the object, rather than having to redo that check wherever we might want to display it.

Should we perhaps differentiate between the $name we get back from hosting_server_services() and $serviceClass->name? That is, consistently call (at least one of) them $machine_name and/or $serviceClass->humanName, respectively.

Finally, I think we'd also want to use these human names as the column header is our servers view, no?

ergonlogic’s picture

Status: Needs review » Needs work

  • Jon Pugh committed c04d0a6 on 2714561-hostingService-name
    Progress on issue #2714561: Adding service, type,...
  • Jon Pugh committed fa73280 on 2714561-hostingService-name
    Progress on Issue #2714561: moving the class instantiation up the line...
Jon Pugh’s picture

Status: Needs work » Active
Issue tags: +DrupalNorth2016

All suggestions implemented, except the last one about the column headers.

Will work on that after Pizza!

  • Jon Pugh committed f7d0a6d on 2714561-hostingService-name
    Progress on Issue #2714561: Output getName() method instead of "type" in...
Jon Pugh’s picture

Status: Active » Needs review
FileSize
18.57 KB

Screenshot of servers list.

helmo’s picture

Status: Needs review » Needs work

Sorry but the 2714561-hostingService-name branch gives a merge conflict.

Jon Pugh’s picture

Status: Needs work » Needs review
FileSize
8.03 KB
Jon Pugh’s picture

Pushed to the branch as well.

  • helmo committed 4134e42 on 7.x-3.x authored by Jon Pugh
    Issue #2714561 by Jon Pugh, helmo: Add "name" property to HostingService...
helmo’s picture

Status: Needs review » Fixed

Thanks, Looks much nicer on /hosting/servers

Status: Fixed » Closed (fixed)

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

Jon Pugh’s picture

Status: Closed (fixed) » Needs review

  • helmo committed 4134e42 on 7.x-3.x-devshop authored by Jon Pugh
    Issue #2714561 by Jon Pugh, helmo: Add "name" property to HostingService...
Jon Pugh’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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