akeeba / fof

Rapid Application Development framework for Joomla!™ 3 and 4
0 stars 0 forks source link

get() without attaching behaviors? #699

Closed compojoom closed 3 years ago

compojoom commented 3 years ago

Hi, I have a helper function that loads a model and does ->get() on it. Since I've defined the model with behavior filters -> I'm only getting the records that are published, but I would like to have all records without filtering.

I currently did it by passing an array('noFilters' => true)

$parkings  = $container->factory->model('Bookingperiods', array('noFilters' => true))->get();

then in the model I do:

    public function __construct(Container $container, array $config = array())
    {
        parent::__construct($container, $config);

        $noFilters = isset($config['noFilters']) ? $config['noFilters'] : false;
        // Add the filtering behaviour

        if(!$noFilters) {
            $this->addBehaviour('Filters');
        }
    }

Is this ok? or is there some magic prop I can pass to omit the $this->addBehavior on the object?

compojoom commented 3 years ago

Okay, nevermind.

$parkings  = $container->factory->model('Bookingperiods')->tmpInstance()->get();

is the way to go.