Example #1
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function handle(callable $next, AbstractObject $context)
 {
     if ($context->getElement()->hasDecorators() && !isset($context->getElement()->populated)) {
         $context->getElement()->populated = true;
         $context->getElement()->__call('populate', ['context' => $context]);
     }
     return $next();
 }
Example #2
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function handle(AbstractObject $context)
 {
     if ($context->getElement()->hasDecorators() && !isset($context->getElement()->predecorated)) {
         $context->getElement()->predecorated = true;
         $context->getElement()->preDecorate();
     }
     return $this;
 }
Example #3
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function handle(callable $next, AbstractObject $context)
 {
     if ($context->getElement()->hasDecorators() && !isset($context->getElement()->prepopulate)) {
         $context->getElement()->prepopulate = true;
         $context->getElement()->prePopulate();
     }
     return $next();
 }
Example #4
0
 /**
  * @param AbstractObject $context
  *
  * @return bool
  */
 public function overloadIsValid(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     $value = null;
     $valid = $this->validate($value);
     return $valid ? $next() : $valid;
 }
Example #5
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadDecorate(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     $this->decorateID($element);
     $this->decorateName($element);
     return $next();
 }
Example #6
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadDecorate(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     if (in_array($element->getTag(), ['input', 'select', 'button', 'textarea']) && $element->getAttribute('type') != 'hidden') {
         $this->decorateParent($element);
     }
     return $next();
 }
Example #7
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadDecorate(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     if (in_array($element->getTag(), ['form'])) {
         //$fieldset = $element->addFieldset()->setClass('crsf');
         //$csrf = $fieldset->addField(new Element\Input\Hidden\Csrf());
         // save csrf value to session
     }
     return $next();
 }
 /**
  * @param AbstractObject $context
  *
  * @return bool
  */
 public function overloadIsValid(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     $value = $element->getValue();
     // @DEBUG var_dump("value", $value);
     $valid = $this->validate($value);
     // @DEBUG var_dump(($valid ? ' valid ' : ' INVALID ') . " in " . get_class($this));
     if ($this->next) {
         // @DEBUG var_dump("next is " . get_class($this->next));
     }
     // @DEBUG var_dump("overloadIsValid #valid", $valid);
     return $valid ? $next() : $valid;
 }
Example #9
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadDecorate(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     if ($element->isStepped() || $element->isStep()) {
         $this->stepStrategy->overloadDecorate($next, $context);
     }
     return $next();
 }
Example #10
0
 public function overloadUseStrategy(callable $next, AbstractObject $context)
 {
     $this->strategy = is_object($context->getArg(0)) ? $context->getArg(0) : $context->getElement()->decoratorFactory->create($context->getArg(0));
     return $next();
 }
Example #11
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadDecorate(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     if (in_array($element->getTag(), ['input', 'select', 'button', 'textarea']) && $element->getAttribute('type') != 'hidden') {
         $this->decorateParent($element);
     } else {
         if (in_array($element->getTag(), ['div'])) {
             if ($element instanceof Element\Group) {
                 $this->decorateGroup($element);
             } elseif ($element instanceof Element\Div) {
                 $this->decorateGroup($element);
             }
         }
     }
     return $next();
 }
Example #12
0
 /**
  * @param AbstractObject $context
  *
  * @return bool
  */
 public function overloadIsSubmitted(callable $next, AbstractObject $context)
 {
     return isset($_POST['_form']) && $_POST['_form'] == $context->getElement()->getName();
 }
Example #13
0
 /**
  * @param AbstractObject $context
  *
  * @return int|string
  */
 public function overloadGetIndex(callable $next, AbstractObject $context)
 {
     $element = $context->getElement();
     if (!$element->getParent()) {
         $context->setReturn(null);
     } else {
         foreach ($element->getParent()->getChildren() as $i => $child) {
             if ($child === $element) {
                 return $i;
             }
         }
     }
     return $next();
 }
Example #14
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadRequired(callable $next, AbstractObject $context)
 {
     $context->getElement()->emptyAttribute('required');
     $this->setEnabled();
     return $next();
 }
Example #15
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadIsStep(callable $next, AbstractObject $context)
 {
     $fieldset = $context->getElement();
     return $fieldset->hasClass('step');
 }
Example #16
0
 /**
  * @param AbstractObject $context
  *
  * @return mixed
  */
 public function overloadMax(callable $next, AbstractObject $context)
 {
     $this->max = $context->getArg(0);
     $context->getElement()->setAttribute('max', $this->max);
     return $next();
 }