예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function __construct($id, $name = null)
 {
     parent::__construct($id, $name);
     $this->argsCallback = function (self $caller, string $sort = null) {
         if ($sort) {
             return Uri::parse()->addQuery(self::QUERY_SORT, $sort)->get();
         } else {
             return Uri::parse()->getQuery(self::QUERY_SORT);
         }
     };
 }
예제 #2
0
 /**
  * @param int $page
  * @param callable $argsCallback
  */
 public function __construct(int $page, callable $argsCallback = null)
 {
     parent::__construct('<nav>');
     $this->page = $page;
     if ($argsCallback) {
         $this->argsCallback = $argsCallback;
     } else {
         $this->argsCallback = function (self $caller, int $page = null) {
             if ($page) {
                 return Uri::parse()->addQuery(self::QUERY_PAGE, (string) $page)->get();
             } else {
                 return (int) Uri::parse()->getQuery(self::QUERY_PAGE);
             }
         };
     }
     $this->current = call_user_func($this->argsCallback, $this) ?: 1;
     $this->ul = new HtmlContainer('<ul>');
     $this->ul->addClass('pagination');
 }
예제 #3
0
파일: UriTest.php 프로젝트: cawaphp/cawa
 /**
  * Test that parsing and composing a valid URI returns the same URI
  *
  * @param string $uriString
  * @dataProvider validUriStringProvider
  */
 public function testValidUri(string $uriString)
 {
     $uri = Uri::parse($uriString);
     $this->assertEquals($uriString, $uri->get(false, true));
 }
예제 #4
0
파일: Grid.php 프로젝트: cawaphp/bootstrap
 /**
  * @param $filter
  *
  * @return $this|self
  */
 public function addFilter(AbstractField $filter) : self
 {
     if (!$this->filtersForm) {
         $this->filtersForm = new Form();
         $this->filtersForm->setMethod('GET')->setName($this->stateId ? $this->stateId : 'grid')->setAction(self::request()->getUri()->get());
         $this->navbar->add($this->filtersForm);
     }
     if ($this->stateId) {
         $filter->setName($this->stateId . '_' . $filter->getName());
     }
     $this->filtersForm->add($filter);
     $this->filtersForm->setAction(Uri::parse($this->filtersForm->getAction())->removeQuery($filter->getName())->get());
     if ($filter->getLabel()) {
         $filter->getLabel()->addClass('sr-only');
     }
     return $this;
 }