/** * Handle the command. * * @param SettingRepositoryInterface $settings * @param Parser $parser * @return string */ public function handle(SettingRepositoryInterface $settings, Parser $parser) { $base = $settings->get('anomaly.module.posts::module_segment', 'posts'); $structure = $settings->get('anomaly.module.posts::permalink_structure', '{year}/{month}/{day}/{post}'); $data = ['year' => $this->post->created_at->format('Y'), 'month' => $this->post->created_at->format('m'), 'day' => $this->post->created_at->format('d'), 'post' => $this->post->getSlug()]; return $parser->parse($base . '/' . $structure, $data); }
public function __construct(SettingRepositoryInterface $settings, MessageBag $bag) { $this->baseUrl = $settings->get('bloveless.module.migrator::base_url'); $this->disk = $settings->get('bloveless.module.migrator::disk'); if (empty($this->baseUrl) || empty($this->disk)) { $bag->error("The base url and disk are required for this module to function. Set them in \"Settings\""); } parent::__construct(); }
/** * Handle the command. * * @param SettingRepositoryInterface $settings * @return \Anomaly\Streams\Platform\Addon\FieldType\FieldType|null */ public function handle(SettingRepositoryInterface $settings) { if (!($setting = $settings->get($this->key))) { return null; } return $setting->getFieldType('value'); }
/** * Return the form fields. * * @param SettingFormBuilder $builder */ public function handle(SettingFormBuilder $builder, SettingRepositoryInterface $settings) { $namespace = $builder->getFormEntry() . '::'; /** * Get the fields from the config system. Sections are * optionally defined the same way. */ if (!($fields = $this->config->get($namespace . 'settings/settings'))) { $fields = $fields = $this->config->get($namespace . 'settings', []); } if ($sections = $this->config->get($namespace . 'settings/sections')) { $builder->setSections($sections); } /** * Finish each field. */ foreach ($fields as $slug => &$field) { /** * Force an array. This is done later * too in normalization but we need it now * because we are normalizing / guessing our * own parameters somewhat. */ if (is_string($field)) { $field = ['type' => $field]; } // Make sure we have a config property. $field['config'] = array_get($field, 'config', []); if (trans()->has($label = array_get($field, 'label', $namespace . 'setting.' . $slug . '.label'))) { $field['label'] = trans($label); } // Default the label. $field['label'] = trans(array_get($field, 'label', $namespace . 'setting.' . $slug . '.name')); // Default the warning. if (trans()->has($warning = array_get($field, 'warning', $namespace . 'setting.' . $slug . '.warning'))) { $field['warning'] = trans($warning); } // Default the placeholder. if (trans()->has($placeholder = array_get($field, 'placeholder', $namespace . 'setting.' . $slug . '.placeholder'))) { $field['placeholder'] = trans($placeholder); } // Default the instructions. if (trans()->has($instructions = array_get($field, 'instructions', $namespace . 'setting.' . $slug . '.instructions'))) { $field['instructions'] = trans($instructions); } // Get the value defaulting to the default value. if ($value = $settings->get($namespace . $slug)) { $field['value'] = $value->getValue(); } else { $field['value'] = array_get($field['config'], 'default_value'); } } $builder->setFields($fields); }
/** * Handle the command. * * @param SettingRepositoryInterface $settings * @param ThemeCollection $themes * @param Repository $config */ public function handle(SettingRepositoryInterface $settings, ThemeCollection $themes, Repository $config) { if (!($theme = $themes->current())) { return; } if (!($fields = $config->get($theme->getNamespace('settings/settings')))) { $fields = $config->get($theme->getNamespace('settings')); } if (!$fields) { return; } foreach (array_keys($fields) as $field) { $this->variables->put($field, $settings->get($theme->getNamespace($field), array_get($fields, $field . '.config.default_value'))); } }
/** * Cache the post's HTTP response. * * @param PostInterface $post */ public function cache(PostInterface $post) { $response = $post->getResponse(); $response->setTtl($this->settings->get('anomaly.module.posts::ttl')); }
/** * Handle the command. * * @param SettingRepositoryInterface $settings * @return mixed */ public function handle(SettingRepositoryInterface $settings) { return $settings->get($this->key, $this->default); }
/** * Handle the event. */ public function handle() { $this->config->set('streams::themes.active.standard', $this->settings->get('streams::standard_theme', $this->config->get('streams::themes.active.standard'))); $this->config->set('streams::themes.active.admin', $this->settings->get('streams::admin_theme', $this->config->get('streams::themes.active.admin'))); }
/** * Handle the command. * * @param SettingRepositoryInterface $settings * @param BreadcrumbCollection $breadcrumbs */ public function handle(SettingRepositoryInterface $settings, BreadcrumbCollection $breadcrumbs) { $breadcrumbs->add('anomaly.module.posts::addon.name', $settings->get('anomaly.module.posts::module_segment', 'posts')); }
/** * 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}')])); }
public function handle(SettingRepositoryInterface $settings) { return $settings->get('anomaly.module.posts::module_segment', 'posts') . '/' . $settings->get('anomaly.module.posts::category_segment', 'category') . '/' . $this->category->getSlug(); }
/** * Resolve the post. * * @return PostInterface|null */ public function resolve() { $base = $this->settings->get('anomaly.module.posts::module_base', 'posts'); $structure = $base . '/' . $this->settings->get('anomaly.module.posts::permalink_structure', '{year}/{month}/{day}/{post}'); return $this->posts->findBySlug($this->request->segment(array_search('{post}', explode('/', $structure)) + 1)); }
public function __construct(SettingRepositoryInterface $settings) { $this->baseUrl = $settings->get('bloveless.module.migrator::base_url'); parent::__construct(); }
/** * Handle the event. */ public function handle() { $this->config->set('streams.force_https', $this->settings->get('streams::force_https', $this->config->get('streams.force_https'))); $this->config->set('streams.site_enabled', $this->settings->get('streams::site_enabled', $this->config->get('streams.site_enabled'))); $this->config->set('streams.ip_whitelist', $this->settings->get('streams::ip_whitelist', $this->config->get('streams.ip_whitelist'))); }