/** * Get the storage path. * * @return string */ public function getStoragePath() { if (!($path = $this->getFilePath())) { return null; } return $this->application->getStoragePath($path); }
/** * Render a string template. * * @param $template * @param array $payload * @return string * @throws \Exception */ function render($template, array $payload = []) { $view = 'templates/' . md5($template); $path = $this->application->getStoragePath($view); if (!$this->files->isDirectory($directory = dirname($path))) { $this->files->makeDirectory($directory, 0777, true); } $this->files->put($path . '.twig', $template); return $this->view->make('storage::' . $view, $payload)->render(); }
/** * Handle the command. * * @param Application $application */ public function handle(Application $application, Filesystem $files) { if (!class_exists('TeamTNT\\TNTSearch\\TNTSearch')) { return; } if (!class_exists($this->stream->getEntryModelName())) { return; } $model = $this->stream->getEntryModel(); $index = $application->getStoragePath('search/' . $model->searchableAs() . '.index'); if ($this->stream->isSearchable() && file_exists($index)) { return; } if (!$this->stream->isSearchable() && file_exists($index)) { $files->delete($index); return; } if (!$this->stream->isSearchable()) { return; } try { app(EngineManager::class)->engine('tntsearch')->initIndex($model); } catch (\Exception $e) { // Kewl. } }
/** * Get the Builder storage path (create if it doesn't exist). * * @param string path, * * @return string */ protected function getBuilderPath($path = '') { $path = $this->application->getStoragePath(_config('config.path') . ($path ? "/{$path}" : '')); /* make sure the parent folder is a directory or parent directory is a folder */ if (!$this->files->isDirectory($parent = dirname($path))) { $this->files->makeDirectory($parent, 0777, true); } return $path; }
/** * Map additional routes. * * @param Filesystem $files * @param Application $application */ public function map(Filesystem $files, Application $application) { // Include public routes. if ($files->exists($routes = $application->getStoragePath('posts/routes.php'))) { $files->requireOnce($routes); } else { $files->requireOnce(__DIR__ . '/../resources/routes.php'); } }
/** * Handle the command. * * @param Filesystem $files * @param Application $application */ public function handle(Filesystem $files, Application $application) { $paths = ['storage', $application->getStoragePath(), 'public/assets', $application->getAssetsPath()]; foreach ($paths as $path) { if ($files->exists(base_path($path)) && !$files->isWritable(base_path($path))) { die('chmod -R 777 ' . base_path($path)); } } }
/** * Handle the command. * * @param Application $application * @param Factory $views */ public function handle(Application $application, Factory $views) { $views->composer('*', 'Anomaly\\Streams\\Platform\\View\\ViewComposer'); $views->addNamespace('streams', __DIR__ . '/../../../resources/views'); $views->addNamespace('resources', base_path('resources/views')); $views->addNamespace('storage', $application->getStoragePath()); $views->addNamespace('app', $application->getResourcesPath()); $views->addNamespace('root', base_path()); $views->addExtension('html', 'php'); }
/** * Handle the command. */ public function handle(Asset $asset, Container $container, Application $application) { $asset->addPath('public', public_path()); $asset->addPath('node', base_path('node_modules')); $asset->addPath('asset', $application->getAssetsPath()); $asset->addPath('storage', $application->getStoragePath()); $asset->addPath('download', $application->getAssetsPath('assets/downloads')); $asset->addPath('streams', $container->make('streams.path') . '/resources'); $asset->addPath('bower', $container->make('path.base') . '/bin/bower_components'); }
/** * Handle the command. * * @param Filesystem $files * @param Parser $parser * @param Application $application */ public function handle(Filesystem $files, Parser $parser, Application $application) { $data = ['class' => (new EntryClassParser())->parse($this->stream), 'title' => (new EntryTitleParser())->parse($this->stream), 'table' => (new EntryTableParser())->parse($this->stream), 'rules' => (new EntryRulesParser())->parse($this->stream), 'dates' => (new EntryDatesParser())->parse($this->stream), 'stream' => (new EntryStreamParser())->parse($this->stream), 'trashable' => (new EntryTrashableParser())->parse($this->stream), 'relations' => (new EntryRelationsParser())->parse($this->stream), 'namespace' => (new EntryNamespaceParser())->parse($this->stream), 'field_slugs' => (new EntryFieldSlugsParser())->parse($this->stream), 'searchable' => (new EntrySearchableParser())->parse($this->stream), 'relationships' => (new EntryRelationshipsParser())->parse($this->stream), 'translation_model' => (new EntryTranslationModelParser())->parse($this->stream), 'translated_attributes' => (new EntryTranslatedAttributesParser())->parse($this->stream), 'translation_foreign_key' => (new EntryTranslationForeignKeyParser())->parse($this->stream)]; $template = file_get_contents(__DIR__ . '/../../../resources/stubs/models/entry.stub'); $path = $application->getStoragePath('models/' . studly_case($this->stream->getNamespace())); $files->makeDirectory($path, 0777, true, true); $file = $path . '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug()) . 'EntryModel.php'; $files->makeDirectory(dirname($file), 0777, true, true); $files->delete($file); $files->put($file, $parser->parse($template, $data)); }
/** * Handle the comand. * * @param Parser $parser * @param Application $application */ public function handle(Parser $parser, Application $application) { $data = ['namespace' => (new EntryNamespaceParser())->parse($this->stream), 'class' => (new EntryTranslationsClassParser())->parse($this->stream), 'table' => (new EntryTranslationsTableParser())->parse($this->stream)]; $template = file_get_contents(__DIR__ . '/../../../resources/stubs/models/translation.stub'); $path = $application->getStoragePath('models/' . studly_case($this->stream->getNamespace())); $path .= '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug()); $file = $path . 'EntryTranslationsModel.php'; @unlink($file); // Don't judge me.. file_put_contents($file, $parser->parse($template, $data)); }
/** * Handle the command. * * @param Application $application */ public function handle(Application $application, Filesystem $files) { if (!class_exists('TeamTNT\\TNTSearch\\TNTSearch')) { return; } $model = $this->stream->getEntryModel(); $index = $application->getStoragePath('search/' . $model->searchableAs() . '.index'); if (!file_exists($index)) { return; } $files->delete($index); }
/** * Handle the command. * * @param Filesystem $files * @param Application $application * @return string */ public function handle(Filesystem $files, Application $application) { $path = $application->getStoragePath('models/' . studly_case($this->stream->getNamespace())); $model = $path . '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug()) . 'EntryModel.php'; if ($files->exists($model)) { $files->delete($model); } if (!$this->stream->isTranslatable()) { return; } $model = $path . '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug()) . 'EntryTranslationsModel.php'; if ($files->exists($model)) { $files->delete($model); } }
/** * Handle the command. * * @param Application $application */ public function handle(Application $application) { $loader = null; foreach (spl_autoload_functions() as $autoloader) { if ($autoloader[0] instanceof ClassLoader) { $loader = $autoloader[0]; } } if (!$loader) { throw new \Exception("The ClassLoader could not be found."); } /*if (file_exists($classmap = $application->getStoragePath('models/classmap.php'))) { $loader->addClassMap(include $classmap); return; }*/ /* @var ClassLoader $loader */ $loader->addPsr4('Anomaly\\Streams\\Platform\\Model\\', $application->getStoragePath('models')); $loader->register(); }
/** * Get the destination path the compiled entry model. * * @param StreamInterface $stream * @return string */ protected function getFilePath(StreamInterface $stream) { $path = $this->application->getStoragePath('models/' . studly_case($stream->getNamespace())); $this->files->makeDirectory($path, 0777, true, true); return $path . '/' . studly_case($stream->getNamespace()) . studly_case($stream->getSlug()) . 'EntryModel.php'; }
/** * Map additional routes. * * @param Filesystem $files * @param Application $application */ public function map(Filesystem $files, Application $application) { if ($files->exists($routes = $application->getStoragePath('redirects/routes.php'))) { $files->requireOnce($routes); } }
/** * Handle the command. * * @param RedirectRepositoryInterface $redirects * @param Application $application * @param RedirectsModule $module * @param Filesystem $files */ public function handle(RedirectRepositoryInterface $redirects, Application $application, RedirectsModule $module, Filesystem $files) { $files->makeDirectory($application->getStoragePath('redirects'), 0777, true, true); $files->put($application->getStoragePath('redirects/routes.php'), app('Anomaly\\Streams\\Platform\\Support\\String')->render($files->get($module->getPath('resources/assets/routes.template')), ['redirects' => $redirects->all()])); }
/** * Boot the service provider. * * @param Repository $config * @param Application $application */ public function boot(Repository $config, Application $application) { $config->set('search', $config->get('anomaly.module.search::engine')); $config->set('search.connections.zend.path', str_replace('storage::', $application->getStoragePath() . '/', $config->get('search.connections.zend.path'))); }
/** * Handle the command. * * @param ClassLoader $loader * @param Application $application */ public function handle(ClassLoader $loader, Application $application) { $loader->addPsr4('Anomaly\\Streams\\Platform\\Model\\', $application->getStoragePath('models')); $loader->register(); }
/** * Fired after module is uninstalled. * * @param Application $application */ public function onUninstalled(Application $application) { rmdir($application->getStoragePath('search/zend')); }
/** * Handle the command. * * @param SettingRepositoryInterface $settings * @param Application $application * @param PostsModule $module * @param Filesystem $files */ public function handle(SettingRepositoryInterface $settings, Application $application, PostsModule $module, Filesystem $files) { $files->makeDirectory($application->getStoragePath('posts'), 0777, true, true); $files->put($application->getStoragePath('posts/routes.php'), app('Anomaly\\Streams\\Platform\\Support\\String')->render($files->get($module->getPath('resources/stubs/routes.stub')), ['tag_segment' => $settings->get('anomaly.module.posts::tag_segment', 'tag'), 'module_segment' => $settings->get('anomaly.module.posts::module_segment', 'posts'), 'category_segment' => $settings->get('anomaly.module.posts::category_segment', 'category'), 'permalink_structure' => $settings->get('anomaly.module.posts::permalink_structure', '{year}/{month}/{day}/{post}')])); }
/** * Get the compiled entry model path for a stream. * * @param StreamInterface $stream * @return string */ protected function getFilePath(StreamInterface $stream) { $path = $this->application->getStoragePath('models/' . studly_case($stream->getNamespace())); $path .= '/' . studly_case($stream->getNamespace()) . studly_case($stream->getSlug()); return $path . 'EntryTranslationsModel.php'; }
/** * Fired after module is uninstalled. * * @param Application $application * @param Filesystem $files */ public function onUninstalled(Application $application, Filesystem $files) { $files->deleteDirectory($application->getStoragePath('search/zend')); }
/** * Handle the command. * * @param Application $application * @param Repository $config */ public function handle(Application $application, Repository $config, Filesystem $files) { $files->makeDirectory($application->getStoragePath('search'), 0777, true, true); $config->set('scout.tntsearch.storage', $application->getStoragePath('search')); }