コード例 #1
0
ファイル: Checkbox.php プロジェクト: slickframework/form
 /**
  * Check whenever the checkbox state is checked
  *
  * @return bool|mixed
  */
 public function isChecked()
 {
     if (null == $this->checked) {
         $this->checked = StaticFilter::filter(Boolean::class, $this->getValue());
     }
     return $this->checked;
 }
コード例 #2
0
ファイル: Fragment.php プロジェクト: slickframework/http
 /**
  * Returns the result of filtering $value
  *
  * @param mixed $value
  *
  * @throws Exception\CannotFilterValueException
  *      If filtering $value is impossible.
  *
  * @return mixed
  */
 public function filter($value)
 {
     if (!empty($value) && strpos($value, '#') === 0) {
         $value = substr($value, 1);
     }
     return StaticFilter::filter(QueryOrFragment::class, $value);
 }
コード例 #3
0
 /**
  * Adds a filter to the filter chain
  *
  * The filter param could be a known filter alias, a FQ FilterInterface
  * class name or an object implementing FilterInterface.
  *
  * @param string|FilterInterface $filter
  *
  * @return self|$this|FilterAwareInterface
  *
  * @throws InvalidArgumentException If the provided filter is an unknown
  *      filter alias or not a valid class name or the object passed
  *      does not implement the FilterInterface interface.
  */
 public function addFilter($filter)
 {
     try {
         $this->getFilterChain()->add(StaticFilter::create($filter));
     } catch (FilterException $caught) {
         throw new InvalidArgumentException($caught->getMessage(), 0, $caught);
     }
     return $this;
 }
コード例 #4
0
ファイル: Query.php プロジェクト: slickframework/http
 /**
  * Returns the result of filtering $value
  *
  * @param mixed $query
  *
  * @throws Exception\CannotFilterValueException
  *      If filtering $value is impossible.
  *
  * @return mixed
  */
 public function filter($query)
 {
     if (!empty($query) && strpos($query, '?') === 0) {
         $query = substr($query, 1);
     }
     $parts = explode('&', $query);
     foreach ($parts as $index => $part) {
         list($key, $value) = $this->splitQueryValue($part);
         if ($value === null) {
             $parts[$index] = StaticFilter::filter(QueryOrFragment::class, $key);
             continue;
         }
         $parts[$index] = sprintf('%s=%s', StaticFilter::filter(QueryOrFragment::class, $key), StaticFilter::filter(QueryOrFragment::class, $value));
     }
     return implode('&', $parts);
 }
コード例 #5
0
ファイル: FilterTrait.php プロジェクト: slickframework/http
 /**
  * @param string $alias Filter name
  * @param mixed $value The value to filter
  *
  * @return mixed Filter output
  */
 protected function filter($alias, $value)
 {
     $this->update();
     return StaticFilter::filter($alias, $value);
 }
コード例 #6
0
ファイル: AddElements.php プロジェクト: slickframework/form
 /**
  * Sets the properties and dependencies for input elements
  *
  * @param ElementInterface $input
  * @param array $data
  */
 protected static function populateInputs(ElementInterface $input, array $data)
 {
     if ($input instanceof InputInterface) {
         self::addLabel($input, $data);
         self::addValidators($input, $data);
         self::setFilters($input, $data);
         self::addOptions($input, $data);
         if (isset($data['required'])) {
             $input->setRequired(StaticFilter::filter(Boolean::class, $data['required']));
         }
     }
     self::populateElement($input, $data);
 }