예제 #1
0
 /**
  * @inheritdoc
  */
 public function validate(array $request, array $builderData)
 {
     $iblockElement = new \CIBlockElement();
     $fields['IBLOCK_ID'] = $builderData['DATA']['ID'];
     foreach ($builderData['DEFAULT_FIELDS'] as $fieldName => $field) {
         if (isset($request[$fieldName])) {
             $fields[$fieldName] = $request[$fieldName];
         }
     }
     foreach ($builderData['FIELDS'] as $fieldName => $field) {
         if (isset($request[$fieldName])) {
             $fields['PROPERTY_VALUES'][$fieldName] = $request[$fieldName];
         }
     }
     if (!$iblockElement->checkFields($fields)) {
         $iblockErrorParser = new IBlockErrorParser($builderData['FIELDS'], $builderData['DEFAULT_FIELDS']);
         $this->errorList = $iblockErrorParser->parse($iblockElement->LAST_ERROR);
     }
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function save(array $request, array $builderData)
 {
     $iblockElement = new \CIBlockElement();
     $fields['IBLOCK_ID'] = $builderData['DATA']['ID'];
     foreach ($builderData['DEFAULT_FIELDS'] as $fieldName => $field) {
         if (isset($request[$fieldName])) {
             $fields[$fieldName] = $request[$fieldName];
         }
     }
     foreach ($builderData['FIELDS'] as $fieldName => $field) {
         if (isset($request[$fieldName])) {
             $fields['PROPERTY_VALUES'][$fieldName] = $request[$fieldName];
         }
     }
     $result = $iblockElement->Add($fields);
     if (is_numeric($result)) {
         return $result;
     }
     $iblockErrorParser = new IBlockErrorParser($builderData['FIELDS'], $builderData['DEFAULT_FIELDS']);
     $this->errorList = $iblockErrorParser->parse($iblockElement->LAST_ERROR);
     return false;
 }