Example #1
0
/**
* Create a non-cached UrlMatcher
*
* @param \src\extension\manager $manager Extension manager
* @param RequestContext $context Symfony RequestContext object
* @return UrlMatcher
*/
function src_create_url_matcher(\src\extension\manager $manager, RequestContext $context, $root_path)
{
    $provider = new \src\controller\provider();
    $provider->find_routing_files($manager->get_finder());
    $routes = $provider->find($root_path)->get_routes();
    return new UrlMatcher($routes, $context);
}
Example #2
0
 /**
  * Constructor
  *
  * @param \src\template\template $template Template object
  * @param \src\user $user User object
  * @param \src\config\config $config Config object
  * @param \src\controller\provider $provider Path provider
  * @param \src\extension\manager $manager Extension manager object
  * @param \src\symfony_request $symfony_request Symfony Request object
  * @param \src\request\request_interface $request src request object
  * @param \src\filesystem $filesystem The filesystem object
  * @param string $src_root_path src root path
  * @param string $php_ext PHP file extension
  */
 public function __construct(\src\template\template $template, \src\user $user, \src\config\config $config, \src\controller\provider $provider, \src\extension\manager $manager, \src\symfony_request $symfony_request, \src\request\request_interface $request, \src\filesystem $filesystem, $src_root_path, $php_ext)
 {
     $this->template = $template;
     $this->user = $user;
     $this->config = $config;
     $this->symfony_request = $symfony_request;
     $this->request = $request;
     $this->filesystem = $filesystem;
     $this->src_root_path = $src_root_path;
     $this->php_ext = $php_ext;
     $provider->find_routing_files($manager->get_finder());
     $this->route_collection = $provider->find($src_root_path)->get_routes();
 }
Example #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $migrations = $this->extension_manager->get_finder()->set_extensions(array())->core_path('src/db/migration/data/')->get_classes();
     $tips = $migrations;
     foreach ($migrations as $migration_class) {
         foreach ($migration_class::depends_on() as $dependency) {
             $tips_key = array_search($dependency, $tips);
             if ($tips_key !== false) {
                 unset($tips[$tips_key]);
             }
         }
     }
     $output->writeln("\t\tarray(");
     foreach ($tips as $migration) {
         $output->writeln("\t\t\t'{$migration}',");
     }
     $output->writeln("\t\t);");
 }
Example #4
0
 /**
  * Sets the filepath of the metadata file
  *
  * @throws \src\extension\exception
  */
 private function set_metadata_file()
 {
     $ext_filepath = $this->extension_manager->get_extension_path($this->ext_name);
     $metadata_filepath = $this->src_root_path . $ext_filepath . 'composer.json';
     $this->metadata_file = $metadata_filepath;
     if (!file_exists($this->metadata_file)) {
         throw new \src\extension\exception($this->user->lang('FILE_NOT_FOUND', $this->metadata_file));
     }
 }
Example #5
0
 /**
  * Set custom style location (able to use directory outside of src).
  *
  * Note: Templates are still compiled to src's cache directory.
  *
  * @param string|array $names Array of names (or detailed names) or string of name of template(s) in inheritance tree order, used by extensions.
  *	E.g. array(
  *			'name' 		=> 'adm',
  *			'ext_path' 	=> 'adm/style/',
  *		)
  * @param string|array of string $paths Array of style paths, relative to current root directory
  * @return \src\template\template $this
  */
 public function set_custom_style($names, $paths)
 {
     $paths = is_string($paths) ? array($paths) : $paths;
     $names = is_string($names) ? array($names) : $names;
     // Set as __main__ namespace
     $this->twig->getLoader()->setPaths($paths);
     // Add all namespaces for all extensions
     if ($this->extension_manager instanceof \src\extension\manager) {
         $names[] = 'all';
         foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path) {
             // namespaces cannot contain /
             $namespace = str_replace('/', '_', $ext_namespace);
             $paths = array();
             foreach ($names as $template_dir) {
                 if (is_array($template_dir)) {
                     if (isset($template_dir['ext_path'])) {
                         $ext_style_template_path = $ext_path . $template_dir['ext_path'];
                         $ext_style_path = dirname($ext_style_template_path);
                         $ext_style_theme_path = $ext_style_path . 'theme/';
                     } else {
                         $ext_style_path = $ext_path . 'styles/' . $template_dir['name'] . '/';
                         $ext_style_template_path = $ext_style_path . 'template/';
                         $ext_style_theme_path = $ext_style_path . 'theme/';
                     }
                 } else {
                     $ext_style_path = $ext_path . 'styles/' . $template_dir . '/';
                     $ext_style_template_path = $ext_style_path . 'template/';
                     $ext_style_theme_path = $ext_style_path . 'theme/';
                 }
                 $is_valid_dir = false;
                 if (is_dir($ext_style_template_path)) {
                     $is_valid_dir = true;
                     $paths[] = $ext_style_template_path;
                 }
                 if (is_dir($ext_style_theme_path)) {
                     $is_valid_dir = true;
                     $paths[] = $ext_style_theme_path;
                 }
                 if ($is_valid_dir) {
                     // Add the base style directory as a safe directory
                     $this->twig->getLoader()->addSafeDirectory($ext_style_path);
                 }
             }
             $this->twig->getLoader()->setPaths($paths, $namespace);
         }
     }
     return $this;
 }
Example #6
0
 /**
  * Get the list of enabled src extensions
  *
  * Used in EVENT node
  *
  * @return array
  */
 public function get_src_extensions()
 {
     return $this->extension_manager ? $this->extension_manager->all_enabled() : array();
 }
Example #7
0
 protected function load_migrations()
 {
     $migrations = $this->extension_manager->get_finder()->core_path('src/db/migration/data/')->extension_directory('/migrations')->get_classes();
     $this->migrator->set_migrations($migrations);
 }
Example #8
0
 /**
  * Lists all the available extensions and dumps to the template
  *
  * @param  $src_extension_manager     An instance of the extension manager
  * @return null
  */
 public function list_available_exts(\src\extension\manager $src_extension_manager)
 {
     $uninstalled = array_diff_key($src_extension_manager->all_available(), $src_extension_manager->all_configured());
     $available_extension_meta_data = array();
     foreach ($uninstalled as $name => $location) {
         $md_manager = $src_extension_manager->create_extension_metadata_manager($name, $this->template);
         try {
             $meta = $md_manager->get_metadata('all');
             $available_extension_meta_data[$name] = array('META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), 'META_VERSION' => $meta['version']);
             $force_update = $this->request->variable('versioncheck_force', false);
             $updates = $this->version_check($md_manager, $force_update, !$force_update);
             $available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
             $available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
             $available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
         } catch (\src\extension\exception $e) {
             $this->template->assign_block_vars('disabled', array('META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), 'S_VERSIONCHECK' => false));
         } catch (\RuntimeException $e) {
             $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
         }
     }
     uasort($available_extension_meta_data, array($this, 'sort_extension_meta_data_table'));
     foreach ($available_extension_meta_data as $name => $block_vars) {
         $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name);
         $this->template->assign_block_vars('disabled', $block_vars);
         $this->output_actions('disabled', array('ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name)));
     }
 }
Example #9
0
 /**
  * Populate migrations for the installation
  *
  * This "installs" all migrations from (root path)/src/db/migrations/data.
  * "installs" means it adds all migrations to the migrations table, but does not
  * perform any of the actions in the migrations.
  *
  * @param \src\extension\manager $extension_manager
  * @param \src\db\migrator $migrator
  */
 function populate_migrations($extension_manager, $migrator)
 {
     $finder = $extension_manager->get_finder();
     $migrations = $finder->core_path('src/db/migration/data/')->get_classes();
     $migrator->populate_migrations($migrations);
 }