server/src/app/Http/Controllers/Api/DocumentController.php
author ymh <ymh.work@gmail.com>
Wed, 19 Oct 2016 21:38:23 +0200
changeset 372 796ebdbf6a25
parent 370 d7c5b43d309a
child 376 02f113d43f18
permissions -rw-r--r--
Add filter for discourse types on documents list api end point
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
namespace CorpusParole\Http\Controllers\Api;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
use Illuminate\Http\Request;
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
     6
//use Illuminate\Http\Response;
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
use CorpusParole\Http\Requests;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
use CorpusParole\Http\Controllers\Controller;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
use CorpusParole\Repositories\DocumentRepository;
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    11
use CorpusParole\Services\TranscriptManager;
329
0a2c2ad49d75 Improvce language visualization. Generalize language node selection, change language query parameters, add resolution of node name (corpus-) to lexvo controler
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
    12
use CorpusParole\Libraries\Filters\CorpusFilterManager;
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
class DocumentController extends Controller
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
{
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
    /**
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
     * Create a new controller instance.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
     */
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    19
    public function __construct(DocumentRepository $documentRepo, TranscriptManager $transcriptManager) {
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
        $this->documentRepository = $documentRepo;
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    21
        $this->transcriptManager = $transcriptManager;
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    /**
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
     * Display a listing of the resource.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
     *
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
     * @return Response
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
     */
324
92fc9d077f95 add pagination info for document list, move it to meta sub object
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    29
    public function index(Request $request)
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
    {
324
92fc9d077f95 add pagination info for document list, move it to meta sub object
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    31
        $perPage = intval($request->input('perpage', config('corpusparole.documents_per_page')));
326
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    32
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    33
        $filters = [];
369
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    34
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    35
        $languages = CorpusFilterManager::prepareLanguages($request->input('language', []));
326
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    36
        if(!empty($languages)) {
369
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    37
            $filters['language'] = $languages;
326
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    38
        }
372
796ebdbf6a25 Add filter for discourse types on documents list api end point
ymh <ymh.work@gmail.com>
parents: 370
diff changeset
    39
369
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    40
        $location = CorpusFilterManager::prepareLocation($request->input('location', ''));
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    41
        if(!empty($location)) {
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    42
            $filters['location'] = $location;
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    43
        }
372
796ebdbf6a25 Add filter for discourse types on documents list api end point
ymh <ymh.work@gmail.com>
parents: 370
diff changeset
    44
370
d7c5b43d309a add theme/subject filter to back documents api end point
ymh <ymh.work@gmail.com>
parents: 369
diff changeset
    45
        $themes = CorpusFilterManager::prepareTheme($request->input('theme', []));
d7c5b43d309a add theme/subject filter to back documents api end point
ymh <ymh.work@gmail.com>
parents: 369
diff changeset
    46
        if(!empty($themes)) {
d7c5b43d309a add theme/subject filter to back documents api end point
ymh <ymh.work@gmail.com>
parents: 369
diff changeset
    47
            $filters['themes'] = $themes;
d7c5b43d309a add theme/subject filter to back documents api end point
ymh <ymh.work@gmail.com>
parents: 369
diff changeset
    48
        }
369
796725d33b67 Add location filter to documents api end-point
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    49
372
796ebdbf6a25 Add filter for discourse types on documents list api end point
ymh <ymh.work@gmail.com>
parents: 370
diff changeset
    50
        $discourses = CorpusFilterManager::prepareDiscourse($request->input('discourse', []));
796ebdbf6a25 Add filter for discourse types on documents list api end point
ymh <ymh.work@gmail.com>
parents: 370
diff changeset
    51
        if(!empty($discourses)) {
796ebdbf6a25 Add filter for discourse types on documents list api end point
ymh <ymh.work@gmail.com>
parents: 370
diff changeset
    52
            $filters['discourses'] = $discourses;
796ebdbf6a25 Add filter for discourse types on documents list api end point
ymh <ymh.work@gmail.com>
parents: 370
diff changeset
    53
        }
796ebdbf6a25 Add filter for discourse types on documents list api end point
ymh <ymh.work@gmail.com>
parents: 370
diff changeset
    54
326
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    55
        $sort = $request->input('sort', null);
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    56
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    57
        $paginator = $this->documentRepository->paginate($filters, $perPage, config('corpusparole.pagination_page_param'), null, $sort);
226d5b17a119 - First implementation of filter for languages.
ymh <ymh.work@gmail.com>
parents: 324
diff changeset
    58
125
e550b10fe3ca add language resolver on api data
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    59
        $res = $paginator->toArray();
e550b10fe3ca add language resolver on api data
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    60
        if(array_key_exists('data', $res)) {
e550b10fe3ca add language resolver on api data
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    61
            $documents = $res['data'];
e550b10fe3ca add language resolver on api data
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    62
            unset($res['data']);
324
92fc9d077f95 add pagination info for document list, move it to meta sub object
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    63
        } else {
92fc9d077f95 add pagination info for document list, move it to meta sub object
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    64
            $documents = [];
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    65
        }
324
92fc9d077f95 add pagination info for document list, move it to meta sub object
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    66
        return response()->json([ 'documents' => $documents, 'meta' => $res]);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
    /**
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
     * Show the form for creating a new resource.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
     *
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
     * @return Response
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
     */
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
    public function create()
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
    {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
        //
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
    /**
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
     * Store a newly created resource in storage.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
     *
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
     * @param  Request  $request
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
     * @return Response
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
     */
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
    public function store(Request $request)
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
    {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
        //
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
    /**
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
     * Display the specified resource.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
     *
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    93
     * @param  string  $id
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
     * @return Response
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
     */
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 165
diff changeset
    96
    public function show(Request $request, $id)
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
    {
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    98
        $id = urldecode($id);
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 165
diff changeset
    99
        $short = filter_var($request->input('short', false), FILTER_VALIDATE_BOOLEAN);
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 165
diff changeset
   100
        $doc = $this->documentRepository->get($id, $short);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
        if(is_null($doc)) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
            abort(404);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
        }
128
bc18286e55b2 remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents: 125
diff changeset
   104
        //$this->documentRepository->resolveLexvo([$doc,]);
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   105
        return response()->json(["document" => $doc]);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
    /**
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   109
     * Display the resource transcript
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   110
     *
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   111
     * @param string $id
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   112
     * @return Response
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   113
     */
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   114
    public function transcript($id) {
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 277
diff changeset
   115
        $id= urldecode($id);
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 277
diff changeset
   116
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   117
        $doc = $this->documentRepository->get($id);
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   118
        if(is_null($doc) || is_null($doc->getTranscript()) ) {
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   119
            abort(404);
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   120
        }
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 165
diff changeset
   121
        $transcript = $doc->getTranscript();
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 165
diff changeset
   122
        $transcriptUrl = $transcript->getUrl();
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 165
diff changeset
   123
        if(empty($transcriptUrl) || empty($transcript->getConformsTo())) {
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   124
            abort(404);
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   125
        }
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 165
diff changeset
   126
        $converter = $this->transcriptManager->getConverterUrl($transcript->getConformsTo(), $doc, $transcriptUrl);
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   127
        return response()->json($converter->convertToJson());
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   128
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   129
    }
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   130
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   131
    /**
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
     * Show the form for editing the specified resource.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
     *
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
     * @param  int  $id
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
     * @return Response
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
     */
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
    public function edit($id)
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
    {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
        //
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
    /**
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   143
     * Update the specified document in storage.
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
     *
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
     * @param  Request  $request
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
     * @param  int  $id
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
     * @return Response
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
     */
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
    public function update(Request $request, $id)
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
    {
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 277
diff changeset
   151
        $id= urldecode($id);
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 277
diff changeset
   152
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   153
        $data = $request->json();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   154
        $document = $data->get('document');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   155
        $doc = $this->documentRepository->get($id);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   156
        if(is_null($doc)) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   157
            abort(404);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   158
        }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   159
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   160
        //for now, update contributors and subjects only
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   161
        $doc->setContributors($document['contributors']);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   162
        $doc->setSubjects($document['subjects']);
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   163
        $doc->addGeoInfo()->setRefLocs($document['reflocs']);
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   164
        $doc->getGeoInfo()->commit();
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   165
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   166
        $doc->setModified();
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   167
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   168
        $this->documentRepository->save($doc);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   169
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   170
        return response('', 204);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
    /**
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
     * Remove the specified resource from storage.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
     *
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
     * @param  int  $id
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
     * @return Response
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
     */
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
    public function destroy($id)
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
    {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
        //
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
}