We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I want to write multiple action in single script file.
Current:
$method = $this->request->server->get('HTTP_METHOD'); if($method == 'GET' && preg_match('/^(.*?)\\/edit$/', $this->subpath, $matches)) { $id = $matches[1]; // show data $this->terminate(); } else if($method == 'POST' && preg_match('/^(.*?)\\/edit$/', $this->subpath, $matches)) { $id = $matches[1]; // save data $this->terminate(); } else if(preg_match('/^.*?\\/edit$/', $this->subpath)) { $this->forbidden(); }
Expected:
$d = $this->dispatcher($this->subpath); $d->on('GET', '{id}/edit', function($id) { /* show data */ return false; }); $d->on('POST', '{id}/edit', function($id) { /* save data */ return false; }); $d->on('*', '*/edit', function() { Pinoco::instance()->forbidden(); });
or
$d = $this->dispatcher($this->subpath); $d->on('GET', '{id}/edit', array($controller, 'onGetEdit')); $d->on('POST', '{id}/edit', array($controller, 'onPostEdit')); $d->on('*', '*/edit', array($this, 'forbidden'));
The text was updated successfully, but these errors were encountered:
issue renamed
Sorry, something went wrong.
Keep more flexibility #51
10795d4
Invalid commit log above?
Pinoco_Router has been implemented. It can be used as:
$this->router()->pass(array('', 'index.html',)) ->on('list', function() use($self, $data) { // ... }) ->on('show/{id}', function($id) use($self, $data) { // ... }) ->on('POST:post', function() use($self, $data) { // ... }) ->on('GET:post', array($this, 'forbidden')) ->on('*', array($this, 'notfound'));
No branches or pull requests
I want to write multiple action in single script file.
Current:
Expected:
or
The text was updated successfully, but these errors were encountered: