Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function select_action() {
- /**
- * uri_units[1] => api
- * uri_units[2] => auth / stores
- * uri_units[3] => store_id / tag
- * uri_units[4] => components / tag_name
- * uri_units[5] => component_id
- */
- switch ($this->uri_units[2]) {
- case "auth":
- // Authorize user
- $this->action = "Authorization";
- break;
- case "stores":
- switch ($this->method) {
- case "GET":
- if (isset($this->uri_units[3])) {
- switch ($this->uri_units[3]) {
- case "tag":
- // Return all shops with provided tag_name
- $this->action = "Return shops with provided tag";
- break;
- default:
- if (isset($this->uri_units[4])) {
- if (isset($this->uri_units[5])) {
- // Return component with provided id from provided shop id
- $this->action = "Return component with provided id from provided shop id";
- } else {
- // Return all components from provided shop id
- $this->action = "Return all components from provided shop id";
- }
- } else {
- // Return shop with provided shop id
- $this->action = "Return shop with provided shop id";
- }
- }
- } else {
- // Return all shops
- $this->action = "Return all shops";
- }
- break;
- case "POST":
- if (isset($this->uri_units[3])) {
- if (isset($this->uri_units[4])) {
- // Add component
- $this->action = "Add component";
- } else {
- // Edit shop
- $this->action = "Edit shop";
- }
- } else {
- // Add new shop
- $this->action = "Add new shop";
- }
- break;
- case "DELETE":
- if (isset($this->uri_units[4])) {
- // Delete component
- $this->action = "Delete component";
- } else {
- $this->action = "Delete shop";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement