getEntity(), 'get', [ 'return' => 'id', 'options' => ['limit' => 0], 'check_permissions' => 1, 'id' => ['IN' => $id], ])['values']; if (empty($perm)) { throw new CRM_Core_Exception(ts('No records available')); } $this->set('id', implode(',', array_keys($perm))); $pages = array_fill_keys($this->getTaskClass(), NULL); $this->_stateMachine = new CRM_Core_StateMachine($this); $this->_stateMachine->addSequentialPages($pages); // create and instantiate the pages $this->addPages($this->_stateMachine, $action); // add all the actions $this->addActions(); } /** * Get the name used to construct the class. * * @return string */ abstract public function getEntity():string; /** * Get the available tasks for the entity. * * @return array */ abstract public function getAvailableTasks():array; /** * Get the class for the action. * * @return array Array of the classes for the form controlle. * * @throws \CRM_Core_Exception */ protected function getTaskClass(): array { $task = CRM_Utils_Request::retrieve('task', 'Alphanumeric', $this, TRUE); foreach ($this->getAvailableTasks() as $taskAction) { if (($taskAction['key'] ?? '') === $task) { return (array) $taskAction['class']; } } throw new CRM_Core_Exception(ts('Invalid task')); } }