Skip to content
Snippets Groups Projects
Commit 7abe3b19 authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #8587 from Raydiation/master

Small cleanup and language detection for apps
parents 3daaf6ba d8020c35
No related branches found
No related tags found
No related merge requests found
...@@ -401,6 +401,23 @@ class OC_L10N implements \OCP\IL10N { ...@@ -401,6 +401,23 @@ class OC_L10N implements \OCP\IL10N {
self::$language = $lang; self::$language = $lang;
} }
/**
* @brief find the best language
* @param array|string $app details below
* @returns string language
*
* If $app is an array, ownCloud assumes that these are the available
* languages. Otherwise ownCloud tries to find the files in the l10n
* folder.
*
* If nothing works it returns 'en'
*/
public function getLanguageCode($app=null) {
return self::findLanguage($app);
}
/** /**
* @brief find the best language * @brief find the best language
* @param array|string $app details below * @param array|string $app details below
......
...@@ -186,7 +186,7 @@ class Server extends SimpleContainer implements IServerContainer { ...@@ -186,7 +186,7 @@ class Server extends SimpleContainer implements IServerContainer {
} }
return $router; return $router;
}); });
$this['Db'] = $this->share(function($c){ $this->registerService('Db', function($c){
return new Db(); return new Db();
}); });
} }
......
...@@ -225,12 +225,12 @@ abstract class Mapper { ...@@ -225,12 +225,12 @@ abstract class Mapper {
*/ */
protected function findOneQuery($sql, array $params=array(), $limit=null, $offset=null){ protected function findOneQuery($sql, array $params=array(), $limit=null, $offset=null){
$result = $this->execute($sql, $params, $limit, $offset); $result = $this->execute($sql, $params, $limit, $offset);
$row = $result->fetchRow(); $row = $result->fetch();
if($row === false || $row === null){ if($row === false || $row === null){
throw new DoesNotExistException('No matching entry found'); throw new DoesNotExistException('No matching entry found');
} }
$row2 = $result->fetchRow(); $row2 = $result->fetch();
//MDB2 returns null, PDO and doctrine false when no row is available //MDB2 returns null, PDO and doctrine false when no row is available
if( ! ($row2 === false || $row2 === null )) { if( ! ($row2 === false || $row2 === null )) {
throw new MultipleObjectsReturnedException('More than one result'); throw new MultipleObjectsReturnedException('More than one result');
...@@ -264,7 +264,7 @@ abstract class Mapper { ...@@ -264,7 +264,7 @@ abstract class Mapper {
$entities = array(); $entities = array();
while($row = $result->fetchRow()){ while($row = $result->fetch()){
$entities[] = $this->mapRowToEntity($row); $entities[] = $this->mapRowToEntity($row);
} }
......
...@@ -72,4 +72,18 @@ interface IL10N { ...@@ -72,4 +72,18 @@ interface IL10N {
* - params: timestamp (int/string) * - params: timestamp (int/string)
*/ */
public function l($type, $data); public function l($type, $data);
/**
* @brief find the best language
* @param array|string $app details below
* @returns string language
*
* If $app is an array, ownCloud assumes that these are the available
* languages. Otherwise ownCloud tries to find the files in the l10n
* folder.
*
* If nothing works it returns 'en'
*/
public function getLanguageCode($app=null);
} }
...@@ -51,7 +51,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase { ...@@ -51,7 +51,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
->getMock(); ->getMock();
$this->query = $this->getMock('Query', array('execute', 'bindValue')); $this->query = $this->getMock('Query', array('execute', 'bindValue'));
$this->pdoResult = $this->getMock('Result', array('fetchRow')); $this->pdoResult = $this->getMock('Result', array('fetch'));
$this->queryAt = 0; $this->queryAt = 0;
$this->prepareAt = 0; $this->prepareAt = 0;
$this->iterators = array(); $this->iterators = array();
...@@ -65,7 +65,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase { ...@@ -65,7 +65,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
* @param array $arguments the expected arguments for the prepare query * @param array $arguments the expected arguments for the prepare query
* method * method
* @param array $returnRows the rows that should be returned for the result * @param array $returnRows the rows that should be returned for the result
* of the database query. If not provided, it wont be assumed that fetchRow * of the database query. If not provided, it wont be assumed that fetch
* will be called on the result * will be called on the result
*/ */
protected function setMapperResult($sql, $arguments=array(), $returnRows=array(), protected function setMapperResult($sql, $arguments=array(), $returnRows=array(),
...@@ -77,7 +77,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase { ...@@ -77,7 +77,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
$fetchAt = $this->fetchAt; $fetchAt = $this->fetchAt;
$this->pdoResult->expects($this->any()) $this->pdoResult->expects($this->any())
->method('fetchRow') ->method('fetch')
->will($this->returnCallback( ->will($this->returnCallback(
function() use ($iterators, $fetchAt){ function() use ($iterators, $fetchAt){
$iterator = $iterators[$fetchAt]; $iterator = $iterators[$fetchAt];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment