<?php
namespace App\Model;
use App\Helpers\CurrentLocale;
use App\Helpers\LocaleHelper;
use Symfony\Component\Intl\Countries;
class ContactPerson extends \Pimcore\Model\DataObject\ContactPerson
{
public function translatedRegion(): string
{
//TODO isn't the `region` field unused since the introduction of the `enabled` translatable field?
$region = $this->getRegion();
return $region ? Countries::getName($region) : '';
}
/**
* For all the selected branches for this ContactPerson we combine this in a list, separating each branch with a comma.
*
* @return string
* @throws \Exception
*/
public function branchesList(): ?string
{
$branches = $this->getBranches();
if (!$branches) {
return null;
}
// Combine all branch names into a string, separate then with a comma and a space.
return join(', ', array_map(fn($b) => $b->getBranchename(), $branches));
}
}