Resolve paginator info for connection.

@param  \Illuminate\Contracts\Pagination\LengthAwarePaginator  $root
@return array
172377
public function paginatorInfoResolver(LengthAwarePaginator $root): array
    {
        return [
            'count' => $root->count(),
            'currentPage' => $root->currentPage(),
            'firstItem' => $root->firstItem(),
            'hasMorePages' => $root->hasMorePages(),
            'lastItem' => $root->lastItem(),
            'lastPage' => $root->lastPage(),
            'perPage' => $root->perPage(),
            'total' => $root->total(),
        ];
    }
1071196
public function updateConnectionByRootPageId($rootPageId)
    {
        $systemLanguages = $this->systemLanguageRepository->findSystemLanguages();
        $siteRepository = GeneralUtility::makeInstance(SiteRepository::class);
        $site = $siteRepository->getSiteByRootPageId($rootPageId);
        $rootPage = $site->getRootPage();

        $updatedSolrConnections = [];
        foreach ($systemLanguages as $languageId) {
            $connection = $this->getConfiguredSolrConnectionByRootPage($rootPage, $languageId);

            if (!empty($connection)) {
                $updatedSolrConnections[$connection['connectionKey']] = $connection;
            }
        }

        $solrConnections = $this->getAllConfigurations();
        $solrConnections = array_merge($solrConnections, $updatedSolrConnections);
        $solrConnections = $this->filterDuplicateConnections($solrConnections);
        $this->setAllConfigurations($solrConnections);
    }
830652
public function getLeftPoint(LengthAwarePaginator $paginator)
    {
        $side = $paginator->onEachSide;
        $current = $paginator->currentPage();
        $last = $paginator->lastPage();

        if (! empty($side)) {
            $x = $current + $side;
            $offset = $x >= $last ? $x - $last : 0;
            $left = $current - $side - $offset;
        }

        return ! isset($left) || $left < 1 ? 1 : $left;
    }
622386
protected function _getPaginationLinks($pagination)
    {
        $links = [
            Link::SELF => null,
            Link::FIRST => null,
            Link::LAST => null,
            Link::PREV => null,
            Link::NEXT => null,
        ];

        if (isset($pagination['self'])) {
            $links[Link::SELF] = new Link($pagination['self'], null, true);
        }

        if (isset($pagination['first'])) {
            $links[Link::FIRST] = new Link($pagination['first'], null, true);
        }

        if (isset($pagination['last'])) {
            $links[Link::LAST] = new Link($pagination['last'], null, true);
        }

        if (isset($pagination['prev'])) {
            $links[Link::PREV] = new Link($pagination['prev'], null, true);
        }

        if (isset($pagination['next'])) {
            $links[Link::NEXT] = new Link($pagination['next'], null, true);
        }

        return $links;
    }
1229341
protected function generatePaginationData($resources)
    {
        $paginationData = [
            'total'             => $resources->total(),
            'per_page'          => $resources->perPage(),
            'current_page'      => $resources->currentPage(),
            'last_page'         => $resources->lastPage(),
            'previous_page_url' => $resources->previousPageUrl(),
            'next_page_url'     => $resources->nextPageUrl(),
            'from'              => $resources->firstItem(),
            'to'                => $resources->lastItem()
        ];

        return $paginationData;
    }
1230022
public function getRedirectParameters($resource = null)
    {
        $redirect = $this->parameters->get('redirect');

        if ($this->areParametersIntentionallyEmptyArray($redirect)) {
            return [];
        }

        if (!is_array($redirect)) {
            $redirect = ['parameters' => []];
        }

        $parameters = $redirect['parameters'] ?? [];
        $parameters = $this->addExtraRedirectParameters($parameters);

        if (null !== $resource) {
            $parameters = $this->parseResourceValues($parameters, $resource);
        }

        return $parameters;
    }
1047143
public static function getFolders($root)
    {
        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::SELF_FIRST,
            RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
        );

        $paths = [
            $root,
        ];

        foreach ($iterator as $path => $dir) {
            if (true === $dir->isDir()) {
                $paths[] = $path;
            }
        }

        return $paths;
    }
783936
public function build(RootNode &$root)
    {
        $parser = new RoutingRuleParser($this->routing_rule);
        
        try{
            $section_list_set = $parser->parse();
        }
        catch(RoutingRuleParseException $e){
            throw new RouterNodeBuilderException($this->routing_rule, 'Parse failed');
        }
        
        $node = $root;
        
        foreach($section_list_set as $section_list){
            while(($section = array_shift($section_list))!==null) {
                $last = empty($section_list);
                if (is_string($section)){
                    if ($last){
                        $node->leaf($section)->bind($this->filter, $this->event);
                        break;
                    }
                    $node = $node->node($section);
                }
                else if (is_array($section)){
                    $varname = $section['varname'] ?? null;
                    $regex = $section['regex'] ?? null;
                    $type = $section['type'] ?? null;
                    $regex = empty($regex) ? '.*' : $regex;
                    if ($last){
                        $node->leaf($regex,$varname,$type)->bind($this->filter, $this->event);
                        break;
                    }
                    $node = $node->node($regex,$varname,$type);
                }
                else if ($section instanceof EmptyRoutingPathInterface){
                    if ($last){
                        $node->leaf('()')->bind($this->filter, $this->event);
                        break;
                    }
                    throw new RouterNodeBuilderException($this->routing_rule, 'Empty section not allowed before last section');
                }
                else{
                    throw new RouterNodeBuilderException($this->routing_rule, 'invalid section');
                }
            }
        }
    }
232866
public function resolveURL($resource)
    {
        // Skip blank resources
        if (empty($resource)) {
            return null;
        }

        // Resolve resource to reference
        $resource = $this->resolveResource($resource);

        // Resolve resource to url
        /** @var ResourceURLGenerator $generator */
        $generator = Injector::inst()->get(ResourceURLGenerator::class);
        return $generator->urlForResource($resource);
    }
144462
protected function getOptions($root = null)
    {
        $_SERVER['DOCUMENT_ROOT'] .= $this->getBaseUrl();

        if ($root) {
            $_SERVER['DOCUMENT_ROOT'] .= $root;
        }

        return array(
            // Output an array of data instead of returning headers/content.
            'quiet' => true,

            // In debug mode, allow access to all files, in case assets are symlinked to Bower repos for example.
            'minApp' => array('allowDirs' =>  $this->get('kernel')->isDebug() ? array('/') : array(
                // Allow all files inside the Symfony root folder to be accessed, in case asset files are symlinked to it.
                __DIR__ . '/../../../../../../',

                // Allow files in the configured combo-root to be accessed.
                $_SERVER['DOCUMENT_ROOT']
            )),

            // CSS URIs are rewritten. Don't minify JavaScript, we're just providing a combo service.
            'minifiers' => array(
                \Minify::TYPE_CSS => array('Rednose\ComboHandlerBundle\Controller\MinifyController', 'rewriteUris'),
                \Minify::TYPE_JS  => '',
            ),

            'minifierOptions' => array(
                \Minify::TYPE_CSS => array('baseUrl' => $this->getBaseUrl().$root)
            )
        );
    }
198738
public function search(FinderItem $finder = null): LengthAwarePaginator
    {
        if ($finder) {
            $this->query = $finder($this->query);
        }

        return $this->query->paginate();
    }
393572
public static function generate_options($root = null)
	{
		if ($root === null)
		{
			$root = static::query()
				->where('id', 1)
				->get_one();
		}

		$return = [];

		if ($root)
		{
			foreach ($root->children()->get() as $model)
			{
				if ($model->has_children())
				{
					$return[$model->name] = static::generate_options($model);
				}
				else
				{
					$return[$model->id] = $model->name;
				}
			}
		}

		return $return;
	}
449687
public function do_length($topic, $priority = null)
    {
        /** @var \ManaPHP\DbInterface $db */
        $db = $this->_di->getShared($this->_db);

        if ($priority === null) {
            return $db->query($this->_source)->where(['topic' => $topic, 'deleted_time' => 0])->count();
        } else {
            return $db->query($this->_source)->where(['topic' => $topic, 'deleted_time' => 0, 'priority' => $priority])->count();
        }
    }
140992
public function getPaginator( $where        = null,
                                  $order        = null,
                                  $columns      = null,
                                  $joins        = null,
                                  $quantifier   = null )
    {
        $joins = array_merge( (array) $joins, array(
            'rootParagraph' => array(
                'table'     => array(
                    'rootParagraph' => $this->getTableInSchema( 'paragraph' )
                ),
                'where'     => 'customize_rule.rootParagraphId = rootParagraph.id',
                'type'      => Sql\Select::JOIN_LEFT,
                'columns'   => array(
                    'rootType'  => 'type',
                    'rootName'  => 'name',
                ),
            ),
        ) );

        return parent::getPaginator( $where, $order, $columns, $joins, $quantifier );
    }
357299
protected function _processControllers($root)
    {
        $controllers = $this->getControllerList();
        $this->foundACOs[$root->id] = $this->_updateControllers($root, $controllers);
    }
625377
protected function findFiles($root)
    {
        $except = [];
        if ($root === null) {
            $root = CANIS_APP_VENDOR_PATH . DIRECTORY_SEPARATOR . 'canis';//. DIRECTORY_SEPARATOR .'cascade-lib';

            $except = [
                '.git/',
                '/apps/',
                '/build/',
                '/docs/',
                '/extensions/apidoc/helpers/PrettyPrinter.php',
                '/extensions/codeception/TestCase.php',
                '/extensions/codeception/DbTestCase.php',
                '/extensions/composer/',
                '/extensions/gii/components/DiffRendererHtmlInline.php',
                '/extensions/gii/generators/extension/default/*',
                '/extensions/twig/TwigSimpleFileLoader.php',
                '/framework/BaseYii.php',
                '/framework/Yii.php',
                'tests/',
                'vendor/',
                'cs/',
            ];
        }
        $root = FileHelper::normalizePath($root);
        $options = [
            'filter' => function ($path) {
                    if (is_file($path)) {
                        $file = basename($path);
                        if ($file[0] < 'A' || $file[0] > 'Z') {
                            return false;
                        }
                    }

                    return;
                },
            'only' => ['*.php'],
            'except' => array_merge($except, [
                'views/',
                'requirements/',
                'gii/generators/',
                'vendor/',
            ]),
        ];

        return FileHelper::findFiles($root, $options);
    }
408251
public function getRightPoint(LengthAwarePaginator $paginator)
    {
        $side = $paginator->onEachSide;
        $current = $paginator->currentPage();
        $last = $paginator->lastPage();

        if (! empty($side)) {
            $offset = $current <= $side ? $side - $current + 1 : 0;
            $right = $current + $side + $offset;
        }

        return ! isset($right) || $right > $last ? $last : $right;
    }