0

I have a model class witch basically is the fields from a database table with getter and setters.

class RealEstate extends BaseModel implements FilterProviderInterface
{    
    public $cityId;
    public $stateId;
    ...
    public $transferFields = array();

    public function getFilter()
    {
        return new MethodMatchFilter('getTransferFields');
    }

    public function setTransferFields($transferFields)
    {
        $this->transferFields = $transferFields;
    }

    public function getTransferFields()
    {
        return $this->transferFields;
    }
    ...
}

In my BaseTableGateway class I have a method save which takes this model object and extracts the data using get methods into an array.

    $hydrator = new ClassMethods(false);
    $model_data = $hydrator->extract($model);

I need the getTransferFields() method to bind the object to my form but I dont need it to be in the final array (be excluded while extracting).

public function getFilter()
{
    return new MethodMatchFilter('getTransferFields');
}

This method does exactly what I want but only for 1 method. I can't find out how to filter more than 1 method. Does anyone know how this would be achieved?

Ren
  • 1,111
  • 5
  • 15
  • 24
Exlord
  • 5,009
  • 4
  • 31
  • 51

1 Answers1

0

Simply return a FilterComposite object. The FilterComposite implements FilterInterface and is treated the same as the MethodMatchFilter.

For example:

    public function getFilter()
    {
         $myFilters = new FilterComposite();
         $myFilters->addFilter('someParam', new MethodMatchFilter('getSomeParam'));
         $myFilters->addFilter('someOtherParam', new MethodMatchFilter('getSomeOtherParam'));
         return $myFilters;
    }
Nick Cox
  • 35,529
  • 6
  • 31
  • 47