當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。