diff --git a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php index aeb0fb6a9..e9640bd71 100644 --- a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php @@ -41,27 +41,6 @@ class AttributeCollectorsController extends StandardEnrollerController { ] ]; - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.0.0 - */ - - public function beforeRender(EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->AttributeCollectors->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->AttributeCollectors->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->AttributeCollectors->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } - /** * Dispatch an Enrollment Flow Step. * diff --git a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php index be85918ad..4e3496057 100644 --- a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php @@ -39,27 +39,6 @@ class BasicAttributeCollectorsController extends StandardEnrollerController { ] ]; - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.1.0 - */ - - public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->BasicAttributeCollectors->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->BasicAttributeCollectors->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->BasicAttributeCollectors->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } - /** * Dispatch an Enrollment Flow Step. * diff --git a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php index 2922f0c67..6e683e9f9 100644 --- a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php +++ b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php @@ -58,14 +58,6 @@ class EmailVerifiersController extends StandardEnrollerController { */ public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->EmailVerifiers->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->EmailVerifiers->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->EmailVerifiers->EnrollmentFlowSteps->getPrimaryKey()); - } - // We use the viewvar to determine the op since 'index' isn't always present $op = $this->viewBuilder()->getVar('vv_op'); diff --git a/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php b/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php index fc7198367..b86691aeb 100644 --- a/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php +++ b/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php @@ -51,14 +51,6 @@ class EnrollmentAttributesController extends StandardEnrollerController { public function beforeRender(\Cake\Event\EventInterface $event) { $this->set('vv_supported_attributes', $this->EnrollmentAttributes->supportedAttributes()); - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->EnrollmentAttributes->AttributeCollectors->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->EnrollmentAttributes->AttributeCollectors->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->EnrollmentAttributes->AttributeCollectors->getPrimaryKey()); - } - $ret = parent::beforeRender($event); $attributes = $this->viewBuilder()->getVar('attributes'); diff --git a/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php index 74347f02e..0a532ecb3 100644 --- a/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php @@ -38,27 +38,6 @@ class IdentifierCollectorsController extends StandardEnrollerController { 'IdentifierCollectors.id' => 'asc' ] ]; - - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.0.0 - */ - - public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->IdentifierCollectors->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->IdentifierCollectors->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->IdentifierCollectors->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } /** * Dispatch an Enrollment Flow Step. diff --git a/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php b/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php index 172594124..17535e9c0 100644 --- a/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php +++ b/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php @@ -39,27 +39,6 @@ class InvitationAcceptersController extends StandardEnrollerController { 'InvitationAccepters.id' => 'asc' ] ]; - - /** - * Callback run prior to the request render. - * - * @param EventInterface $event Cake Event - * - * @return Response|void - * @since COmanage Registry v5.0.0 - */ - - public function beforeRender(\Cake\Event\EventInterface $event) { - $link = $this->getPrimaryLink(true); - - if(!empty($link->value)) { - $this->set('vv_bc_parent_obj', $this->InvitationAccepters->EnrollmentFlowSteps->get($link->value)); - $this->set('vv_bc_parent_displayfield', $this->InvitationAccepters->EnrollmentFlowSteps->getDisplayField()); - $this->set('vv_bc_parent_primarykey', $this->InvitationAccepters->EnrollmentFlowSteps->getPrimaryKey()); - } - - return parent::beforeRender($event); - } /** * Dispatch an Enrollment Flow Step. diff --git a/app/src/Controller/Component/BreadcrumbComponent.php b/app/src/Controller/Component/BreadcrumbComponent.php index ccd86e65a..71bf699c5 100644 --- a/app/src/Controller/Component/BreadcrumbComponent.php +++ b/app/src/Controller/Component/BreadcrumbComponent.php @@ -274,8 +274,7 @@ public function injectPrimaryLink(object $link, bool $index = true, string $link [$title] = StringUtilities::entityAndActionToTitle( entity: $linkedEntity, modelPath: $linkModelFqn, - action: $breadcrumbAction, - domain: StringUtilities::pluginToTextDomain($link->plugin ?? null) + action: $breadcrumbAction ); $title = StringUtilities::stripActionPrefix($title); diff --git a/app/src/Controller/Component/RegistryAuthComponent.php b/app/src/Controller/Component/RegistryAuthComponent.php index d8c3f8d74..02afc8f52 100644 --- a/app/src/Controller/Component/RegistryAuthComponent.php +++ b/app/src/Controller/Component/RegistryAuthComponent.php @@ -49,7 +49,6 @@ namespace App\Controller\Component; -use App\Model\Entity; use \App\Lib\Enum\AuthenticationEventEnum; use \App\Lib\Enum\SuspendableStatusEnum; use \App\Lib\Enum\TemplateableStatusEnum; diff --git a/app/src/Controller/StandardEnrollerController.php b/app/src/Controller/StandardEnrollerController.php index ea70e6982..c7f6e2124 100644 --- a/app/src/Controller/StandardEnrollerController.php +++ b/app/src/Controller/StandardEnrollerController.php @@ -70,6 +70,17 @@ public function beforeRender(\Cake\Event\EventInterface $event) { $this->set('vv_petition', null); } + $link = $this->getPrimaryLink(true); + + if(!empty($link->value)) { + $currentTable = $this->getCurrentTable(); + $efsTable = $currentTable->getAssociation('EnrollmentFlowSteps')->getTarget(); + + $this->set('vv_bc_parent_obj', $efsTable->get($link->value)); + $this->set('vv_bc_parent_displayfield', $efsTable->getDisplayField()); + $this->set('vv_bc_parent_primarykey', $efsTable->getPrimaryKey()); + } + return parent::beforeRender($event); } diff --git a/app/src/Lib/Util/StringUtilities.php b/app/src/Lib/Util/StringUtilities.php index feed2b562..60b9f5227 100644 --- a/app/src/Lib/Util/StringUtilities.php +++ b/app/src/Lib/Util/StringUtilities.php @@ -146,7 +146,7 @@ public static function columnKey( // Otherwise look for the general key $cfield = __d('field', $c); - return ($cfield !== $c) ? $cfield : \Cake\Utility\Inflector::humanize($c); + return ($cfield !== $c) ? $cfield : Inflector::humanize($c); } /** @@ -180,15 +180,15 @@ public static function columnToAutoViewVar(string $column): string { * Determines the translation domain for a plugin * * @param string|null $plugin Plugin name - * @return string Translation domain + * @return string|null Translation domain * @since COmanage Registry v5.2.0 */ - public static function pluginToTextDomain(?string $plugin): string + public static function pluginToTextDomain(?string $plugin): ?string { if (empty($plugin)) { - return 'operation'; + return null; } - return \Cake\Utility\Inflector::singularize(\Cake\Utility\Inflector::tableize($plugin)); + return Inflector::underscore($plugin); } /** @@ -407,7 +407,7 @@ public static function localizeController(string $controllerName, ?string $plugi if ($pluginName) { // Localize via plugin - return __d(\Cake\Utility\Inflector::underscore($pluginName), 'controller.' . $controllerName, [$plural ? 99 : 1]); + return __d(Inflector::underscore($pluginName), 'controller.' . $controllerName, [$plural ? 99 : 1]); } // Standard Localization return __d('controller', $controllerName, [$plural ? 99 : 1]); diff --git a/app/src/Model/Table/JobsTable.php b/app/src/Model/Table/JobsTable.php index 15f9012a8..3d016635c 100644 --- a/app/src/Model/Table/JobsTable.php +++ b/app/src/Model/Table/JobsTable.php @@ -30,7 +30,6 @@ namespace App\Model\Table; use Cake\Datasource\ConnectionManager; -use Cake\ORM\Query; use Cake\ORM\RulesChecker; use Cake\ORM\Table; use Cake\ORM\TableRegistry; @@ -124,6 +123,24 @@ public function initialize(array $config): void { ] ]); } + + /** + * Table specific logic to generate a display field. + * + * @since COmanage Registry v5.2.0 + * @param Job $entity Entity to generate display field for + * @return string Display field + */ + + public function generateDisplayField(Job $entity): string { + // Try to find something renderable + + if(!empty($entity->plugin)) { + return $entity->plugin . " (" . $entity->id . ")"; + } + + return (string)$entity->id; + } /** * Assign a Job to a worker. This function should be called by the process diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index 57bda472c..60e3f9c31 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -104,9 +104,7 @@ public function calculateLabelAndDescription(string $fieldName): array $label = null; // First, try to autogenerate the field label (if we weren't given one). - $pluginDomain = (!empty($this->getPluginName()) - ? Inflector::underscore($this->getPluginName()) - : null); + $pluginDomain = StringUtilities::pluginToTextDomain($this->getPluginName()); $modelName = $this->getModelName(); // We try to automagically determine if a description for the field exists by