Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
match/app/src/Model/Table/MatchgridRecordsTable.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

…laneous fixes (NOJIRA)
95 lines (81 sloc)
3.3 KB
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
<?php | |
/** | |
* COmanage Match Matchgrid Records Table | |
* | |
* 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 http://www.internet2.edu/comanage COmanage Project | |
* @package match | |
* @since COmanage Match v1.0.0 | |
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | |
*/ | |
declare(strict_types = 1); | |
namespace App\Model\Table; | |
use Cake\ORM\Table; | |
use Cake\ORM\TableRegistry; | |
class MatchgridRecordsTable extends Table { | |
use \App\Lib\Traits\AutoViewVarsTrait; | |
use \App\Lib\Traits\MatchgridLinkTrait; | |
use \App\Lib\Traits\PrimaryLinkTrait; | |
use \App\Lib\Traits\SearchFilterTrait; | |
/** | |
* Perform Cake Model initialization. | |
* | |
* @since COmanage Match v1.0.0 | |
* @param array $config Configuration options passed to constructor | |
*/ | |
public function initialize(array $config): void { | |
$this->setPrimaryLink('matchgrid_id'); | |
$this->setRequiresMatchgrid(true); | |
// We allow unkeyed primary link here because a record ID is not by itself | |
// sufficient to identify a matchgrid, since each matchgrid gets its own | |
// physical table. | |
$this->setAllowUnkeyedPrimaryLink(['delete', 'edit']); | |
$this->setAutoViewVars([ | |
'sor' => [ | |
'type' => 'list', | |
'model' => 'SystemsOfRecord', | |
'find' => 'filterPrimaryLink', | |
// Because matchgrids use the actual SOR label and not systems_of_record_id | |
// we need a custom select field | |
'fields' => ['keyField' => 'label', 'valueField' => 'label'] | |
] | |
]); | |
// Use the matchgrid ID to figure out the attribute configuration for | |
// search filter purposes | |
$Matchgrid = TableRegistry::getTableLocator()->get('Matchgrids'); | |
$mgconfig = $Matchgrid->getMatchgridConfig($config['matchgrid_id']); | |
// Always permit search on SOR, SORID, and Reference ID | |
$this->setSearchFilter('sor', true, null, false); | |
$this->setSearchFilter('sorid', true, null, false); | |
$this->setSearchFilter('referenceid', true, null, false); | |
foreach($mgconfig->attributes as $attr) { | |
// XXX for now we permit substring on all fields since we don't have a better way to distinguish | |
$this->setSearchFilter($attr->name, $attr->case_sensitive, null, true); | |
} | |
} | |
/** | |
* Set validation rules. | |
* | |
* @param Validator $validator Validator | |
* @return \Cake\Validation\Validator Validator | |
* | |
public function validationDefault(Validator $validator): Validator { | |
// We don't do validation here since MatchService should handle that | |
}*/ | |
} |