Problem/Motivation

If one wants to extend either of the server or index classes, then in typical OO fashion one would like to call the parent class constructor method when creating the new class. However, because the entity class (for the $server or $index property) to be created is hard-coded in these constructors as in the code below

public function __construct(array $values = array()) {
  parent::__construct($values, 'search_api_index');
}

one is unable to create an instance of the extended class for the $server or $index property using this approach.

Proposed resolution

Add a parameter to each constructor method for the entity type of the class to create with its default value being the currently hard-coded class name in the body of the constructor.

Remaining tasks

Review and test. No documentation.

User interface changes

None.

API changes

None.

Comments

solotandem’s picture

Status: Active » Needs review
StatusFileSize
new1.47 KB

Attached patch implements proposed resolution.

drunken monkey’s picture

Status: Needs review » Fixed

Makes sense, thanks a lot for posting!
I vaguely remember copying this code from fago, but I don't think there was really any reason.
So, committed. Thanks again!

Status: Fixed » Closed (fixed)

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