Get bindingModel name

@param string|Garp_Model_Db $theOtherModel
@return string
168673
public function getBindingModelName($theOtherModel) {
        if (!$theOtherModel instanceof Garp_Model_Db) {
            $theOtherModel = new $theOtherModel();
        }
        $modelNames = array(
            $this->getNameWithoutNamespace(),
            $theOtherModel->getNameWithoutNamespace()
        );
        sort($modelNames);
        $namespace = 'Model_';

        // The following makes sure the namespace used is the same as that of
        // the given models, but only if they both use the same namespace.
        $thisNamespace = $this->getNamespace();
        $theOtherNamespace = $theOtherModel->getNamespace();
        if ($thisNamespace === $theOtherNamespace && $thisNamespace !== 'Model') {
            $namespace = $thisNamespace . '_Model_';
        }
        $bindingModelName = $namespace . implode('', $modelNames);
        return $bindingModelName;
    }
1239040
private function getClassMetadataDefinition($model)
    {
        $definition = new Definition('Doctrine\ORM\Mapping\ClassMetadata');
        $definition
            ->setFactory([
                new Reference($this->getEntityManagerServiceKey()),
                'getClassMetadata',
            ])
            ->setArguments([$model])
            ->setPublic(false);

        return $definition;
    }
662281
protected function _combineResultsWithBindings(Garp_Model $model, $data) {
        if (!$data) {
            return;
        }
        $tableName = $model->getName();
        $bindings = $model->getBindings();
        if (empty($bindings)) {
            return;
        }
        // check if it's a rowset or a single row
        if (!$data instanceof Garp_Db_Table_Rowset) {
            $data = array($data);
        }
        foreach ($bindings as $binding => $bindOptions) {
            /**
             * We keep tabs on the outer call to fetch() by checking getRecursion.
             * If it is 0, this is the first call in the chain. That way we can
             * clean up the recursion when we're done, since all subsequent fetch() calls
             * will happen within this one and the if ($cleanup) line ahead will only
             * fire on the first fetch(). Look at it like this:
             *
             * ```
             * fetch()
             *   cleanup = 1
             *     fetch()
             *       fetch()
             *     fetch()
             *       fetch()
             *     fetch()
             *       fetch()
             *   if (cleanup) resetRecursion()
             * ```
             */
            $cleanup = false;
            if (Garp_Model_Db_BindingManager::getRecursion(get_class($model), $binding) == 0) {
                $cleanup = true;
            }

            if (Garp_Model_Db_BindingManager::isAllowedFetch(get_class($model), $binding)) {
                Garp_Model_Db_BindingManager::registerFetch(get_class($model), $binding);

                foreach ($data as $datum) {
                    // There's no relation possible if the primary key is not
                    // among the fetched columns.
                    $prim = (array)$model->info(Zend_Db_Table::PRIMARY);
                    foreach ($prim as $key) {
                        try {
                            $datum->$key;
                        } catch (Exception $e) {
                            break 2;
                        }
                    }
                    $relatedRowset = $this->_getRelatedRowset($model, $datum, $bindOptions);
                    $datum->setRelated($binding, $relatedRowset);
                }
            }

            if ($cleanup) {
                Garp_Model_Db_BindingManager::resetRecursion(get_class($model), $binding);
            }
        }

        // return the pointer to 0
        if ($data instanceof Garp_Db_Table_Rowset) {
            $data->rewind();
        }
    }
48638
public function getModelName()
    {
        if (!$name = $this->modelName) {
            $tableName = $this->getName();

            $modelNames = [];
            foreach (explode('_', $tableName) as $word) {
                $modelNames[] = ucfirst(Inflector::singularize($word));
            } //foreach
            $modelName = implode('', $modelNames);

            $this->setModelName($name = ucfirst($this->isReservedPHPWord($modelName) ? $tableName : $modelName));
        } // if

        return $name;
    }
1237753
public function getTableName(ClassMetadataInfo $metadata)
    {
        $tableName = $metadata->getTableName();

        //## Fix for doctrine/orm >= 2.5
        if (method_exists($metadata, 'getSchemaName') && $metadata->getSchemaName()) {
            $tableName = $metadata->getSchemaName() . '.' . $tableName;
        }

        return $this->getTablePrefix() . $tableName . $this->getTableSuffix();
    }
1326433
public function getOtherModelSelectorField($currentModel = '')
    {
        $otherVersionedObjects = $this->getVersionedModels('other', true);

        $modelSelectField = DropdownField::create(
            'OtherDropdown',
            _t(__CLASS__ . '.SELECT_TYPE', 'Select a content type'),
            $otherVersionedObjects,
            $currentModel
        );
        $modelSelectField->setAttribute(
            'data-others-archive-url',
            $this->Link('/')
        );
        $modelSelectField->addExtraClass('other-model-selector');
        $modelSelectField->setEmptyString(_t(__CLASS__ . '.SELECT_EMPTY', 'Select…'));
        $modelSelectField->setHasEmptyDefault(true);

        return $modelSelectField;
    }
184813
protected function getModelFieldPrefix($model)
    {
        return (get_class($this->owner) != get_class($model)) ? get_class($this->owner) . '.' : '';
    }
78649
public function getForeignModel()
    {
        $model = $this->getFullForeignModel();

        if ($this->isModel($model)) {
            return class_basename($model);
        }

        $position = strrpos($model, '\\');

        if ($position !== false) {
            return substr($model, $position + 1);
        }

        return '';
    }
498235
public function bindWithI18nModel(Garp_Model_Db $model) {
        $i18nModel = $this->getI18nModel($model);
        $model->bindModel(
            self::I18N_MODEL_BINDING_ALIAS, array(
            'modelClass' => $i18nModel,
            'conditions' => $i18nModel->select()->from(
                $i18nModel->getName(),
                array_merge($this->_translatableFields, array(self::LANG_COLUMN))
            )
            )
        );
    }
1289923
protected function getAttributeNamesFrom($metaModelName)
    {
        $metaModel = $this->factory->getMetaModel($metaModelName);
        $result    = [];

        if (empty($metaModel)) {
            return $result;
        }

        foreach ($metaModel->getAttributes() as $attribute) {
            $name   = $attribute->getName();
            $column = $attribute->getColName();
            $type   = $attribute->get('type');

            $result[$column] = \sprintf('%s (%s - %s)', $name, $column, $type);
        }

        return $result;
    }
253769
public function getApiModel(string $p_model) : \FreeFW\Core\Model
    {
        $class = str_replace('_', '::Model::', $p_model);
        return \FreeFW\DI\DI::get($class);
    }
468495
public function getDbName()
    {
        // Special handler for "NULL" relations
        if ($this->name === "NULL") {
            return $this->name;
        }

        // Ensure that we're dealing with a DataObject.
        if (!is_subclass_of($this->model, DataObject::class)) {
            throw new InvalidArgumentException(
                "Model supplied to " . static::class . " should be an instance of DataObject."
            );
        }
        $tablePrefix = DataQuery::applyRelationPrefix($this->relation);
        $schema = DataObject::getSchema();

        if ($this->aggregate) {
            $column = $this->aggregate['column'];
            $function = $this->aggregate['function'];

            $table = $column ?
                $schema->tableForField($this->model, $column) :
                $schema->baseDataTable($this->model);

            if (!$table) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid column %s for aggregate function %s on %s',
                    $column,
                    $function,
                    $this->model
                ));
            }
            return sprintf(
                '%s("%s%s".%s)',
                $function,
                $tablePrefix,
                $table,
                $column ? "\"$column\"" : '"ID"'
            );
        }


        // Check if this column is a table on the current model
        $table = $schema->tableForField($this->model, $this->name);
        if ($table) {
            return $schema->sqlColumnForField($this->model, $this->name, $tablePrefix);
        }

        // fallback to the provided name in the event of a joined column
        // name (as the candidate class doesn't check joined records)
        $parts = explode('.', $this->fullName);
        return '"' . implode('"."', $parts) . '"';
    }
1278060
protected function getModelValueAttribute($model, $name)
    {
        $transformedName = $this->transformKey($name);
        if (is_string($model)) {
            return $model;
        } elseif (is_object($model)) {
            return object_get($model, $transformedName);
        } elseif (is_array($model)) {
            return array_get($model, $transformedName);
        }
    }
58740
protected function _getModelName($object)
    {
        $obj = explode('-', preg_replace('/[^\p{L}\p{N}-_]/u', '', $object));
        foreach ($obj as $k => $v) {
            $obj[$k] = ucfirst($v);
        }
        $class = $obj[0] . '\\Model\\' . $obj[0];
        unset($obj[0]);
        return rtrim($class . implode('', $obj)) . 'Api';
    }
917216
public function getModelName(): string
    {
        $className = get_class($this);

        $postfix = $this->getFactory()->getFactoryPostfix();
        $namespace = $this->getFactory()->getFactoryNamespace();

        if ($postfix != '') {
            $result = substr($className, strlen($namespace), strlen($postfix) * -1);
        } else {
            $result = substr($className, strlen($namespace));
        }

        return $result;
    }
1073107
public function getModelName($modelName = null)
    {
        $modelName = is_null($modelName) ? $this->argument('name') : $modelName;
        $model_name = ucfirst(class_basename($modelName));
        $plural_model_name = str_plural($model_name);
        $modelPath = $this->getModelPath($modelName);
        $modelNamespace = $this->getModelNamespace($modelPath);

        return $this->modelNames = [
            'model_namespace'           => $modelNamespace,
            'full_model_name'           => $modelNamespace.'\\'.$model_name,
            'plural_model_name'         => $plural_model_name,
            'model_name'                => $model_name,
            'table_name'                => snake_case($plural_model_name),
            'lang_name'                 => snake_case($model_name),
            'collection_model_var_name' => camel_case($plural_model_name),
            'single_model_var_name'     => camel_case($model_name),
            'model_path'                => $modelPath,
        ];
    }
1175365
public function resolveModelClassName($model)
    {
        foreach ($this->metadataFactory->getAllMetadata() as $metadata) {
            /** @var Mapping\ClassMetadata $metadata */
            foreach ($metadata->getFieldMappings() as $mapping) {
                if (is_a($model, $mapping->getName())) {
                    return $metadata->getName();
                }
            }
        }

        return null;
    }