コード例 #1
0
 /**
  * Resolves a Config instance.
  *
  * @return ModelConfig The resolved config.
  */
 public function resolve()
 {
     if (is_null($this->config->getDisplayField()) || $this->config->getDisplayField() == '') {
         $this->config->setDisplayField($this->resolveDisplayField());
         $this->config->setVisibleFields($this->resolveVisibleFields());
     }
     return $this->config;
 }
コード例 #2
0
 /**
  * Finds which display field 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 field for.
  * @param ModelConfig $config The `ModelConfig` to use for retrieving the display field.
  *
  * @return String The name of the field to use for displaying the `Model`.
  */
 public function getDisplayField(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->getDisplayField() != null) {
         $result = $config->getDisplayField();
     } else {
         $modelConfig = $this->configs[$model->getName()];
         $result = $modelConfig->getDisplayField();
     }
     return $result;
 }