Creates a submit a form, to use in controllers

@param $type
@param object|array $data
@param callable     $validCallback Callback to call when form is valid

@return \Symfony\Component\Form\FormView
510826
public function createAndSubmitForm($type, $data = null, callable $validCallback = null)
    {
        $form = $this->createForm($type, $data);

        if ($this->isPost()) {
            $form->handleRequest($this->getRequest());

            if ($form->isValid()) {
                if ($validCallback) {
                    $response = $validCallback($form->getData(), $form);

                    if($response instanceof Response)

                        return $response;
                }
            }
        }

        return $form->createView();
    }
424651
public function factoryFromArray(array $data, $type = null)
    {
        if ($type === null) {
            if (array_key_exists('type', $data)) {
                $type = $data['type'];
                unset($data['type']);
            } else {
                throw new \InvalidArgumentException(
                    'Parameter type not specified in PaymentDataFactory.factoryFromArray()'
                );
            }
        }

        $paymentData = $this->factory($type);
        $this->fillModel($paymentData, $data);

        return $paymentData;
    }
1216330
public function create($contentOrName, $type = null, array $data = [])
    {
        // Check if container or name is defined
        if (!(
            $contentOrName instanceof Model\ContentInterface ||
            (is_string($contentOrName) && 0 < strlen($contentOrName))
        )
        ) {
            throw new InvalidOperationException("Excepted instance of ContentInterface or string.");
        }

        // Default type if null
        if (null === $type) {
            $type = $this->defaultType;
        }

        // New instance
        $container = $this->editor->getRepository()->createContainer();
        $container->setType($type);

        // Plugin creation
        $plugin = $this->editor->getContainerPlugin($type);
        $plugin->create($container, $data);

        // Create default row
        if (!$plugin instanceof CopyPlugin) {
            $this->editor->getRowManager()->create($container);
        }

        // Add to container if available
        if ($contentOrName instanceof Model\ContentInterface) {
            $count = $contentOrName->getContainers()->count();
            $container->setPosition($count);
            $contentOrName->addContainer($container);
        } else {
            $container->setName($contentOrName);
        }

        return $container;
    }
781577
protected function createResult(array &$data, $type = null) {
		if ($type === null) {
			$type = $this->getResultType();
		}

		if ($type & self::RESULT_ARRAY) {
			return $data;
		}

		if ($type & self::RESULT_OBJECT) {
			return (object) $data;
		}

		if ($type & self::RESULT_MODEL) {
			return $this->create($data);
		}

		throw new Exceptions\InvalidResultType('Nothing to do with the type #' . $type);
	}
265883
public static function create($title = '', $data = null, $type = ButtonType::WEB_URL)
    {
        return new static($title, $data, $type);
    }
1143572
public function consistentDataValdiateRule ($callback, $validate_rule = []) {
		return function () use ($callback, $validate_rule) {
			$consistent_validate_rule = [];

			foreach ($callback() as $id => $value) {
				$consistent_validate_rule[$id] = [
					'force_validate'	=> false,
					'force_value'		=> false,
					'value'	=> $value,
					['===', static::ReadSuidSession($id), 'raise_exception', 'message' => 'トランザクション中固定値がマッチしません。target:{:title} input:{:value}, session:{:operand:0}'],
				];
			}

			return $consistent_validate_rule + $validate_rule;
		};
	}
862319
public function createFormBuilder($data = null, array $options = array())
    {
        $type = 'Symfony\Component\Form\Extension\Core\Type\FormType';
        return $this->container->get('form.factory')->createBuilder($type, $data, $options);
    }
400855
public function create($formClass, array $options = [], array $data = [])
    {
        $class = $this->getNamespaceFromConfig() . $formClass;

        if (!class_exists($class)) {
            throw new \InvalidArgumentException(
                'Form class with name ' . $class . ' does not exist.'
            );
        }

        $form = $this->setDependenciesAndOptions($this->container->make($class), $options, $data);

        $form->buildForm();

        $this->eventDispatcher->dispatch(new AfterFormCreation($form));

        $form->filterFields();

        return $form;
    }
1109954
public function createObjectType() : ObjectConstructorCallbackDefiner
    {
        return new ObjectConstructorCallbackDefiner($this->class, function (callable $typeCallback) {
            $this->createObjectCallback = function (array $input) use ($typeCallback) {
                $className = $this->class->getClassName();

                /** @var ValueObject $valueObject */
                $valueObject = $typeCallback($input);

                if (!($valueObject instanceof $className)) {
                    throw InvalidReturnValueException::format(
                        'Invalid create object callback return value: expecting class compatible with %s, %s given',
                        $className, is_string($valueObject) ? $valueObject : Debug::getType($valueObject)
                    );
                }

                return $valueObject;
            };
        });
    }
612369
private function prepareData(PropertyInterface $property, callable $dataCallback, $returnType = true)
    {
        /** @var BlockPropertyInterface $blockProperty */
        $blockProperty = $property;
        while (!($blockProperty instanceof BlockPropertyInterface)) {
            $blockProperty = $blockProperty->getProperty();
        }

        $data = [];
        for ($i = 0; $i < $blockProperty->getLength(); ++$i) {
            $blockPropertyType = $blockProperty->getProperties($i);

            if ($returnType) {
                $type = $blockPropertyType->getName();
                $data[$i] = ['type' => $type];
            }

            foreach ($blockPropertyType->getChildProperties() as $childProperty) {
                $contentType = $this->contentTypeManager->get($childProperty->getContentTypeName());
                $data[$i][$childProperty->getName()] = $dataCallback($contentType, $childProperty);
            }
        }

        if (!$property->getIsMultiple() && count($data) > 0) {
            $data = $data[0];
        }

        return $data;
    }
1141029
public function getFormBuilder(Action $action, $data, array $options = []): FormBuilderInterface
    {
        return $this->baseFormHelper->getFormBuilder($action, $data, $options);
    }
1259040
public function validateDataWithRules(array $data, array $validateRules, array $validateMessages = [], array $parametricConverter = [])
    {
        foreach ($validateRules as $key => $rules) {
            $value = array_key_exists($key, $data) ? $data[$key] : null;

            if (array_key_exists('nullable', $rules) && $rules['nullable'] && is_null($value)) {
                continue;
            }

            unset($rules['nullable']);

            $defaultParametricConverter = (method_exists($this, 'getParametricConverter') && is_array($this->getParametricConverter())) ? $this->getParametricConverter() : [];
            $parametricConverter = array_merge($defaultParametricConverter, $parametricConverter);
            $parameter = (array_key_exists($key, $parametricConverter)) ? $parametricConverter[$key] : $key;

            foreach ($rules as $ruleName => $ruleParameter) {
                if ($ruleName === 'callback') {
                    if (!is_callable($ruleParameter)) {
                        throw new BadMethodCallException('The reference of rule named `callback` must be a valid callable. You provided ' . $this->getValueDescription($ruleParameter) . '.');
                    }

                    call_user_func($ruleParameter, $value, InvalidRequestException::class);
                } else {
                    $method = 'check'.ucfirst(Helper::camelCase($ruleName));

                    if (!method_exists($this, $method)) {
                        throw new BadMethodCallException('Call to undefined the ' .get_class($this). '::' .$method. '() validator that associated with the `' .$ruleName. '` rule');
                    }

                    if (!$this->$method($value, $ruleParameter)) {
                        $message = isset($validateMessages[$key][$ruleName]) ? $validateMessages[$key][$ruleName] : null;

                        throw new InvalidRequestException($this->formatMessage($parameter, $ruleName, $ruleParameter, $message));
                    }
                }
            }
        }
    }
1247805
public static function validate($data, $type, callable $filter=null) {

        $type = strtoupper($type);

        if ( !array_key_exists($type, self::$supported_types) ) {
            throw new UnexpectedValueException("Bad validation type");
        }

        return call_user_func(self::$supported_types[$type], $data, $filter);

    }
641664
public function createObjectType() : ObjectConstructorCallbackDefiner
    {
        return new ObjectConstructorCallbackDefiner($this->class, function (callable $typeCallback) {
            $this->createObjectCallback = function (array $input) use ($typeCallback) {
                $className = $this->class->getClassName();

                /** @var TypedObject|string $instanceOrType */
                $instanceOrType = $typeCallback($input);

                if (is_string($instanceOrType)) {
                    if (class_exists($instanceOrType) && is_a($instanceOrType, $className, true)) {
                        $instanceOrType = $instanceOrType::definition()->newCleanInstance();
                    }
                }

                if (!($instanceOrType instanceof $className)) {
                    throw InvalidReturnValueException::format(
                        'Invalid create object callback return value: expecting class compatible with %s, %s given',
                        $className, is_string($instanceOrType) ? $instanceOrType : Debug::getType($instanceOrType)
                    );
                }

                return $instanceOrType;
            };
        });
    }
1052978
protected static function createButton($type, $label, $htmlOptions)
    {
        $url = TbArray::popValue('url', $htmlOptions, '#');
        $ajaxOptions = TbArray::popValue('ajaxOptions', $htmlOptions, array());
        switch ($type) {
            case self::BUTTON_TYPE_HTML:
                return parent::htmlButton($label, $htmlOptions);

            case self::BUTTON_TYPE_SUBMIT:
                $htmlOptions['type'] = 'submit';
                return parent::htmlButton($label, $htmlOptions);

            case self::BUTTON_TYPE_RESET:
                $htmlOptions['type'] = 'reset';
                return parent::htmlButton($label, $htmlOptions);

            case self::BUTTON_TYPE_IMAGE:
                return parent::imageButton($label, $htmlOptions);

            case self::BUTTON_TYPE_LINKBUTTON:
                return parent::linkButton($label, $htmlOptions);

            case self::BUTTON_TYPE_AJAXLINK:
                return parent::ajaxLink($label, $url, $ajaxOptions, $htmlOptions);

            case self::BUTTON_TYPE_AJAXBUTTON:
                $htmlOptions['ajax'] = $ajaxOptions;
                return parent::htmlButton($label, $htmlOptions);

            case self::BUTTON_TYPE_INPUTBUTTON:
                return parent::button($label, $htmlOptions);

            case self::BUTTON_TYPE_INPUTSUBMIT:
                $htmlOptions['type'] = 'submit';
                return parent::button($label, $htmlOptions);

            case self::BUTTON_TYPE_LINK:
                return self::link($label, $url, $htmlOptions);

            default:
                throw new CException('Invalid button type "' . $type . '".');
        }
    }
277421
private function validateType($type)
    {
        if (!in_array($type, self::$validTypes)) {
            throw new InvalidMappingException(
                'Invalid uploadable field type reference. Must be one of: '.implode(', ', self::$validTypes)
            );
        }
    }
539280
public function putDataviewAction(DataView $dataView, ConstraintViolationListInterface $validationErrors)
    {
        if (count($validationErrors) > 0) {
            return $this->handleValidationErrors($validationErrors);
        }

        $em = $this->getDoctrine()->getManager();
        $em->persist($dataView);
        $em->flush();

        $cacheDriver = $em->getConfiguration()->getResultCacheImpl();
        $cacheDriver->deleteAll();

        $view = $this->view(['message' => 'saved'], 200);
        return $this->handleView($view);
    }