Returns a string which uniquely represents the group the given model should be in for aggregation.
@param Model $model
@return string
501040
private function getGroupKeyForModel(Model $model)
    {
        $key = "";

        foreach ($this->groups as $group) {
            $key .= $model[$group] . "|";
        }

        return $key;
    }
1251511
public static function get(Model $model)
    {
        return Mention::where('model_type', get_class($model))
            ->where('model_id', $model->getKey())
            ->get();
    }
2944
public function getModelNamePlural(Model $model, $toLowerCase = false) {
		$modelName = $this->getModelName($model, $toLowerCase);

		return Inflector::pluralize($modelName);
	}
310550
protected function getModelTable($model)
    {
        if (!is_object($model)) {
            $model = new $model;
        }

        return DB::getTablePrefix().$model->getTable();
    }
1157516
public static function getModelClass($model): string
    {
        if (!isset(self::$modelClassMap[$model])) {
            // try to detect
            $className = '\\Application\\' . $model . '\\Table';

            if (!class_exists($className)) {
                throw new RelationNotFoundException("Related class for model `$model` not found");
            }
            self::$modelClassMap[$model] = $className;
        }
        return self::$modelClassMap[$model];
    }
650228
protected function concatenation(Model $model)
    {
        // We simply add the connectors for public access.
        return $model->getConnectorLeft() .
            $this->pool->encodingService->encodeStringForCodeGeneration($model->getName()) .
            $model->getConnectorRight();
    }
1147567
public function modelSlug($model)
    {
        if (is_object($model)) {
            $model = get_class($model);
        }

        return str_replace('\\', '-', strtolower($model));
    }
925638
public function isOpenNode($model)
    {
        $isOpen = false;

        if ($openedIds = (array)$this->openedIds) {
            if (in_array($model->id, $openedIds)) {
                $isOpen = true;
            }
        }

        return $isOpen;
    }
1214331
public static function groupModelsAndIdentifiersByType($models)
    {
        $groups = (new Collection($models))->groupBy(function ($model) {
            if (is_numeric($model)) {
                return 'integers';
            } else if (is_string($model)) {
                return 'strings';
            } else if ($model instanceof Model) {
                return 'models';
            }

            throw new InvalidArgumentException('Invalid model identifier');
        })->map(function ($items) {
            return $items->all();
        })->all();

        return static::fillMissingKeys($groups, [], ['integers', 'strings', 'models']);
    }
53248
public static function with($model)
    {
        $data = static::model()->findAll();

        $idKey = null;
        $whereIn = [];
        foreach ($data as $key => $value) {
            $idKey = $value->primaryKey;
            $whereIn[] = $value->{$value->primaryKey};
        }

        $associatedModel = new $model();
        $associatedData = $associatedModel
            ->where(static::getForeignKey(static::model()->tableName), 'IN', implode(',', $whereIn))
            ->findAll();

        $data = static::buildRelations($data, $associatedModel, $associatedData);

        return $data;
    }
232641
public function getLikedRecord(Model $model): ?Model
    {
        return $this->likes()
                    ->where('liked_by_id', $model->id)
                    ->where('liked_by_type', get_class($model))
                    ->first();
    }
1323938
protected function serializeModel($model)
    {
        if ($this->request->getIsHead()) {
            return null;
        }

        [$fields, $expand] = $this->getRequestedFields();
        return $model->toArray($fields, $expand);
    }
109703
public function setModel($model)
    {
        if(!($model instanceof KModelInterface))
        {
            if(is_string($model) && strpos($model, '.') === false )
            {
                // Model names are always plural
                if(KStringInflector::isSingular($model)) {
                    $model = KStringInflector::pluralize($model);
                }

                $identifier         = $this->getIdentifier()->toArray();
                $identifier['path'] = array('model');
                $identifier['name'] = $model;

                $identifier = $this->getIdentifier($identifier);
            }
            else $identifier = $this->getIdentifier($model);

            $model = $identifier;
        }

        $this->_model = $model;

        return $this->_model;
    }
315999
public static function getModelName( $model, $bean = null ) {
		if (isset(self::$modelCache[$model])) return self::$modelCache[$model];
		if (self::$modelFormatter){
			$modelID = self::$modelFormatter->formatModel($model,$bean);
		}
		else {
			$modelID = 'Model_'.ucfirst($model);
		}
		self::$modelCache[$model] = $modelID;
		return self::$modelCache[$model];
	}
741070
protected function getCondition($condition,$model){
        if(empty($condition)){
            return $condition;
        }
        if(is_array($condition)){
            foreach ($condition as $k=>$v){
                $result[$k]=$this->getCondition($v,$model);
            }
        }else{
            if(preg_match('/{([\w\d_]+):([\w\d_]+)}/',$condition,$match)){
                $result=$model->{$match[2]};
            }else{
                $result=$condition;
            }
        }
        return $result;
    }
769457
protected function _getAliases(Model $Model) {
		$aliases = array_merge(array(
			//$Model->name,
			$Model->alias
				), $this->config[$Model->alias]['aliases']
		);

		foreach ($Model->associations() as $associationType) {
			foreach ($Model->$associationType as $associationKey => $association) {
				if ($association['className'] === $Model->name) {
					$aliases[] = $associationKey;
				}
			}
		}

		return $aliases;
	}
1049648
public function getModelLinks(Model $model) {
        $models = Configure::read('Admin.modelLinks');

        if (isset($models[$model->qualifiedName])) {
            return $models[$model->qualifiedName];
        }

        return array();
    }