/** * Migrate the migration. * * @param Migration $migration */ public function migrate(Migration $migration) { $this->input->read($migration); if (!($stream = $migration->getStream())) { return; } if (!$this->streams->findBySlugAndNamespace($stream['slug'], $stream['namespace'])) { $this->streams->create($migration->getStream()); } }
/** * Handle the command. * * @param MigrateStream $command * @return StreamInterface */ public function handle(MigrateStream $command) { $migration = $command->getMigration(); $stream = $migration->getStream(); if (!$stream) { return null; } if (is_string($stream)) { $stream = ['slug' => $stream]; } $addon = $migration->getAddon(); $stream['slug'] = array_get($stream, 'slug', $addon ? $addon->getSlug() : null); $stream['namespace'] = array_get($stream, 'namespace', $addon ? $addon->getSlug() : null); if ($this->streams->findBySlugAndNamespace($stream['slug'], $stream['namespace'])) { return null; } /** * If the name exists in the base array * then move it to the translated array * for the default locale. */ if ($name = array_pull($stream, 'name')) { $stream = array_add($stream, config('app.fallback_locale') . '.name', $name); } /** * If the name is not set then make one * based on a standardized pattern. */ if (!array_get($stream, config('app.fallback_locale') . '.name')) { $stream = array_add($stream, config('app.fallback_locale') . '.name', $addon ? $addon->getNamespace("stream.{$stream['slug']}.name") : null); } /** * If the description exists in the base array * then move it to the translated array * for the default locale. */ if ($description = array_pull($stream, 'description')) { $stream = array_add($stream, config('app.fallback_locale') . '.description', $description); } /** * If the name is not set then make one * based on a standardized pattern. */ if (!array_get($stream, config('app.fallback_locale') . '.description')) { $stream = array_add($stream, config('app.fallback_locale') . '.description', $addon ? $addon->getNamespace("stream.{$stream['slug']}.description") : 'foo'); } // Create the stream. return $this->streams->create($stream); }
/** * Handle the command. * * @param StreamRepositoryInterface $streams * @param Repository $config */ public function handle(StreamRepositoryInterface $streams, Repository $config) { $streams->create([$config->get('app.fallback_locale') => ['name' => $this->folder->getName(), 'description' => $this->folder->getDescription()], 'namespace' => 'files', 'slug' => $this->folder->getSlug(), 'translatable' => true, 'locked' => false]); }
/** * Handle the command. * * @param StreamRepositoryInterface $streams */ public function handle(StreamRepositoryInterface $manager, Repository $config) { $manager->create([$config->get('app.fallback_locale') => ['name' => $this->type->getName(), 'description' => $this->type->getDescription()], 'namespace' => 'partials', 'slug' => $this->type->getSlug() . '_partials', 'translatable' => true, 'locked' => false]); }