public function toBoolean(Form $form) { $left = $form->toFormValue($this->left); $right = $form->toFormValue($this->right); $value = $form->toFormValue($this->field); return $left <= $value && $value <= $right; }
public function toBoolean(Form $form) { $left = $form->toFormValue($this->left); $right = $form->toFormValue($this->right); $both = null !== $left && null !== $right; return $both && mb_strtolower($left) === mb_strtolower($right); }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { if ($object = $form->getValue('id')) { FormUtils::object2form($object, $form); } return ModelAndView::create(); }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { if (!$form->getErrors()) { ClassUtils::copyProperties($form->getValue('id'), $subject); FormUtils::form2object($form, $subject, false); return parent::run($subject, $form, $request); } return new ModelAndView(); }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { $form->markGood('id'); if (!$form->getErrors()) { FormUtils::form2object($form, $subject); return parent::run($subject, $form, $request); } return new ModelAndView(); }
public static function getLong(Form $form) { $long = array(); foreach ($form->getPrimitiveList() as $primitive) { if (strlen($primitive->getName()) > 1) { $long[] = $primitive->getName() . self::getValueType($primitive); } } return $long; }
public function toBoolean(Form $form) { Assert::isTrue($this->brackets, 'brackets must be enabled'); $subject = $form->toFormValue($this->subject); switch ($this->logic) { case self::NOT: return false === $subject; default: throw new UnsupportedMethodException("'{$this->logic}' doesn't supported yet"); } }
/** * @return ModelAndView **/ public function run(Prototyped $subject, Form $form, HttpRequest $request) { if ($object = $form->getValue('id')) { if ($object instanceof Identifiable) { $object->dao()->drop($object); return ModelAndView::create()->setView(BaseEditor::COMMAND_SUCCEEDED); } else { // already deleted $form->markMissing('id'); } } return ModelAndView::create(); }
public function toBoolean(Form $form) { $left = $form->toFormValue($this->left); $right = $this->right; $both = null !== $left && null !== $right; switch ($this->logic) { case self::IN: return $both && in_array($left, $right); case self::NOT_IN: return $both && !in_array($left, $right); default: throw new UnsupportedMethodException("'{$this->logic}' doesn't supported"); } }
public function chooseAction(HttpRequest $request) { $action = Primitive::choice('action')->setList($this->methodMap); if ($this->getDefaultAction()) { $action->setDefault($this->getDefaultAction()); } Form::create()->add($action)->import($request->getGet())->importMore($request->getPost())->importMore($request->getAttached()); if (!($command = $action->getValue())) { return $action->getDefault(); } return $command; }
/** * @return Form **/ public final function attachPrimitives(Form $form) { foreach ($this->getFormMapping() as $primitive) { $form->add($primitive); } return $form; }
/** * @return Form **/ protected function makeForm() { $form = Form::create(); foreach ($this->getFormMapping() as $primitive) { $form->add($primitive); } return $form; }
/** * @static * @param Prototyped $object * @param Form $form * @return array modified objects to save * @throws WrongArgumentException */ public static function fillObject(Prototyped $object, Form $form) { $modifications = array(); foreach ($form->getPrimitiveList() as $primitive) { try { $value = $primitive->getValue(); $field = $primitive->getName(); if (!self::hasProperty($object, $field)) { continue; } if (self::getValue($object, $field) != $value) { self::setValue($object, $field, $value); $owner = self::getOwner($object, $field); $modifications[get_class($owner) . '#' . $owner->getId()] = $owner; } } catch (WrongArgumentException $e) { throw $e; } } return $modifications; }
public function toBoolean(Form $form) { Assert::isTrue($this->brackets, 'brackets must be enabled'); $left = $form->toFormValue($this->left); $right = $form->toFormValue($this->right); $both = null !== $left && null !== $right; switch ($this->logic) { case self::EQUALS: return $both && $left == $right; case self::NOT_EQUALS: return $both && $left != $right; case self::GREATER_THAN: return $both && $left > $right; case self::GREATER_OR_EQUALS: return $both && $left >= $right; case self::LOWER_THAN: return $both && $left < $right; case self::LOWER_OR_EQUALS: return $both && $left <= $right; case self::EXPRESSION_AND: return $both && ($left && $right); case self::EXPRESSION_OR: return $both && ($left || $right); case self::ADD: return $both && $left + $right; case self::SUBSTRACT: return $both && $left - $right; case self::MULTIPLY: return $both && $left * $right; case self::DIVIDE: return $both && $right && $left / $right; case self::MOD: return $both && $right && $left % $right; case self::REGEXP: return preg_match("/{$right}/i", $left); case self::NOT_REGEXP: return !preg_match("/{$right}/i", $left); default: throw new UnsupportedMethodException("'{$this->logic}' doesn't supported yet"); } }
/** * @return Form */ public static function removePrefix(Form $form, $prefix) { $newForm = Form::create(); foreach ($form->getPrimitiveList() as $primitive) { $primitive->setName(strtr($primitive->getName(), [$prefix => ''])); $newForm->add($primitive); } return $newForm; }
/** * @return Form **/ public function fillForm(Form $form, $prefix = null) { return $form->add($this->makePrimitive($prefix . $this->name)); }
/** * @return Form **/ public function makeForm($prefix = null) { $form = Form::create(); foreach ($this->getPropertyList() as $property) { $property->fillForm($form, $prefix); } return $form; }
/** * @return Form **/ protected function createEmpty() { return Form::create(); }