data['url']; $hash = md5($url); $date = now(); $path = sprintf('%s/%s/%s', static::$section, $date->format('Y/m/d'), $hash); $bundle = new Bundle($path, $this->disk); if ($bundle->exists()) { throw new BundleAlreadyExists( sprintf('A bundle already exists in %s', $path) ); } $bundle->markdown()->set(''); // $bundle->metadata()->set([ // 'title' => $title, // 'date' => $date->toIso8601String(), // ]); $bundle->save(); return $path; } /** * Return a boolean value indicating if the creator can actually make the * bundle using known data. */ public function canCreateBundle(): bool { return !empty($this->data['url']); } /** * Return an array describing what kind of data the creator needs in * addition to the one it already has */ public function formSpecs(): ?array { $specs = []; if (empty($this->data['url'])) { $specs['url'] = fn () => text('Interesting link URL', '', '', true, [ 'url' => 'url', ]); } return $specs; } /** * Return a boolean value indicating if this creator in particular can * create bundles for specified section */ public static function handles(string $section, ?array $data = []): bool { return $section === static::$section; } }