Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #8886] Require mandatory parameters in controller actions and CLI commands #1514

Closed
icinga-migration opened this issue Mar 27, 2015 · 6 comments
Labels
area/framework Affects third party integration/development enhancement New feature or improvement
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/8886

Created by elippmann on 2015-03-27 13:50:01 +00:00

Assignee: elippmann
Status: Resolved (closed on 2015-04-07 11:10:05 +00:00)
Target Version: 2.0.0-rc1
Last Update: 2015-04-07 11:10:05 +00:00 (in Redmine)


Controller actions and CLI commands may require mandatory parameters. Instead of writing custom code for each of them, we should introduce requiring mandatory parameters in our framework:

Action:

$host = $this->params->req('host');

Param:

public function req($name)
{
    if ($this->has($name) && strlen(($value = $this->get($name))) > 0) {
        return $value;
    }
    throw new MissingParameterException(...);
}

Web should respond with 400 (https://tools.ietf.org/html/rfc7231#section-6.5.1) and may include X-Status-Reason: Missing parameter $name.

Changesets

2015-04-07 08:48:37 +00:00 by elippmann 4d79549

Fix MissingParameterException's PHPDoc

refs #8886

2015-04-07 10:15:15 +00:00 by elippmann 0fc5801

lib: Add MissingParameterException::getParameter and ::setParameter ...

... for getting/setting the name of the missing parameter which caused the exception.

refs #8886

2015-04-07 10:17:59 +00:00 by elippmann 93b1a35

lib: Add UrlParams::req()

UrlParams::req() should be used for requiring a mandatory URL parameter.

refs #8886

2015-04-07 10:20:37 +00:00 by elippmann 002e793

lib: Add Params::req()

Params::req() should be used for requiring a mandatory CLI parameter.

refs #8886

2015-04-07 10:27:19 +00:00 by elippmann 25736cf

Return HTTP 400 on MissingParameterException

refs #8886

2015-04-07 11:06:43 +00:00 by elippmann 6b63f3d

Merge branch 'feature/require-mandatory-params-8886'

resolves #8886

Relations:

@icinga-migration
Copy link
Author

Updated by elippmann on 2015-03-27 14:31:16 +00:00

  • Blocks set to 7488

@icinga-migration
Copy link
Author

Updated by elippmann on 2015-03-27 14:31:29 +00:00

  • Blocks set to 7490

@icinga-migration
Copy link
Author

Updated by elippmann on 2015-03-27 14:34:22 +00:00

  • Description updated

@icinga-migration
Copy link
Author

Updated by elippmann on 2015-04-07 08:46:59 +00:00

  • Status changed from New to Assigned
  • Assigned to set to elippmann

@icinga-migration
Copy link
Author

Updated by elippmann on 2015-04-07 08:52:46 +00:00

  • Description updated

@icinga-migration
Copy link
Author

Updated by elippmann on 2015-04-07 11:10:05 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset 6b63f3d.

@icinga-migration icinga-migration added enhancement New feature or improvement area/framework Affects third party integration/development labels Jan 17, 2017
@icinga-migration icinga-migration added this to the 2.0.0-rc1 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/framework Affects third party integration/development enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

1 participant