/** * Returns the URL of a view. * * @param Site $site * @param string $view_id The identifier of the view. * @param array|null $args The arguments to format the URL, if the URL uses a pattern. * * @return string * @throws \Exception */ public static function resolve_view_url(Site $site, $view_id, $args = null) { if (isset(self::$view_url_cache[$view_id])) { return self::$view_url_cache[$view_id]; } $target = $site->resolve_view_target($view_id); if (!$target) { return '#unknown-target-for-view-' . $view_id; } $url_pattern = $target->url_pattern; if (!Pattern::is_pattern($url_pattern)) { return self::$view_url_cache[$view_id] = $target->url; } return Pattern::from($url_pattern)->format($args); }
$core = new \ICanBoogie\Core(\ICanBoogie\array_merge_recursive(\ICanBoogie\get_autoconfig(), ['config-path' => [__DIR__ . DIRECTORY_SEPARATOR . 'config'], 'module-path' => [realpath(__DIR__ . '/../')]])); $core(); # # Install modules # $errors = new \ICanBoogie\Errors(); foreach (array_keys($core->modules->enabled_modules_descriptors) as $module_id) { # # The index on the `constructor` column of the `nodes` module clashes with SQLite, we don't # care right now, so the exception is discarted. # try { $core->modules[$module_id]->install($errors); } catch (\Exception $e) { $errors[$module_id] = "Unable to install module: " . $e->getMessage(); } } if ($errors->count()) { foreach ($errors as $error) { echo "{$module_id}: {$error}\n"; } exit(1); } # # Create a user # use Icybee\Modules\Users\User; use Icybee\Modules\Sites\Site; User::from(['username' => 'admin', 'email' => '*****@*****.**'])->save(); Site::from(['title' => 'example'])->save();
/** * Creates site record. */ protected function process_site() { global $core; $site = $core->models['sites']->one; if (!$site) { $site = new Site(); } $options = $core->session->install['site']; $site->title = $options['title']; $site->language = $options['language']; $site->timezone = $options['timezone']; $site->email = $core->session->install['user']['email']; $site->status = Site::STATUS_OK; $site->save(); if (!$core->models['pages']->one) { $page = new Page(); $page->title = "Home"; $page->is_online = true; $page->uid = 1; $page->siteid = $site->siteid; $page->save(); } }
public function provide_test_fallback_properties() { return [['constructor', [], 'nodes'], ['constructor', ['constructor' => 'images'], 'images'], ['language', ['site' => null], null], ['language', ['site' => Site::from(['language' => 'fr'])], 'fr'], ['language', ['site' => Site::from(['language' => 'fr']), 'language' => 'en'], 'en'], ['slug', [], ''], ['slug', ['title' => 'The quick brown fox'], 'the-quick-brown-fox'], ['slug', ['title' => 'The quick brown fox', 'slug' => 'quick-fox'], 'quick-fox']]; }