当前位置: 首页>>代码示例>>PHP>>正文


PHP FormInterface::isSynchronized方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\FormInterface::isSynchronized方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::isSynchronized方法的具体用法?PHP FormInterface::isSynchronized怎么用?PHP FormInterface::isSynchronized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\FormInterface的用法示例。


在下文中一共展示了FormInterface::isSynchronized方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

    public function validate(FormInterface $form)
    {
        if (!$form->isSynchronized()) {
            $form->addError(new FormError('The value is invalid'));
        }

        if (count($form->getExtraData()) > 0) {
            $form->addError(new FormError('This form should not contain extra fields'));
        }

        if ($form->isRoot() && isset($_SERVER['CONTENT_LENGTH'])) {
            $length = (int) $_SERVER['CONTENT_LENGTH'];
            $max = trim(ini_get('post_max_size'));

            switch (strtolower(substr($max, -1))) {
                // The 'G' modifier is available since PHP 5.1.0
                case 'g':
                    $max *= 1024;
                case 'm':
                    $max *= 1024;
                case 'k':
                    $max *= 1024;
            }

            if ($length > $max) {
                $form->addError(new FormError('The uploaded file was too large. Please try to upload a smaller file'));
            }
        }
    }
开发者ID:nacef,项目名称:symfony,代码行数:29,代码来源:DefaultValidator.php

示例2: commonTest

 /**
  *
  * @param FormInterface $form
  * @param array $formData
  */
 public function commonTest(FormInterface $form, $formData)
 {
     $this->assertTrue($form->isSynchronized());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
开发者ID:NobletSolutions,项目名称:AceBundle,代码行数:14,代码来源:BaseFormTestType.php

示例3: mapFormToData

 public function mapFormToData(FormInterface $form, &$data)
 {
     if ($form->getAttribute('property_path') !== null && $form->isSynchronized()) {
         $propertyPath = $form->getAttribute('property_path');
         // If the data is identical to the value in $data, we are
         // dealing with a reference
         $isReference = $form->getData() === $propertyPath->getValue($data);
         $byReference = $form->getAttribute('by_reference');
         if (!(is_object($data) && $isReference && $byReference)) {
             $propertyPath->setValue($data, $form->getData());
         }
     }
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:13,代码来源:PropertyPathMapper.php

示例4: extractSubmittedData

 /**
  * {@inheritdoc}
  */
 public function extractSubmittedData(FormInterface $form)
 {
     $data = array('submitted_data' => array('norm' => $this->valueExporter->exportValue($form->getNormData())), 'errors' => array());
     if ($form->getViewData() !== $form->getNormData()) {
         $data['submitted_data']['view'] = $this->valueExporter->exportValue($form->getViewData());
     }
     if ($form->getData() !== $form->getNormData()) {
         $data['submitted_data']['model'] = $this->valueExporter->exportValue($form->getData());
     }
     foreach ($form->getErrors() as $error) {
         $data['errors'][] = array('message' => $error->getMessage());
     }
     $data['synchronized'] = $this->valueExporter->exportValue($form->isSynchronized());
     return $data;
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:18,代码来源:FormDataExtractor.php

示例5: extractSubmittedData

 /**
  * {@inheritdoc}
  */
 public function extractSubmittedData(FormInterface $form)
 {
     $data = array('submitted_data' => array('norm' => $this->valueExporter->exportValue($form->getNormData())), 'errors' => array());
     if ($form->getViewData() !== $form->getNormData()) {
         $data['submitted_data']['view'] = $this->valueExporter->exportValue($form->getViewData());
     }
     if ($form->getData() !== $form->getNormData()) {
         $data['submitted_data']['model'] = $this->valueExporter->exportValue($form->getData());
     }
     foreach ($form->getErrors() as $error) {
         $errorData = array('message' => $error->getMessage(), 'origin' => is_object($error->getOrigin()) ? spl_object_hash($error->getOrigin()) : null, 'trace' => array());
         $cause = $error->getCause();
         while (null !== $cause) {
             if ($cause instanceof ConstraintViolationInterface) {
                 $errorData['trace'][] = array('class' => $this->valueExporter->exportValue(get_class($cause)), 'root' => $this->valueExporter->exportValue($cause->getRoot()), 'path' => $this->valueExporter->exportValue($cause->getPropertyPath()), 'value' => $this->valueExporter->exportValue($cause->getInvalidValue()));
                 $cause = method_exists($cause, 'getCause') ? $cause->getCause() : null;
                 continue;
             }
             if ($cause instanceof \Exception) {
                 $errorData['trace'][] = array('class' => $this->valueExporter->exportValue(get_class($cause)), 'message' => $this->valueExporter->exportValue($cause->getMessage()));
                 $cause = $cause->getPrevious();
                 continue;
             }
             $errorData['trace'][] = $cause;
             break;
         }
         $data['errors'][] = $errorData;
     }
     $data['synchronized'] = $this->valueExporter->exportValue($form->isSynchronized());
     return $data;
 }
开发者ID:xingshanghe,项目名称:symfony,代码行数:34,代码来源:FormDataExtractor.php

示例6: acceptsErrors

 /**
  * @param FormInterface $form
  *
  * @return Boolean
  */
 private function acceptsErrors(FormInterface $form)
 {
     return $this->allowNonSynchronized || $form->isSynchronized();
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:9,代码来源:ViolationMapper.php

示例7: acceptsErrors

 /**
  * @param FormInterface $form
  *
  * @return bool
  */
 private function acceptsErrors(FormInterface $form)
 {
     // Ignore non-submitted forms. This happens, for example, in PATCH
     // requests.
     // https://github.com/symfony/symfony/pull/10567
     return $form->isSubmitted() && ($this->allowNonSynchronized || $form->isSynchronized());
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:12,代码来源:ViolationMapper.php

示例8: isValidScope

 /**
  * @return Boolean
  */
 private function isValidScope()
 {
     return $this->allowNonSynchronized || $this->scope->isSynchronized();
 }
开发者ID:laubosslink,项目名称:lab,代码行数:7,代码来源:ViolationMapper.php

示例9: extractSubmittedData

 /**
  * {@inheritdoc}
  */
 public function extractSubmittedData(FormInterface $form)
 {
     $data = array('submitted_data' => array('norm' => $this->valueExporter->exportValue($form->getNormData())), 'errors' => array());
     if ($form->getViewData() !== $form->getNormData()) {
         $data['submitted_data']['view'] = $this->valueExporter->exportValue($form->getViewData());
     }
     if ($form->getData() !== $form->getNormData()) {
         $data['submitted_data']['model'] = $this->valueExporter->exportValue($form->getData());
     }
     foreach ($form->getErrors() as $error) {
         $errorData = array('message' => $error->getMessage(), 'origin' => is_object($error->getOrigin()) ? spl_object_hash($error->getOrigin()) : null);
         $cause = $error->getCause();
         if ($cause instanceof ConstraintViolationInterface) {
             $errorData['cause'] = array('root' => $this->valueExporter->exportValue($cause->getRoot()), 'path' => $this->valueExporter->exportValue($cause->getPropertyPath()), 'value' => $this->valueExporter->exportValue($cause->getInvalidValue()));
         } else {
             $errorData['cause'] = null !== $cause ? $this->valueExporter->exportValue($cause) : null;
         }
         $data['errors'][] = $errorData;
     }
     $data['synchronized'] = $this->valueExporter->exportValue($form->isSynchronized());
     return $data;
 }
开发者ID:NivalM,项目名称:VacantesJannaMotors,代码行数:25,代码来源:FormDataExtractor.php


注:本文中的Symfony\Component\Form\FormInterface::isSynchronized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。