@@ -55,24 +55,24 @@ private function getParts() {
5555
5656 /**
5757 * Stores (POSTs) a newly created statement in storage.
58- * @param String $lrs_id
58+ * @param [ String => mixed] $options
5959 * @return Response
6060 */
61- public function store ($ lrs_id ) {
61+ public function store ($ options ) {
6262 if (LockerRequest::hasParam (StatementController::STATEMENT_ID )) {
6363 throw new Exceptions \Exception ('Statement ID parameter is invalid. ' );
6464 }
6565
66- return IlluminateResponse::json ($ this ->createStatements ($ lrs_id ), 200 , $ this ->getCORSHeaders ());
66+ return IlluminateResponse::json ($ this ->createStatements ($ options ), 200 , $ this ->getCORSHeaders ());
6767 }
6868
6969 /**
7070 * Updates (PUTs) Statement with the given id.
71- * @param String $lrs_id
71+ * @param [ String => mixed] $options
7272 * @return Response
7373 */
74- public function update ($ lrs_id ) {
75- $ this ->createStatements ($ lrs_id , function ($ statements ) {
74+ public function update ($ options ) {
75+ $ this ->createStatements ($ options , function ($ statements ) {
7676 $ statement_id = \LockerRequest::getParam (StatementController::STATEMENT_ID );
7777
7878 // Returns a error if identifier is not present.
@@ -90,11 +90,11 @@ public function update($lrs_id) {
9090
9191 /**
9292 * Creates statements from the content of the request.
93- * @param String $lrs_id
93+ * @param [ String => mixed] $options
9494 * @param Callable|null $modifier A function that modifies the statements before storing them.
9595 * @return AssocArray Result of storing the statements.
9696 */
97- private function createStatements ($ lrs_id , Callable $ modifier = null ) {
97+ private function createStatements ($ options , Callable $ modifier = null ) {
9898 Helpers::validateAtom (new XApiImt (explode ('; ' , LockerRequest::header ('Content-Type ' ))[0 ]));
9999
100100 // Gets parts of the request.
@@ -123,21 +123,13 @@ private function createStatements($lrs_id, Callable $modifier = null) {
123123 return $ this ->statements ->store (
124124 $ statements ,
125125 is_array ($ parts ['attachments ' ]) ? $ parts ['attachments ' ] : [],
126- [
127- 'lrs_id ' => $ lrs_id ,
128- 'authority ' => $ this ->getAuthority ()
129- ]
126+ array_merge ([
127+ 'authority ' => $ this ->getAuthority ($ options ['client ' ])
128+ ], $ options )
130129 );
131130 }
132131
133- private function getAuthority () {
134- list ($ username , $ password ) = Helpers::getUserPassFromAuth ();
135- $ client = Helpers::getClient ($ username , $ password );
136-
137- if ($ client === null ) {
138- throw new Exceptions \Exception ('No authority. ' );
139- }
140-
132+ private function getAuthority ($ client ) {
141133 return json_decode (json_encode ($ client ['authority ' ]));
142134 }
143135
0 commit comments