예제 #1
0
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * @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
 /**
  * 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);
 }