/** * Finds which display name to use for given Model, using the `ModelConfig` class for the `Model`. * Uses the overridden value if present, or falls back to the generated value. * * @param Model $model The `Model` to find the display name for. * @param ModelConfig $config The `ModelConfig` to use for retrieving the display name. * * @return String The name to display for the `Model`. */ public function getDisplayName(Model $model, ModelConfig $config = null) { if (empty($this->models)) { throw new \LogicException('AujaConfigurator not configured yet! Call configure first.'); } if (!isset($this->configs[$model->getName()])) { throw new \LogicException(sprintf('AujaConfigurator not configured for model %s', $model->getName())); } $result = null; if ($config != null && $config->getDisplayName() != null) { $result = $config->getDisplayName(); } else { $modelConfig = $this->configs[$model->getName()]; $result = $modelConfig->getDisplayName(); } return $result; }