-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,503 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Forms Roles Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_API_Forms_Roles extends Ushahidi_Rest { | ||
|
||
protected $_action_map = array | ||
( | ||
Http_Request::GET => 'get', | ||
Http_Request::PUT => 'put', // Typically Update.. | ||
Http_Request::OPTIONS => 'options' | ||
); | ||
|
||
protected function _scope() | ||
{ | ||
return 'forms'; | ||
} | ||
|
||
protected function _resource() | ||
{ | ||
return 'form_roles'; | ||
} | ||
|
||
// Ushahidi_Rest | ||
public function action_get_index_collection() | ||
{ | ||
parent::action_get_index_collection(); | ||
|
||
$this->_usecase->setIdentifiers($this->request->param()); | ||
$this->_usecase->setFilters($this->request->query() + [ | ||
'form_id' => $this->request->param('form_id') | ||
]); | ||
} | ||
|
||
// Ushahidi_Rest | ||
public function action_put_index_collection() | ||
{ | ||
$this->_usecase = service('factory.usecase') | ||
->get($this->_resource(), 'update_collection') | ||
->setIdentifiers($this->_identifiers()) | ||
->setPayload($this->_payload()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Formatter for Form Role | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application | ||
* @copyright 2014 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
use Ushahidi\Core\Traits\FormatterAuthorizerMetadata; | ||
|
||
class Ushahidi_Formatter_Form_Role extends Ushahidi_Formatter_API | ||
{ | ||
use FormatterAuthorizerMetadata; | ||
|
||
public function __invoke($entity) | ||
{ | ||
$data = [ | ||
'id' => $entity->id, | ||
'url' => URL::site('forms/' . $entity->form_id . '/roles/' . $entity->id, Request::current()), | ||
'form_id' => $entity->form_id, | ||
'role_id' => $entity->role_id, | ||
]; | ||
|
||
$data = $this->add_metadata($data, $entity); | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.