Modules\Core\Source\Libs\Middleware\LastPagePaginatorMiddleware::setOption PHP Method

setOption() public method

public setOption ( $value, RequestParams $allParams )
$allParams app\helpers\RequestParams
    public function setOption($value, RequestParams $allParams)
    {
        $this->groupName = $this->groupName . basename($allParams->getRequest()->getUri()->getPath());
        $arParams = ['value' => $value, 'codeName' => $this->variableName, 'groupName' => $this->groupName];
        $event = new BaseContainerEvent($this->c, $arParams);
        $event = $this->c->dispatcher->dispatch('middleware.lastpagepaginator.before', $event);
        $value = $event->getParams()['value'] ? $event->getParams()['value'] : $allParams->all($this->variableName);
        $result = $this->storeParams($value);
        $arParams = ['result' => $result, 'allParams' => $allParams];
        $event = new BaseContainerEvent($this->c, $arParams);
        $this->c->dispatcher->dispatch('middleware.lastpagepaginator.after', $event);
    }

Usage Example

 public function afterInitialization()
 {
     parent::afterInitialization();
     $this->container->dispatcher->addListener('middleware.itemparpage.after', function ($event) {
         $page = new LastPagePaginatorMiddleware($event->getContainer());
         $page->setOption(1, $event->getParams()['allParams']);
     });
 }
LastPagePaginatorMiddleware