/** * convert name in nominative to vocative in czech lang * * @param string $name * @return string * @register */ public function vocative($name) { $lang = $this->translator->lang; if ($lang === 'cs') { return Common::czechVocative($name); } return $name; }
/** * @param bool $collectionKeys when field contains collection, return only array of PKs * @param bool $includeCollections * @param array $ignoreKeys * @return ArrayHash */ public function toArray($collectionKeys = TRUE, $includeCollections = TRUE, $ignoreKeys = []) { $ret = get_object_vars($this); $unset = []; if (method_exists($this, 'getId')) { $ret['id'] = $this->getId(); } foreach ($ret as $key => &$value) { if (in_array($key, $ignoreKeys)) { continue; } if ($value instanceof BaseEntity) { $value = $value->getId(); } elseif ($value instanceof PersistentCollection) { if ($includeCollections && $collectionKeys) { $keys = []; foreach ($value as $subEntity) { $keys[] = $subEntity->getId(); } $value = $keys; } else { $unset[] = $key; } } } if (!$includeCollections) { foreach ($unset as $key) { unset($ret[$key]); } } $ret = Common::unsetKeys($ret, $ignoreKeys); return ArrayHash::from($ret, FALSE); }