/** * Handle the widget data. */ public function handle(ConfigurationRepositoryInterface $configuration) { $template = $configuration->get('anomaly.extension.xml_feed_widget::template', $this->widget->getId()); /* @var EditorFieldTypePresenter $presenter */ $presenter = $template->getFieldTypePresenter('value'); $this->widget->setContent($presenter->parsed(['widget' => $this->widget])); }
/** * Save the form. * * @param FormBuilder|ConfigurationFormBuilder $builder * @return bool|mixed */ public function save(FormBuilder $builder) { $namespace = $builder->getFormEntry() . '::'; /* @var FieldType $field */ foreach ($builder->getFormFields() as $field) { $this->configurations->set($namespace . $field->getField(), $builder->getScope(), $builder->getFormValue($field->getInputName())); } }
/** * Run the seeder. */ public function run() { $this->widgets->truncate(); $dashboard = $this->dashboards->findBySlug('welcome'); $widget = $this->widgets->create(['en' => ['title' => 'Recent News', 'description' => 'Recent news from http://pyrocms.com/'], 'extension' => 'anomaly.extension.xml_feed_widget', 'dashboard' => $dashboard]); $this->configuration->purge('anomaly.extension.xml_feed_widget'); $this->configuration->create(['scope' => $widget->getId(), 'key' => 'anomaly.extension.xml_feed_widget::url', 'value' => 'http://www.pyrocms.com/posts/rss.xml']); }
/** * Handle the command. * * @param ConfigurationRepositoryInterface $configuration */ public function handle(ConfigurationRepositoryInterface $configuration) { /* @var ConfigurationInterface $html */ $html = $configuration->get('anomaly.extension.html_widget::html', $this->widget->getId()); /* @var EditorFieldTypePresenter $presenter */ if ($presenter = $html->getFieldTypePresenter('value')) { $this->widget->addData('html', $presenter->parsed()); } }
/** * Return the form fields. * * @param ConfigurationFormBuilder $builder */ public function handle(ConfigurationFormBuilder $builder, ConfigurationRepositoryInterface $configuration) { $scope = $builder->getScope(); $namespace = $builder->getFormEntry() . '::'; /** * Get the fields from the config system. Sections are * optionally defined the same way. */ if (!($fields = $this->config->get($namespace . 'configuration/configuration'))) { $fields = $fields = $this->config->get($namespace . 'configuration', []); } if ($sections = $this->config->get($namespace . 'configuration/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', []); // Default the label. if (trans()->has($label = array_get($field, 'label', $namespace . 'configuration.' . $slug . '.label'))) { $field['label'] = trans($label); } // Default the label. $field['label'] = trans(array_get($field, 'label', $namespace . 'configuration.' . $slug . '.name')); // Default the warning. if (trans()->has($warning = array_get($field, 'warning', $namespace . 'configuration.' . $slug . '.warning'))) { $field['warning'] = trans($warning); } // Default the placeholder. $field['config']['placeholder'] = trans(array_get($field, 'placeholder', $namespace . 'configuration.' . $slug . '.placeholder')); // Default the instructions. if (trans()->has($instructions = array_get($field, 'instructions', $namespace . 'configuration.' . $slug . '.instructions'))) { $field['instructions'] = trans($instructions); } // Get the value defaulting to the default value. if ($applied = $configuration->get($namespace . $slug, $scope)) { $field['value'] = $applied->getValue(); } else { $field['value'] = array_get($field['config'], 'default_value'); } } $builder->setFields($fields); }
/** * Handle the command. * * @param ConfigurationRepositoryInterface $configuration * @param Repository $config * @return Gateway */ public function handle(ConfigurationRepositoryInterface $configuration, Repository $config) { $testMode = $config->get('anomaly.module.payments::config.test_mode'); if ($testMode) { $key = $configuration->presenter('anomaly.extension.stripe_gateway::test_api_key', $this->account->getSlug())->__value(); } else { $key = $configuration->presenter('anomaly.extension.stripe_gateway::live_api_key', $this->account->getSlug())->__value(); } $gateway = new Gateway(); $gateway->setApiKey($key); $gateway->setTestMode($testMode); return $gateway; }
/** * Handle the widget data. */ public function handle(\SimplePie $rss, Repository $cache, ConfigurationRepositoryInterface $configuration) { $items = $cache->remember(__METHOD__, 30, function () use($rss, $configuration) { // Let Laravel cache everything. $rss->enable_cache(false); // Hard-code this for now. $rss->set_feed_url($configuration->value('anomaly.extension.xml_feed_widget::url', $this->widget->getId(), 'http://www.pyrocms.com/posts/rss.xml')); // Make the request. $rss->init(); return $rss->get_items(0, 5); }); // Load the items to the widget's view data. $this->widget->addData('items', $items); }
/** * Handle the command. * * @param ConfigurationRepositoryInterface $configuration */ public function handle(ConfigurationRepositoryInterface $configuration) { $mode = $configuration->get('anomaly.extension.stripe_gateway::test_mode', $this->gateway->getSlug()); /* @var EncryptedFieldTypePresenter $key */ if ($mode->getValue()) { $key = $configuration->presenter('anomaly.extension.stripe_gateway::test_api_key', $this->gateway->getSlug()); } else { $key = $configuration->presenter('anomaly.extension.stripe_gateway::live_api_key', $this->gateway->getSlug()); } $gateway = new Gateway(); $gateway->setApiKey($key->decrypted()); $gateway->setTestMode($mode->getValue()); return $gateway; }
/** * Handle the command. * * @param ConfigurationRepositoryInterface $configuration * @return SIMGateway */ public function handle(ConfigurationRepositoryInterface $configuration) { /* @var EncryptedFieldTypePresenter $id */ /* @var EncryptedFieldTypePresenter $key */ /* @var EncryptedFieldTypePresenter $secret */ /* @var SettingInterface $mode */ $id = $configuration->presenter('anomaly.extension.authorizenet_aim_gateway::api_login_id', $this->gateway->getSlug()); $key = $configuration->presenter('anomaly.extension.authorizenet_aim_gateway::transaction_key', $this->gateway->getSlug()); $mode = $configuration->get('anomaly.extension.authorizenet_aim_gateway::test_mode', $this->gateway->getSlug()); $gateway = new AIMGateway(); $gateway->setTransactionKey($key->decrypted()); $gateway->setDeveloperMode($mode->getValue()); $gateway->setApiLoginId($id->decrypted()); $gateway->setTestMode($mode->getValue()); return $gateway; }
/** * Handle the command. * * @param ConfigurationRepositoryInterface $configuration */ public function handle(ConfigurationRepositoryInterface $configuration) { /* @var EncryptedFieldTypePresenter $username */ /* @var EncryptedFieldTypePresenter $password */ /* @var EncryptedFieldTypePresenter $signature */ /* @var ConfigurationInterface $mode */ $username = $configuration->presenter('anomaly.extension.paypal_express_gateway::username', $this->gateway->getSlug()); $password = $configuration->presenter('anomaly.extension.paypal_express_gateway::password', $this->gateway->getSlug()); $signature = $configuration->presenter('anomaly.extension.paypal_express_gateway::signature', $this->gateway->getSlug()); $mode = $configuration->get('anomaly.extension.paypal_express_gateway::test_mode', $this->gateway->getSlug()); $gateway = new ExpressGateway(); $gateway->setUsername($username->decrypted()); $gateway->setPassword($password->decrypted()); $gateway->setSignature($signature->decrypted()); $gateway->setTestMode($mode->getValue()); return $gateway; }
/** * Handles getting and loading the content */ public function handle(ConfigurationRepositoryInterface $configuration) { // First get the location and split it into city & state list($city, $state) = explode(',', $configuration->value('daviesgeek.extension.weather_widget::location', $this->widget->getId())); // Trim both and slug-ify the city $state = trim($state); $request_city = str_replace(" ", "_", trim($city)); // Retrieve the API key $key = $configuration->value('daviesgeek.extension.weather_widget::api_key', $this->widget->getId()); // Build the URL $url = 'http://api.wunderground.com/api/' . $key . '/conditions/q/' . $state . '/' . $request_city . '.json'; // Create a new \GuzzleHttp\Client $client = new Client(); // Make the request $res = $client->request('GET', $url); // Set the content to the twig template with the decoded JSON as the data $this->widget->setContent(view('daviesgeek.extension.weather_widget::template', json_decode($res->getBody(), true))); }