forked from COmanage/registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of BasicAttributeCollector (CFM-415) (COmanage…
…#231) Co-authored-by: Benn Oshrin <boshrin@users.noreply.github.com>
- Loading branch information
Showing
14 changed files
with
841 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
/** | ||
* COmanage Registry Basic Attribute Collectors Controller | ||
* | ||
* Portions licensed to the University Corporation for Advanced Internet | ||
* Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* UCAID licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @link https://www.internet2.edu/comanage COmanage Project | ||
* @package registry-plugins | ||
* @since COmanage Registry v5.1.0 | ||
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CoreEnroller\Controller; | ||
|
||
use Cake\ORM\TableRegistry; | ||
use App\Controller\StandardEnrollerController; | ||
use App\Lib\Enum\PetitionStatusEnum; | ||
|
||
class BasicAttributeCollectorsController extends StandardEnrollerController { | ||
public $paginate = [ | ||
'order' => [ | ||
'BasicAttributeCollectors.id' => 'asc' | ||
] | ||
]; | ||
|
||
/** | ||
* Dispatch an Enrollment Flow Step. | ||
* | ||
* @since COmanage Registry v5.1.0 | ||
* @param string $id Attribute Collector ID | ||
*/ | ||
|
||
public function dispatch(string $id) { | ||
$petition = $this->getPetition(); | ||
|
||
$CoSettings = TableRegistry::getTableLocator()->get('CoSettings'); | ||
|
||
$settings = $CoSettings->find()->where(['co_id' => $this->getCOID()])->firstOrFail(); | ||
|
||
$this->set('vv_permitted_name_fields', $settings->name_permitted_fields_array()); | ||
$this->set('vv_required_name_fields', $settings->name_required_fields_array()); | ||
|
||
if($this->request->is(['post', 'put'])) { | ||
|
||
try { | ||
$this->BasicAttributeCollectors->upsert( | ||
id: (int)$id, | ||
petitionId: $petition->id, | ||
// Remove form metadata from the set of attributes we pass to upsert | ||
attributes: array_diff_key($this->request->getData(), ['petition_id' => true, 'token' => true]) | ||
); | ||
|
||
// On success, indicate the step is completed and generate a redirect | ||
// to the next step | ||
|
||
$link = $this->getPrimaryLink(true); | ||
|
||
return $this->finishStep( | ||
enrollmentFlowStepId: $link->value, | ||
petitionId: $petition->id, | ||
comment: __d('core_enroller', 'result.attr.saved') | ||
); | ||
} | ||
catch(\Exception $e) { | ||
$this->Flash->error($e->getMessage()); | ||
} | ||
} | ||
|
||
// Fall through and let the form render | ||
|
||
$this->render('/Standard/dispatch'); | ||
} | ||
|
||
/** | ||
* Display information about this Step. | ||
* | ||
* @since COmanage Registry v5.1.0 | ||
* @param string $id Attribute Collector ID | ||
*/ | ||
|
||
public function display(string $id) { | ||
$petition = $this->getPetition(); | ||
|
||
$this->set('vv_basic_petition_attribute_set', $this->BasicAttributeCollectors | ||
->BasicPetitionAttributeSets | ||
->find() | ||
->where(['BasicPetitionAttributeSets.petition_id' => $petition->id]) | ||
->firstOrFail()); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/plugins/CoreEnroller/src/Model/Entity/BasicAttributeCollector.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* COmanage Registry Basic Attribute Collector Entity | ||
* | ||
* Portions licensed to the University Corporation for Advanced Internet | ||
* Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* UCAID licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @link https://www.internet2.edu/comanage COmanage Project | ||
* @package registry-plugins | ||
* @since COmanage Registry v5.1.0 | ||
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CoreEnroller\Model\Entity; | ||
|
||
use Cake\ORM\Entity; | ||
|
||
class BasicAttributeCollector extends Entity { | ||
/** | ||
* Fields that can be mass assigned using newEntity() or patchEntity(). | ||
* | ||
* Note that when '*' is set to true, this allows all unspecified fields to | ||
* be mass assigned. For security purposes, it is advised to set '*' to false | ||
* (or remove it), and explicitly make individual fields accessible as needed. | ||
* | ||
* @var array<string, bool> | ||
*/ | ||
protected $_accessible = [ | ||
'*' => true, | ||
'id' => false, | ||
'slug' => false, | ||
]; | ||
} |
49 changes: 49 additions & 0 deletions
49
app/plugins/CoreEnroller/src/Model/Entity/BasicPetitionAttributeSet.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* COmanage Registry Basic Petition Attribute Set Entity | ||
* | ||
* Portions licensed to the University Corporation for Advanced Internet | ||
* Development, Inc. ("UCAID") under one or more contributor license agreements. | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* UCAID licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @link https://www.internet2.edu/comanage COmanage Project | ||
* @package registry-plugins | ||
* @since COmanage Registry v5.1.0 | ||
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CoreEnroller\Model\Entity; | ||
|
||
use Cake\ORM\Entity; | ||
|
||
class BasicPetitionAttributeSet extends Entity { | ||
/** | ||
* Fields that can be mass assigned using newEntity() or patchEntity(). | ||
* | ||
* Note that when '*' is set to true, this allows all unspecified fields to | ||
* be mass assigned. For security purposes, it is advised to set '*' to false | ||
* (or remove it), and explicitly make individual fields accessible as needed. | ||
* | ||
* @var array<string, bool> | ||
*/ | ||
protected $_accessible = [ | ||
'*' => true, | ||
'id' => false, | ||
'slug' => false, | ||
]; | ||
} |
Oops, something went wrong.