Create default thumbnail

@param array $routes see routes in module config
13216
public function createDefaultThumb(array $routes)
    {
        $originalFile = pathinfo($this->url);
        $dirname = $originalFile['dirname'];
        $filename = $originalFile['filename'];
        $extension = $originalFile['extension'];

        Image::$driver = [Image::DRIVER_GD2, Image::DRIVER_GMAGICK, Image::DRIVER_IMAGICK];

        $size = Module::getDefaultThumbSize();
        $width = $size[0];
        $height = $size[1];
        $thumbUrl = "$dirname/" . $this->getThumbFilename($filename, $extension, Module::DEFAULT_THUMB_ALIAS, $width, $height);
        $basePath = Yii::getAlias($routes['basePath']);
        Image::thumbnail("$basePath/{$this->url}", $width, $height)->save("$basePath/$thumbUrl");
    }
348647
function createRoutes(routes) {
  if (isReactChildren(routes)) {
    routes = createRoutesFromReactChildren(routes);
  } else if (routes && !Array.isArray(routes)) {
    routes = [routes];
  }

  return routes;
}
557495
protected function routeDefault($segments = array(), $route)
    {
        // If we don't have any segments left - try the default controller;
        // WARNING: Directories get shifted out of the segments array!
        if (empty($segments))
        {
            $segments[0] = $this->config->routing->default_controller;
        }

        if ($this->config->routing->translate_uri_dashes === true)
        {
            $segments[0] = str_replace('-', '_', $segments[0]);
            if (isset($segments[1]))
            {
                $segments[1] = str_replace('-', '_', $segments[1]);
            }
        }

        // Prepare the values for loading
        $controller = $segments[0];
        $function = (isset($segments[1]) ? $segments[1] : $this->config->routing->default_function);

        // And prepare the Router URI
        array_unshift($segments, null);
        unset($segments[0]);
        $this->uri->rsegments = $segments;

        // Now create a matches array
        $matches = array(
                'controller' => $controller,
                'function' => $function,
                'parameters' => array_slice($this->uri->rsegments, 2)
            );

        // And finally load the callable
        $this->callable = array('\FuzeWorks\Router', 'defaultCallable');
        $this->loadCallable($matches, $route);
    }
86168
public function createGroup(array $routes = array(), Route $route = null)
    {
        return $this->create('group', array($this, $route, $routes));
    }
309334
public function createController($route)
    {
        preg_match('/(default)/', $route, $match);
        if (isset($match[0]))
            return parent::createController($route);

        return parent::createController("{$this->defaultRoute}/{$route}");
    }
1201004
public function setRoutes(array $routes): TableList
    {
        $this->checkRoutesValidity($routes);
        $this->setAttribute('routes', $routes);

        return $this;
    }
1243552
public function createBreadcrumb($route)
    {
        $breadcrumbs = [];

        while ($route !== "./" && $route !== "/") {
            $routeIndex = $this->mapRoute2IndexKey($route);
            $item["url"] = $route;
            $item["text"] = $this->getBreadcrumbTitle($this->index[$routeIndex]["file"]);
            $breadcrumbs[] = $item;
            $route = dirname($route) . "/";
        }

        krsort($breadcrumbs);
        return $breadcrumbs;
    }
372708
public function addNew(array $routes): bool
    {
        foreach ($routes as $route) {
            $this->manager->add($this->manager->createPermission('/' . trim($route, ' /')));
        }

        $this->invalidate();

        return true;
    }
689367
protected function headerLink(array $routes)
    {
        $links = [];
        foreach ($routes as $rel => $route) {
            $links[] = '<' . $this->url . $route . '>; rel="' . $rel . '"';
        }
        return implode(', ', $links);
    }
1008969
protected function populateRoutes(RouteCollection $routes)
    {
        $factory = $this->app->make(RouteHandlerFactory::class);

        $callback = include __DIR__.'/routes.php';
        $callback($routes, $factory);

        $this->app->make('events')->fire(
            new ConfigureForumRoutes($routes, $factory)
        );

        $defaultRoute = $this->app->make('flarum.settings')->get('default_route');

        if (isset($routes->getRouteData()[0]['GET'][$defaultRoute])) {
            $toDefaultController = $routes->getRouteData()[0]['GET'][$defaultRoute];
        } else {
            $toDefaultController = $factory->toForum(Content\Index::class);
        }

        $routes->get(
            '/',
            'default',
            $toDefaultController
        );
    }
423438
public function setRoutes(array $routes)
    {
        $toIterate = RouteConfig::defaultRouteTypes();
        foreach ($routes as $key => $val) {
            if (in_array($key, $toIterate) && isset($this->routes[$key])) {
                $this->routes[$key] = array_merge($this->routes[$key], $val);
            } else {
                $this->routes[$key] = $val;
            }
        }

        return $this;
    }
250203
private function saveNew($routes)
    {
        $manager = Yii::$app->getAuthManager();
        foreach ($routes as $route) {
            try {
                $r = explode('&', $route);
                $item = $manager->createPermission('/' . trim($route, '/'));
                if (count($r) > 1) {
                    $action = '/' . trim($r[0], '/');
                    if (($itemAction = $manager->getPermission($action)) === null) {
                        $itemAction = $manager->createPermission($action);
                        $manager->add($itemAction);
                    }
                    unset($r[0]);
                    foreach ($r as $part) {
                        $part = explode('=', $part);
                        $item->data['params'][$part[0]] = isset($part[1]) ? $part[1] : '';
                    }
                    $this->setDefaultRule();
                    $item->ruleName = RouteRule::RULE_NAME;
                    $manager->add($item);
                    $manager->addChild($item, $itemAction);
                } else {
                    $manager->add($item);
                }
            } catch (Exception $e) {

            }
        }
    }
522554
private function createMaps(RouteCollectionInterface $routes)
    {
        foreach ($routes->all() as $name => $route) {
            foreach ($route->getMethods() as $method) {
                $this->mMap[$method][] = $name;
            }

            foreach ($route->getSchemes() as $scheme) {
                $this->scMap[$scheme][] = $name;
            }

            $this->spMap[$route->getContext()->getStaticPath()][] = $name;
        }
    }
225774
public static function run($routes)
    {
        self::setAppPath();
        self::setFrameworkPath();
        //
        self::exception();
        self::events();
        self::model();
        self::controller();
        self::link();
        if (Component::isOn('database')) {
            self::seed();
        }
        self::filtes();
        self::alias();
        Environment::ini();
        self::mails();
        //
        self::routes($routes);
        self::commands();
    }
1219129
public function create(RouteCollection $routes): Tree
    {
        $routesArray = $routes->all();

        $routesPaths = array_map(function (Route $route) {
            return $this->serializer->serialize($route->getPath());
        }, $routesArray);

        $tree = new Tree();

        /** @var RoutePath[] $pathArray */
        foreach ($routesPaths as $index => $pathArray) {
            $route = $routesArray[$index];

            /** @var TreeNode $treeNode */
            $treeNode = $tree;

            foreach ($pathArray as $path) {
                $treeNode = $this->addPathPartToTree($treeNode, $path, $route, $index);
            }
        }

        return $tree;
    }
243459
public function createThumbs()
    {
        $path = $this->getUploadedFilePath($this->attribute);
        foreach ($this->thumbs as $profile => $config) {
            $thumbPath = static::getThumbFilePath($this->attribute, $profile);
            if (is_file($path) && !is_file($thumbPath)) {

                // setup image processor function
                if (isset($config['processor']) && is_callable($config['processor'])) {
                    $processor = $config['processor'];
                    unset($config['processor']);
                } else {
                    $processor = function (GD $thumb) use ($config) {
                        $thumb->adaptiveResize($config['width'], $config['height']);
                    };
                }

                $thumb = new GD($path, $config);
                call_user_func($processor, $thumb, $this->attribute);
                FileHelper::createDirectory(pathinfo($thumbPath, PATHINFO_DIRNAME), 0775, true);
                $thumb->save($thumbPath);
            }
        }
    }
440779
public function register(array $routes): self
    {
        foreach ($routes as $uri => $action) {
            $this->registerRoute($uri, $action);
        }

        return $this;
    }