mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-01-11 17:08:40 +00:00
added api functions
This commit is contained in:
parent
9e6238a312
commit
8fffd628da
|
|
@ -18,6 +18,7 @@ use Modules\Admin\Models\AccountMapper;
|
|||
use Modules\Tag\Models\TagMapper;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\DataStorage\Database\Mapper\ReadMapper;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
|
||||
/**
|
||||
* Media mapper class.
|
||||
|
|
@ -199,4 +200,19 @@ class MediaMapper extends DataMapperFactory
|
|||
->where('class', MediaClass::COLLECTION)
|
||||
->where('name', $name);
|
||||
}
|
||||
|
||||
public static function countInternalReferences(int $id) : int
|
||||
{
|
||||
$references = self::count()
|
||||
->where('source', $id)
|
||||
->execute();
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
$result = $query->count(self::TABLE)
|
||||
->where('media_relation_src', '=', $id)
|
||||
->execute()
|
||||
?->fetch();
|
||||
|
||||
return $references + ((int) $result[0] ?? 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user