Add limit to number of locations to be stored. #632

This commit is contained in:
Korina Cordero 2021-10-27 08:26:19 +00:00
parent c54ee5d7d8
commit 84844046f1
2 changed files with 14 additions and 1 deletions

View file

@ -3650,8 +3650,13 @@ class APIController extends Controller implements LoggedController
}
else
{
// TODO: limit locations to 6. If more than 6, pop the first one out
// limit locations to 6. If more than 6, pop the first one out
// add location to existing customer meta
$meta_count = count($c_meta->getAllMetaInfo());
if ($meta_count >= 6)
$c_meta->popMetaInfo();
$c_meta->addMetaInfo($name, $loc_info);
}

View file

@ -76,4 +76,12 @@ class CustomerMetadata
{
return $this->meta_info;
}
public function popMetaInfo()
{
if (count($this->meta_info) > 0)
{
array_shift($this->meta_info);
}
}
}