/*
Given model and verb, get method name and parameter list

@param $modelName
@param $crudVerb
@return null|array
@throws \Exception
7735
public function getMethodName($modelName, $crudVerb)
    {
        // enforce we're actually hooked up to a controller
        if (!$this instanceof BaseController) {
            throw new InvalidOperationException(get_class($this));
        }
        // enforce that mapping is actually not empty
        if (0 == count($this->mapping)) {
            throw new InvalidOperationException('Mapping array must not be empty');
        }

        if (!array_key_exists($modelName, $this->mapping)) {
            $msg = 'Metadata mapping for model ' . $modelName . ' not defined';
            throw new \Exception($msg);
        }

        $this->checkCrudVerbDefined($crudVerb);
        $isOptional = in_array($crudVerb, $this->optionalVerbs);

        $lookup = $this->mapping[$modelName];
        if (!is_array($lookup)) {
            $msg = 'Metadata mapping for model ' . $modelName . ' not an array';
            throw new \Exception($msg);
        }

        if (!array_key_exists($crudVerb, $lookup)) {
            if ($isOptional) {
                // optional crud verbs don't have to be defined - so we can return null
                return null;
            }
            $msg = 'Metadata mapping for CRUD verb ' . $crudVerb . ' on model ' . $modelName . ' not defined';
            throw new \Exception($msg);
        }
        $result = $lookup[$crudVerb];
        if (!isset($result)) {
            $msg = 'Metadata mapping for CRUD verb ' . $crudVerb . ' on model ' . $modelName . ' null';
            throw new \Exception($msg);
        }

        if (!method_exists($this, $result)) {
            $msg = 'Metadata target for CRUD verb ' . $crudVerb . ' on model ' . $modelName . ' does not exist';
            throw new \Exception($msg);
        }

        $class = get_class($this);
        $parmArray = $this->getParameterNames($result);

        return ['method' => $result, 'controller' => $class, 'parameters' => $parmArray];
    }
947905
public function showDetail(ModelInterface $model, array $showFields, $allowDelete = true)
    {
        /** @var DetailActionHandler $viewHandler */
        $viewHandler = $this->actionHandlers[DetailActionHandler::class];
        $viewHandler->setView($this->view);
        $viewHandler->setRequest($this->request);
        $viewHandler->setData($model);
        $viewHandler->setShowFields($showFields);
        $viewHandler->isDelete($allowDelete);

        return $this->getResponse($viewHandler->getView($this->driver));
    }
194349
public function getRelation($modelName): ?RowInterface
    {
        $relations = $this->getRelations($modelName);
        return empty($relations) ? null : current($relations);
    }
715820
public function crudViewObject(Request $request, $object, array $templateVars = array())
    {
        if (!is_object($object)) {
            /** @var ObjectRepository $repo */
            $repo = $this->crudRepositoryForClass($this->crudObjectClass());
            $object = $repo->find($object);
        }

        if (null === $object) {
            throw new NotFoundHttpException('There is no object with this id');
        }

        if (!$this->crudViewIsGranted($object)) {
            throw new AccessDeniedException('You need the permission to view this object!');
        }

        $baseTemplateVars = array(
            'request' => $request,
            'object' => $object,
            'createRoute' => $this->crudCreateRoute(),
            'listRoute' => $this->crudListRoute(),
            'editRoute' => $this->crudEditRoute(),
            'viewRoute' => $this->crudViewRoute(),
            'deleteRoute' => $this->crudDeleteRoute(),
            'listRole' => $this->crudListRole(),
            'createRole' => $this->crudCreateRole(),
            'editRole' => $this->crudEditRole(),
            'viewRole' => $this->crudViewRole(),
            'deleteRole' => $this->crudDeleteRole(),
            'identifier' => $this->crudIdentifier(),
            'transPrefix' => $this->crudTransPrefix(),
            'objectClass' => $this->crudObjectClass(),
        );

        return $this->crudRender(
            $this->crudViewTemplate(),
            array_replace_recursive($baseTemplateVars, $templateVars)
        );
    }
814222
public function getTableName($modelName)
    {
        if (! isset($this->_unionModels[$modelName])) {
            return null;
        }

        $model = $this->_unionModels[$modelName];

        if ($model instanceof \MUtil_Model_TableModel) {
            return $model->getTableName();
        }
    }
59499
public function getRepository($modelName, $collection = null)
    {
        return $this->repositoryFactory->getRepository($this, $modelName, $collection);
    }
104900
def crud_for_model(model, urlprefix=None):
    
    model_lower = model.__name__.lower()

    if urlprefix is None:
        urlprefix = ''
    urlprefix += model_lower + '/'

    urls = crud_urls(
        model,
        list_view=CRUDListView.as_view(model=model),
        create_view=CRUDCreateView.as_view(model=model),
        detail_view=CRUDDetailView.as_view(model=model),
        update_view=CRUDUpdateView.as_view(model=model),
        delete_view=CRUDDeleteView.as_view(model=model),
        url_prefix=urlprefix,
    )
    return urls
995872
protected function getSymfonyFormFromParams($params, $name, $throwException = false)
    {
        $sfForm = $this->getParam($params, $name);

        if (null === $sfForm && false === $throwException) {
            return null;
        }

        if (!$sfForm instanceof SymfonyForm) {
            throw new \InvalidArgumentException(
                sprintf(
                    "%s parameter must be an instance of " .
                    "\Symfony\Component\Form\Form, instance of %s found",
                    $name,
                    is_object($sfForm) ? get_class($sfForm) : gettype($sfForm)
                )
            );
        }

        return $sfForm;
    }
440107
public function getSomeModels($model_name, Request $request, $paginate = 100)
    {
        $this->checkParams(func_get_args());
        $model = $this->findModel($model_name);
        $status = $request->ajax() ? 202 : 200;

        return response()->json($model->paginate($paginate), $status);
    }
45705
protected function getModelTpl($modelClassName, $tableName)
    {
        $modelTpl = str_replace(CodeTpl::CLASS_NAME_TAG, $modelClassName, CodeTpl::MODEL_TPL);

        /**
 * @var \PDOStatement $statement 
*/
        $statement = Connection::component()->read_conn->prepare('desc ' . $tableName);
        if ($result = $statement->execute()) {
            $fields = $statement->fetchAll();

            if (!$fields) {
                throw new ParamException(ErrorMsg::INVALID_PARAM);
            }

            //Assemble Attributes & Labels
            $primaryKeyAttr = '';
            $attributes = '';

            $primaryKeyLabel = '';
            $labels = '';

            $primaryKey = '';

            $primaryKeyComment = '';
            $propertyComments = '';

            $setter = '';
            $getter = '';

            foreach ($fields as $field) {
                $attrName = $field['Field'];
                $defaultValue = $this->formatValue($field['Default'], $field['Type']);
                $label = $this->formatLabel($attrName);
                $commentType = $this->getCommentType($field['Type']);
                $camelAttrName = $this->formatAttr($attrName);

                //Setter
                $setter .= <<<EOF
    public function set{$camelAttrName}(\$value)
    {
        \$this->{$attrName} = \$value;
        return \$this;
    }
EOF;
                $setter .= (str_repeat(PHP_EOL, 2));

                //Getter
                $getter .= <<<EOF
    public function get{$camelAttrName}()
    {
        return \$this->{$attrName};
    }
EOF;
                $getter .= (str_repeat(PHP_EOL, 2));

                if ($field['Key'] == 'PRI') {
                    //Primary Key
                    $primaryKey = $attrName;

                    //Primary Key Attribute
                    $primaryKeyAttr = <<<EOF
    '{$attrName}' => {$defaultValue},
EOF;
                    $primaryKeyAttr .= PHP_EOL;

                    //Primary Key Label
                    $primaryKeyLabel = <<<EOF
    '{$attrName}' => '{$label}',
EOF;
                    $primaryKeyLabel .= PHP_EOL;

                    //Primary Key Comment
                    $primaryKeyComment = <<<EOF
 * @property {$commentType} \${$attrName}
EOF;
                    $primaryKeyComment .= PHP_EOL;
                } else {
                    //Attributes
                    $attributes .= <<<EOF
        '{$attrName}' => {$defaultValue},
EOF;
                    $attributes .= PHP_EOL;

                    //Labels
                    $labels .= <<<EOF
        '{$attrName}' => '{$label}',
EOF;
                    $labels .= PHP_EOL;

                    //Property Comment
                    $propertyComments .= <<<EOF
 * @property {$commentType} \${$attrName}
EOF;
                    $propertyComments .= PHP_EOL;
                }
            }
            $modelTpl = str_replace(CodeTpl::ATTRIBUTES_TAG, rtrim($primaryKeyAttr . $attributes, PHP_EOL), $modelTpl);
            $modelTpl = str_replace(CodeTpl::LABELS_TAG, rtrim($primaryKeyLabel . $labels, PHP_EOL), $modelTpl);
            $modelTpl = str_replace(
                CodeTpl::PROPERTY_COMMENTS_TAG,
                rtrim($primaryKeyComment . $propertyComments, PHP_EOL),
                $modelTpl
            );
            $modelTpl = str_replace(CodeTpl::PRIMARY_KEY_TAG, $primaryKey, $modelTpl);
            $modelTpl = str_replace(CodeTpl::SETTER, $setter, $modelTpl);
            $modelTpl = str_replace(CodeTpl::GETTER, rtrim($getter, PHP_EOL), $modelTpl);
        }

        return str_replace(CodeTpl::TABLE_NAME_TAG, $tableName, $modelTpl);
    }
1320677
public static Method getPublicMethodNamed(Class c, String methodName) {
        for( Method m : c.getMethods() )
            if(m.getName().equals(methodName))
                return m;
        return null;
    }
618353
def get_template_names(self):
        
        names = super(CRUDMixin, self).get_template_names()
        if self.crud_template_name:
            names.append(self.crud_template_name)
        return names
1288197
private function doVerb()
    {
        switch ($this->verb) {
            case "Identify":
                return $this->identify();
                break;
            case "ListMetadataFormats":
                return $this->listMetadataFormats();
                break;
            case "ListSets":
                return $this->listSets();
                break;
            case "ListRecords":
                return $this->listRecords();
                break;
            case "ListIdentifiers":
                return $this->listIdentifiers();
                break;
            case "GetRecord":
                return $this->getRecord();
                break;
            default:
                //shouldn't be possible to come here because verb was already checked, but just in case
                throw new BadVerbException("$this->verb is not a valid verb");
        }
    }
728159
function(modelName)
	{
		modelName = modelName || '*';
		if(this._bindingIndex !== null && this.scope.hasOwnProperty(modelName)) return this._bindingIndex;
		if(this.parentView instanceof View) return this.parentView.getBindingIndex(modelName);
		return null;
	}
673170
public function fetchModelFromProvider($modelId, $providerName = null)
    {
        // @codingStandardsIgnoreStart
        @\trigger_error(
            'Use \ContaoCommunityAlliance\DcGeneral\Controller\ModelCollector::getModel()',
            E_USER_DEPRECATED
        );
        // @codingStandardsIgnoreEnd

        return $this->modelCollector->getModel($modelId, $providerName);
    }
1200628
protected function _getMethodParameters(
        MethodInjection $method = null,
        ReflectionMethod $methodReflection = null,
        array $parameters = []
    ) {
        $args = [];
        if ($methodReflection) {
            foreach ($methodReflection->getParameters() as $index => $parameter) {
                if (array_key_exists($parameter->getName(), $parameters)) {
                    $value = $parameters[$parameter->getName()];
                } elseif ($method && $method->hasParameter($index)) {
                    $value = $method->getParameter($index);
                } else {
                    // If the parameter is optional and wasn't specified,
                    // we take its default value
                    if ($parameter->isOptional()) {
                        $args[] = $this->_getParameterDefaultValue(
                            $parameter,
                            $methodReflection
                        );
                        continue;
                    }

                    throw new DefinitionException(sprintf(
                        "The parameter '%s' of %s::%s has no value defined " .
                        "or guessable",
                        $parameter->getName(),
                        $methodReflection->getDeclaringClass()->getName(),
                        $methodReflection->getName()
                    ));
                }

                if ($value instanceof ObjectDefinition\EntryReference) {
                    $args[] = $this->_container->get($value->getName());
                } else {
                    $args[] = $value;
                }
            }
        }
        return $args;
    }
359480
public function getArgument($name, $mode = self::MODE_THROW_EXCEPTION_ON_ERROR)
    {
        $this->checkGetMode($mode, __METHOD__);

        if (false === $this->hasArgument($name)) {
            if ($mode === static::MODE_THROW_EXCEPTION_ON_ERROR) {
                throw new InvalidNameException(sprintf("The argument name '%s' doesn't exist", $name));
            } elseif ($mode === static::MODE_RETURN_BOOLEAN) {
                return false;
            } elseif ($mode === static::MODE_RETURN_NULL) {
                return;
            }
        }

        return $this->collection[$name];
    }