chg: [internal] saveMetafields moved to AppTable

pull/38/head
iglocska 2021-01-13 14:20:29 +01:00
parent af3d2dd6d9
commit 539ce4b99a
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 21 additions and 0 deletions

View File

@ -6,10 +6,31 @@ use Cake\ORM\Table;
use Cake\Validation\Validator; use Cake\Validation\Validator;
use Cake\Core\Configure; use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig; use Cake\Core\Configure\Engine\PhpConfig;
use Cake\ORM\TableRegistry;
class AppTable extends Table class AppTable extends Table
{ {
public function initialize(array $config): void public function initialize(array $config): void
{ {
} }
public function saveMetaFields($id, $input)
{
$this->MetaFields = TableRegistry::getTableLocator()->get('MetaFields');
foreach ($input['metaFields'] as $metaField => $values) {
if (!is_array($values)) {
$values = [$values];
}
foreach ($values as $value) {
if ($value !== '') {
$temp = $this->MetaFields->newEmptyEntity();
$temp->field = $metaField;
$temp->value = $value;
$temp->scope = $this->metaFields;
$temp->parent_id = $id;
$this->MetaFields->save($temp);
}
}
}
}
} }