Returns destination model that is linked through this reference. Will apply
necessary conditions.

@param array $defaults Properties

@return Model
495281
public function getModel($defaults = []) : Model
    {
        // set table_alias
        if (!isset($defaults['table_alias'])) {
            if (!$this->table_alias) {
                $this->table_alias = $this->link;
                $this->table_alias = preg_replace('/_'.($this->owner->id_field ?: 'id').'/', '', $this->table_alias);
                $this->table_alias = preg_replace('/([a-zA-Z])[a-zA-Z]*[^a-zA-Z]*/', '\1', $this->table_alias);
                if (isset($this->owner->table_alias)) {
                    $this->table_alias = $this->owner->table_alias.'_'.$this->table_alias;
                }
            }
            $defaults['table_alias'] = $this->table_alias;
        }

        // if model is Closure, then call it and return model
        if (is_object($this->model) && $this->model instanceof \Closure) {
            $c = $this->model;
            $c = $c($this->owner, $this, $defaults);

            return $this->addToPersistence($c, $defaults);
        }

        // if model is set, then return clone of this model
        if (is_object($this->model)) {
            $c = clone $this->model;

            return $this->addToPersistence($c, $defaults);
        }

        // last effort - try to add model
        if (is_array($this->model)) {
            $model = $this->model[0];
            $md = $this->model;
            unset($md[0]);

            $defaults = array_merge($md, $defaults);
        } else {
            $model = $this->model;
        }

        if (!$model instanceof Model) {
            $model = $this->factory($model, $defaults);
        }

        return $this->addToPersistence($model, $defaults);
    }
577948
public function getNavigation(NavComposer $navComposer = null, array $attrs = null, array $ulAttrs = null, 
			array $liAttrs = null, array $aAttrs = null) {
		if ($navComposer === null) {
			$navComposer = Nav::root();
		}
		
		return $navComposer->build($this->view, $attrs, $ulAttrs, $liAttrs, $aAttrs);
	}
670859
public static function default(array $options = null): ?array
    {
        if ($options === null) {
            return Saber::getDefaultOptions();
        } else {
            Saber::setDefaultOptions($options); //global
            self::getDefaultClient()->setOptions($options);
        }

        return null;
    }
201735
protected function mergeAttributesWith( array $defaults )
	{
		// similar to array_merge except overwrite empty values
		foreach( $defaults as $key => $value ) {
			if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] ))continue;
			$this->args[ $key ] = $value;
		}

		$attributes = $this->args['attributes'];

		// prioritize $attributes over $this->args, don't worry about duplicates
		return array_merge( $this->args, $attributes );
	}
590173
public function setOptions(array $options, array $defaults = [])
    {
        $options = array_merge($defaults, $options);
        $this->options = $options;

        return $this;
    }
1192550
public function addDefaults(array $defaults)
    {
        foreach ($defaults as $name => $default) {
            $this->defaults[$name] = $default;
        }
        $this->compiled = null;

        return $this;
    }
198403
public function modelsFromIds($ids)
    {
        // We need a Model in order to save this relationship so we try
        // to whereIn the given id(s) through the related model.
        return $this->related->whereIn($this->related->getKeyName(), (array) $ids)->get();
    }
1200903
protected function getExportModel()
    {
        $model = parent::getExportModel();
        $model->del('parents', 'formatFunction');
        $model->del('allowed', 'formatFunction');
        $model->del('inherited', 'formatFunction');

        return $model;
    }
1352119
public function haveLinkInDatabase(array $overrides = [])
    {
        $tableName = $this->grabLinksTableName();
        $defaults = Links::getDefaults();
        $overrides = array_merge($defaults, array_intersect_key($overrides, $defaults));

        return $this->haveInDatabase($tableName, $overrides);
    }
1090436
protected function getRequestOptions(array $defaults = []) {

        $defaults = array_merge($this->getDefaultOptions(), $defaults);

        $page = $this->hasRequestParameter('page') ? $this->getRequestParameter('page') : $defaults['page'];
        $rows = $this->hasRequestParameter('rows') ? $this->getRequestParameter('rows') : $defaults['rows'];
        $sortBy = $this->hasRequestParameter('sortby') ? $this->getRequestParameter('sortby') : $defaults['sortby'];
        $sortOrder = $this->hasRequestParameter('sortorder') ? $this->getRequestParameter('sortorder') : $defaults['sortorder'];
        $filter = $this->hasRequestParameter('filter') ? $this->getRequestParameter('filter') : $defaults['filter'];
        $filterquery = $this->hasRequestParameter('filterquery') ? $this->getRequestParameter('filterquery') : $defaults['filter'];
        $periodStart = $this->hasRequestParameter('periodStart') ? $this->getRequestParameter('periodStart') : $defaults['periodStart'];
        $periodEnd = $this->hasRequestParameter('periodEnd') ? $this->getRequestParameter('periodEnd') : $defaults['periodEnd'];
        $detailed = $this->hasRequestParameter('detailed') ? $this->getRequestParameter('detailed') : 'false';
        $detailed = filter_var($detailed, FILTER_VALIDATE_BOOLEAN);

        return array(
            'page' => $page,
            'rows' => $rows,
            'sortBy' => $sortBy,
            'sortOrder' => $sortOrder,
            'filter' => $filter ? $filter : $filterquery,
            'periodStart' => $periodStart,
            'detailed' => $detailed,
            'periodEnd' => $periodEnd
        );

    }
213531
public function addDefaults(array $defaults): self
    {
        // TODO : faire un assert que $name est bien une string sinon lever une exception !!!!
        foreach ($defaults as $name => $default) {
            $this->defaults[$name] = $default;
        }

        return $this;
    }
771707
public function attributable(array $attributes, array $defaults = []): string
    {
        return $this->attributes($this->decorate($attributes, $defaults));
    }
755918
private function generateSelectedRefinements($navigations)
  {
    $refinements = [];
    foreach ($navigations as $key => $navigation) {
      foreach ($navigation->getRefinements() as $refinement) {
        switch ($refinement->getType()) {
          case Type::Range: {
            /** @var RefinementRange $rr */
            $rr = $refinement;
            $selectedRefinementRange = new SelectedRefinementRange();
            $selectedRefinementRange
                ->setNavigationName($navigation->getName())
                ->setLow($rr->getLow())
                ->setHigh($rr->getHigh())
                ->setExclude($rr->isExclude());

            array_push($refinements, $selectedRefinementRange);
            break;
          }
          case Type::Value: {
            /** @var RefinementValue $rv */
            $rv = $refinement;
            $selectedRefinementValue = new SelectedRefinementValue();
            $selectedRefinementValue
                ->setNavigationName($navigation->getName())
                ->setValue($rv->getValue())
                ->setExclude($rv->isExclude());

            array_push($refinements, $selectedRefinementValue);
            break;
          }
        }
      }
    }
    return $refinements;
  }
780270
public function configureDefaults(array $defaults, $force = false)
    {
        if ($force || empty($this->toArray())) {
            $attachmentDefaults = $this->attachmentDefaults;

            foreach (MessageDefaults::allKeys() as $key) {
                if (isset($defaults[$key]) && ! is_null($value = $defaults[$key])) {
                    if (strpos($key, 'attachment_') !== false) {
                        if ($key = substr($key, strlen('attachment_'))) {
                            $attachmentDefaults[$key] = $value;
                        }
                    } else {
                        $this->fillDefaults($key, $value);
                    }
                }
            }

            $this->setAttachmentDefaults($attachmentDefaults);
        }

        return $this;
    }
1337701
public function setDefaults(array $defaults)
    {
        foreach ($this->routes as $route)
            $route->setDefaults($defaults);
        return $this;
    }
520875
public static function gets($keys = null)
    {
        $noInitModel = static::buildNoInitModel();
        $query = static::find();
        if ($keys == null) {
            $models = $query->all();
        } elseif (is_array($keys)) {
            $array = [];
            foreach ($keys as $key) {
                if (is_string($key) && strlen($key)) {
                    $array[] = $key;
                }
            }
            $models = $query->where([$noInitModel->idAttribute => $array])->all();
        }
        $result = [];
        foreach ($models as $key => $model) {
            $result[$model->key] = $model->value;
        }
        return $result;
    }
508798
protected function getMapping($mappings)
    {
        $properties = array();

        foreach ($mappings as $propertyName => $fieldMapping) {
            if (isset($fieldMapping['fieldName'])) {
                $propertyName = $fieldMapping['fieldName'];
            }

            if (isset($fieldMapping['type'])) {
                $properties[$propertyName]['type'] = $fieldMapping['type'];
 
                if ($fieldMapping['type'] == 'attachment' && isset($fieldMapping['fields'])) {
                    $callback = function ($field) {
                        unset($field['type']);
                        return $field;
                    };
                    $properties[$propertyName]['fields'] = array_map($callback, $this->getMapping($fieldMapping['fields']));
                }

                if ($fieldMapping['type'] == 'multi_field' && isset($fieldMapping['fields'])) {
                    $properties[$propertyName]['fields'] = $this->getMapping($fieldMapping['fields']);
                }
  
                if (in_array($fieldMapping['type'], array('nested', 'object')) && isset($fieldMapping['properties'])) {
                    $properties[$propertyName]['properties'] = $this->getMapping($fieldMapping['properties']);
                }
            }

            if (isset($fieldMapping['path'])) {
                $properties[$propertyName]['path'] = $fieldMapping['path'];
            }

            if (isset($fieldMapping['includeInAll'])) {
                $properties[$propertyName]['include_in_all'] = $fieldMapping['includeInAll'];
            }

            if (isset($fieldMapping['nullValue'])) {
                $properties[$propertyName]['null_value'] = $fieldMapping['nullValue'];
            }

            if (isset($fieldMapping['store'])) {
                $properties[$propertyName]['store'] = $fieldMapping['store'];
            }

            if (isset($fieldMapping['index'])) {
                $properties[$propertyName]['index'] = $fieldMapping['index'];
            }

            if (isset($fieldMapping['boost'])) {
                $properties[$propertyName]['boost'] = $fieldMapping['boost'];
            }

            if (isset($fieldMapping['analyzer'])) {
                $properties[$propertyName]['analyzer'] = $fieldMapping['analyzer'];
            }

            if (isset($fieldMapping['indexName'])) {
                $properties[$propertyName]['index_name'] = $fieldMapping['indexName'];
            }

            if (isset($fieldMapping['geohash'])) {
                $properties[$propertyName]['geohash'] = $fieldMapping['geohash'];
            }

            if (isset($fieldMapping['geohash_precision'])) {
                $properties[$propertyName]['geohash_precision'] = $fieldMapping['geohash_precision'];
            }

            if (isset($fieldMapping['geohash_prefix'])) {
                $properties[$propertyName]['geohash_prefix'] = $fieldMapping['geohash_prefix'];
            }
        }

        return $properties;
    }