twill icon indicating copy to clipboard operation
twill copied to clipboard

[3.x] Add getters/setters for options in controllers

Open haringsrob opened this issue 2 years ago • 0 comments

To further enhance the developer experience I want to add getters/setters for:

'indexOptions, while we leave the property for 3.x (but deprecated) we instead suggest to use:

        'create' => true,  --> $this->enableCreate(); $this->disableCreate();
        'edit' => true, --> $this->enableEdit(); $this->disableEdit();
        'publish' => true, --> $this->enablePublish(); ...
        'bulkPublish' => true,
        'feature' => false,
        'bulkFeature' => false,
        'restore' => true,
        'bulkRestore' => true,
        'forceDelete' => true,
        'bulkForceDelete' => true,
        'delete' => true,
        'duplicate' => false,
        'bulkDelete' => true,
        'reorder' => false,
        'permalink' => true,
        'bulkEdit' => true,
        'editInModal' => false,
        'skipCreateModal' => false,

We also introduce a new "setup" method, that can be used to call these:

public function setup() {
   $this->disableCreate();
   ...
   /// Can also be chained
   $this->enablePublish()->disableBulkPublish();

  // For example how this can be used:
  if (Carbon::now()->isWeekend()) {
    $this->disableEdit();
    $this->disablePublish();
  }
}

haringsrob avatar May 19 '22 07:05 haringsrob