server/src/app/Services/LexvoResolver.php
changeset 133 821253d361d1
parent 28 b0b56e0f8c7f
child 158 366509ae2f37
equal deleted inserted replaced
132:d97eda8bc8ec 133:821253d361d1
    19         if(preg_match("/^".preg_quote(config('corpusparole.lexvo_base_url'),"/")."[[:alpha:]]{3}$/", $lexvoid) !== 1) {
    19         if(preg_match("/^".preg_quote(config('corpusparole.lexvo_base_url'),"/")."[[:alpha:]]{3}$/", $lexvoid) !== 1) {
    20             throw new LexvoResolverException("the provided id \"$id\" is not a Lexvo id");
    20             throw new LexvoResolverException("the provided id \"$id\" is not a Lexvo id");
    21         }
    21         }
    22         return $lexvoid;
    22         return $lexvoid;
    23     }
    23     }
       
    24 
    24     /**
    25     /**
    25      * Get name from Viaf id
    26      * Get name from Viaf id
    26      * @param string $id The id to resolve. Can be an url starting with http://viaf.org/viaf/
    27      * @param string $id The id to resolve. Can be an url starting with http://viaf.org/viaf/
    27      * @return a string with the name
    28      * @return a string with the name
    28      */
    29      */
    37      * @param array $ids The array of ids to resolve.
    38      * @param array $ids The array of ids to resolve.
    38      *                   Each id can be an url starting with http://viaf.org/viaf/
    39      *                   Each id can be an url starting with http://viaf.org/viaf/
    39      * @return array key is id, value is the name
    40      * @return array key is id, value is the name
    40      */
    41      */
    41     public function getNames(array $ids) {
    42     public function getNames(array $ids) {
       
    43 
       
    44         if(count($ids) > config('corpusparole.lexvo_max_ids')) {
       
    45             throw new LexvoResolverException("Too manys ids provided");
       
    46         }
    42 
    47 
    43         $lexvoids = array_map([$this, 'checkLexvoId'], $ids);
    48         $lexvoids = array_map([$this, 'checkLexvoId'], $ids);
    44         $lexvoidsMap = array_combine($lexvoids, $ids);
    49         $lexvoidsMap = array_combine($lexvoids, $ids);
    45 
    50 
    46         $results = [];
    51         $results = [];