get()->con->query('select 1 from `' . $dbPool->get()->prefix . 'media`'); } catch (\Exception $e) { return; } $mediaFile = \file_get_contents($data['path'] ?? ''); if ($mediaFile === false) { throw new PathException($data['path'] ?? ''); } $mediaData = \json_decode($mediaFile, true); if ($mediaData === false) { throw new \Exception(); } foreach ($mediaData as $media) { self::installMedia($dbPool, $media); } } /** * Install media element. * * @param DatabasePool $dbPool Database instance * @param array $data Media info * * @return void * * @since 1.0.0 */ private static function installMedia($dbPool, $data) : void { $collection = new Collection(); $collection->setName((string) $data['name'] ?? ''); $collection->setVirtualPath((string) $data['virtualPath'] ?? '/'); $collection->setCreatedBy((int) $data['user'] ?? 1); CollectionMapper::create($collection); } }