diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-16 17:00:08 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-16 17:00:08 +0200 |
commit | 7644950b48b094bfe5675348aefb7cf5747d325b (patch) | |
tree | a1792e21239a86f471da99b454134a5d8533ef77 /lib/public/appframework/db/mapper.php | |
parent | 8653da6c16597959c7bd0f0b202747ff96204575 (diff) | |
download | nextcloud-server-7644950b48b094bfe5675348aefb7cf5747d325b.tar.gz nextcloud-server-7644950b48b094bfe5675348aefb7cf5747d325b.zip |
Add @since tags to all methods in public namespace
* enhance the app development experience - you can look up the
method introduction right inside the code without searching
via git blame
* easier to write apps for multiple versions
Diffstat (limited to 'lib/public/appframework/db/mapper.php')
-rw-r--r-- | lib/public/appframework/db/mapper.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/public/appframework/db/mapper.php b/lib/public/appframework/db/mapper.php index 16a781f0ead..157bea36916 100644 --- a/lib/public/appframework/db/mapper.php +++ b/lib/public/appframework/db/mapper.php @@ -32,6 +32,7 @@ use OCP\IDb; /** * Simple parent class for inheriting your data access layer from. This class * may be subject to change in the future + * @since 7.0.0 */ abstract class Mapper { @@ -44,6 +45,7 @@ abstract class Mapper { * @param string $tableName the name of the table. set this to allow entity * @param string $entityClass the name of the entity that the sql should be * mapped to queries without using sql + * @since 7.0.0 */ public function __construct(IDBConnection $db, $tableName, $entityClass=null){ $this->db = $db; @@ -61,6 +63,7 @@ abstract class Mapper { /** * @return string the table name + * @since 7.0.0 */ public function getTableName(){ return $this->tableName; @@ -71,6 +74,7 @@ abstract class Mapper { * Deletes an entity from the table * @param Entity $entity the entity that should be deleted * @return Entity the deleted entity + * @since 7.0.0 - return value added in 8.1.0 */ public function delete(Entity $entity){ $sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?'; @@ -84,6 +88,7 @@ abstract class Mapper { * Creates a new entry in the db from an entity * @param Entity $entity the entity that should be created * @return Entity the saved entity with the set id + * @since 7.0.0 */ public function insert(Entity $entity){ // get updated fields to save, fields have to be set using a setter to @@ -132,6 +137,7 @@ abstract class Mapper { * @throws \InvalidArgumentException if entity has no id * @param Entity $entity the entity that should be created * @return Entity the saved entity with the set id + * @since 7.0.0 - return value was added in 8.0.0 */ public function update(Entity $entity){ // if entity wasn't changed it makes no sense to run a db query @@ -216,6 +222,7 @@ abstract class Mapper { * @param int $limit the maximum number of rows * @param int $offset from which row we want to start * @return \PDOStatement the database query result + * @since 7.0.0 */ protected function execute($sql, array $params=[], $limit=null, $offset=null){ if ($this->db instanceof IDb) { @@ -264,6 +271,7 @@ abstract class Mapper { * @throws DoesNotExistException if the item does not exist * @throws MultipleObjectsReturnedException if more than one item exist * @return array the result as row + * @since 7.0.0 */ protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null){ $stmt = $this->execute($sql, $params, $limit, $offset); @@ -289,6 +297,7 @@ abstract class Mapper { * from the current mapper name (MyEntityMapper -> MyEntity) * @param array $row the row which should be converted to an entity * @return Entity the entity + * @since 7.0.0 */ protected function mapRowToEntity($row) { return call_user_func($this->entityClass .'::fromRow', $row); @@ -302,6 +311,7 @@ abstract class Mapper { * @param int $limit the maximum number of rows * @param int $offset from which row we want to start * @return array all fetched entities + * @since 7.0.0 */ protected function findEntities($sql, array $params=[], $limit=null, $offset=null) { $stmt = $this->execute($sql, $params, $limit, $offset); @@ -328,6 +338,7 @@ abstract class Mapper { * @throws DoesNotExistException if the item does not exist * @throws MultipleObjectsReturnedException if more than one item exist * @return Entity the entity + * @since 7.0.0 */ protected function findEntity($sql, array $params=[], $limit=null, $offset=null){ return $this->mapRowToEntity($this->findOneQuery($sql, $params, $limit, $offset)); |