Media module, users hardening, README and token ledger

This commit is contained in:
Matthijs Iriks committed 2026-12-04 01:27:04 +01:00
1 parent f86f5aea28
commit 9f2a21fa1f
22 files changed
+827 -24

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
<?php
namespace IriksIT\Manager\Support;
use Closure;
/**
* Where media is used. A module or the host app registers a source: a closure that returns the
* texts which may contain the address of a media file (a post body, a cover, a page text).
* The media library counts the files whose address appears in them. No sources, no counts.
*/
final class MediaUsage
{
/** @var list<Closure(): iterable<mixed>> */
private array $sources = [];
/** @param Closure(): iterable<mixed> $source */
public function register(Closure $source): void
{
$this->sources[] = $source;
}
/** @return list<string> */
public function haystacks(): array
{
$texts = [];
foreach ($this->sources as $source) {
foreach ($source() as $text) {
$texts[] = is_string($text) ? $text : '';
}
}
return $texts;
}
}