@param $postValues

@return \stdClass
@throws \Exception
192804
public static function createApplicationComponentFromPostValues($postValues)
    {
        if (isset($postValues['title'], $postValues['component'])) {
            $applicationComponent = new \stdClass();
            $applicationComponent->title = $postValues['title'];
            $applicationComponent->slug = StringUtil::slugify($postValues['title']);
            $applicationComponent->component = $postValues['component'];
            $applicationComponent->parameters = new \stdClass();
            if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
                foreach ($postValues['parameterNames'] as $key => $value) {
                    $applicationComponent->parameters->$value = $postValues['parameterValues'][$key];
                }
            }

            return $applicationComponent;
        } else {
            throw new \Exception('Trying to create application component with invalid data.');
        }
    }
1343114
protected function convertPointerToMagentoModels($mailValues)
    {
        $newMailValues = [];

        foreach ($mailValues as $key => $value) {
            if (is_array($value)
                && !empty($value['class']) && !empty($value['entity_id'])
            ) {
                $newMailValues[$key] = $this->createAbstractModelFromValue($value);
            }
            /** @noinspection NotOptimalIfConditionsInspection */
            elseif(is_array($value) && !empty($value['class'])) {
                $newMailValues[$key] = $this->createObjectFromValue($value);
            }
            else {
                $newMailValues[$key] = $value;
            }
        }

        return $newMailValues;
    }
1063149
public function data_preprocessing(&$defaultvalues) {
        parent::data_preprocessing($defaultvalues);
        $defaultvalues['completionentriesenabled'] = !empty($defaultvalues['completionentries']) ? 1 : 0;
        if (empty($defaultvalues['completionentries'])) {
            $defaultvalues['completionentries'] = 1;
        }
    }
1012510
public static function createSitemapItemFromPostValues($postValues)
    {
        if (isset($postValues['title'], $postValues['url'], $postValues['component'], $postValues['template'])) {
            $sitemapObject = new \stdClass();
            $sitemapObject->title = $postValues['title'];
            $sitemapObject->slug = StringUtil::slugify($postValues['title']);
            $sitemapObject->url = $postValues['url'];
            $sitemapObject->component = $postValues['component'];
            $sitemapObject->template = $postValues['template'];
            $sitemapObject->regex = isset($postValues['regex']);
            $sitemapObject->parameters = new \stdClass();
            if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
                foreach ($postValues['parameterNames'] as $key => $value) {
                    $sitemapObject->parameters->$value = $postValues['parameterValues'][$key];
                }
            }

            return $sitemapObject;
        } else {
            throw new \Exception('Trying to create sitemap item with invalid data.');
        }
    }
145432
public static function createImageSetFromPostValues($postValues)
    {
        if (isset($postValues['title'], $postValues['width'], $postValues['height'], $postValues['method'])) {
            $imageSetObject = new \stdClass();

            $imageSetObject->title = $postValues['title'];
            $imageSetObject->slug = StringUtil::slugify($postValues['title']);
            $imageSetObject->width = $postValues['width'];
            $imageSetObject->height = $postValues['height'];
            $imageSetObject->method = $postValues['method'];

            return $imageSetObject;
        } else {
            throw new \Exception('Trying to create image set with invalid data.');
        }
    }
1282816
protected function databaseValue($values)
    {
        if (!is_array($values)) {
            throw ODMException::invalidValueForType('List', ['array', 'null'], $values);
        }

        //re-index numerically
        $values = array_values($values); //TODO: Remove me? handle in CollectionPersister?

        return $values;
    }
19275
public function data_preprocessing(&$defaultvalues) {
        global $DB;

        $ctx = null;
        if ($this->current && $this->current->coursemodule) {
            $cm = get_coursemodule_from_instance('assign', $this->current->id, 0, false, MUST_EXIST);
            $ctx = context_module::instance($cm->id);
        }
        $assignment = new assign($ctx, null, null);
        if ($this->current && $this->current->course) {
            if (!$ctx) {
                $ctx = context_course::instance($this->current->course);
            }
            $course = $DB->get_record('course', array('id'=>$this->current->course), '*', MUST_EXIST);
            $assignment->set_course($course);
        }

        $draftitemid = file_get_submitted_draft_itemid('introattachments');
        file_prepare_draft_area($draftitemid, $ctx->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA,
                                0, array('subdirs' => 0));
        $defaultvalues['introattachments'] = $draftitemid;

        $assignment->plugin_data_preprocessing($defaultvalues);
    }
812218
public static function createFileFromPostValues($postValues, $filename)
    {
        $fileObject = new \stdClass();
        $fileObject->file = $filename;
        $fileObject->type = $postValues['type'];
        $fileObject->size = $postValues['size'];

        return new File($fileObject);
    }
1271675
public function addDocumentFolder($postValues)
    {
        $documentFolderObject = DocumentFolderFactory::createDocumentFolderFromPostValues($postValues);
        if ($postValues['path'] === '/') {
            $documentFolderObject->path = $postValues['path'] . $documentFolderObject->slug;
        } else {
            $documentFolderObject->path = $postValues['path'] . '/' . $documentFolderObject->slug;
        }
        $this->repository->getContentRepository()->saveDocument($documentFolderObject, 'published');
        $this->repository->getContentRepository()->saveDocument($documentFolderObject, 'unpublished');
    }
841168
public function setPropertiesValues($propertiesValues)
    {
        $returnValue = (bool) false;
        $returnValue = $this->getImplementation()->setPropertiesValues($this, $propertiesValues);
        $this->onUpdate();
        return (bool) $returnValue;
    }
1259532
public function addSitemapItem($postValues)
    {
        $sitemapObject = SitemapItemFactory::createSitemapItemFromPostValues($postValues);
        $sitemap = $this->repository->sitemap;
        $sitemap[] = $sitemapObject;
        $this->repository->sitemap = $sitemap;
        $this->save();
    }
237859
public function Save($FormPostValues, $Settings = FALSE) {
      $CurrentBanID = GetValue('BanID', $FormPostValues);

      // Get the current ban before saving.
      if ($CurrentBanID)
         $CurrentBan = $this->GetID($CurrentBanID, DATASET_TYPE_ARRAY);
      else
         $CurrentBan = NULL;
    
      $this->SetCounts($FormPostValues);
      $BanID = parent::Save($FormPostValues, $Settings);
      $FormPostValues['BanID'] = $BanID;

      $this->ApplyBan($FormPostValues, $CurrentBan);
   }
369468
public function saveDocumentType($slug, $postValues)
    {
        $documentTypeObject = DocumentTypeFactory::createDocumentTypeFromPostValues($postValues);

        $documentTypes = $this->repository->documentTypes;
        foreach ($documentTypes as $key => $documentType) {
            if ($documentType->slug == $slug) {
                $documentTypes[$key] = $documentTypeObject;
            }
        }
        $this->repository->documentTypes = $documentTypes;
        $this->save();
    }
838223
public function findByFields($fieldValues)
    {
        if (empty($fieldValues)) {
            throw new \Exception('No field values specified');
        }
        $this->primeCommandArray();
        $this->addToCommandArray($fieldValues);
        $this->addToCommandArray(['-find' => null]);
        return $this;
    }
884502
public function Save($FormPostValues) {
      $Session = Gdn::Session();
      
      // Define the primary key in this model's table.
      $this->DefineSchema();
      
      // Add & apply any extra validation rules:      
      $this->Validation->ApplyRule('Body', 'Required');
      $MaxCommentLength = Gdn::Config('Vanilla.Comment.MaxLength');
      if (is_numeric($MaxCommentLength) && $MaxCommentLength > 0) {
         $this->Validation->SetSchemaProperty('Body', 'Length', $MaxCommentLength);
         $this->Validation->ApplyRule('Body', 'Length');
      }
      
      // Get the DraftID from the form so we know if we are inserting or updating.
      $DraftID = ArrayValue('DraftID', $FormPostValues, '');
      $Insert = $DraftID == '' ? TRUE : FALSE;
      
      // Remove the discussionid from the form value collection if it's empty
      if (array_key_exists('DiscussionID', $FormPostValues) && $FormPostValues['DiscussionID'] == '')
         unset($FormPostValues['DiscussionID']);
      
      if ($Insert) {
         // If no categoryid is defined, grab the first available.
         if (ArrayValue('CategoryID', $FormPostValues) === FALSE)
            $FormPostValues['CategoryID'] = $this->SQL->Get('Category', '', '', 1)->FirstRow()->CategoryID;
            
      }
      // Add the update fields because this table's default sort is by DateUpdated (see $this->Get()).
      $this->AddInsertFields($FormPostValues);
      $this->AddUpdateFields($FormPostValues);
      
      // Remove checkboxes from the fields if they were unchecked
      if (ArrayValue('Announce', $FormPostValues, '') === FALSE)
         unset($FormPostValues['Announce']);

      if (ArrayValue('Closed', $FormPostValues, '') === FALSE)
         unset($FormPostValues['Closed']);

      if (ArrayValue('Sink', $FormPostValues, '') === FALSE)
         unset($FormPostValues['Sink']);
         
      // Validate the form posted values
      if ($this->Validate($FormPostValues, $Insert)) {
         $Fields = $this->Validation->SchemaValidationFields(); // All fields on the form that relate to the schema
         $DraftID = intval(ArrayValue('DraftID', $Fields, 0));
         
         // If the post is new and it validates, make sure the user isn't spamming
         if ($DraftID > 0) {
            // Update the draft
            $Fields = RemoveKeyFromArray($Fields, 'DraftID'); // Remove the primary key from the fields for saving
            $this->SQL->Put($this->Name, $Fields, array($this->PrimaryKey => $DraftID));
         } else {
            // Insert the draft
            unset($Fields['DraftID']);
            $DraftID = $this->SQL->Insert($this->Name, $Fields);
            $this->UpdateUser($Session->UserID);
         }
      }
      
      return $DraftID;
   }
1277194
public function getValidFormValues($getSubmits = false) {

		if(is_null($this->requestValues)) {

			throw new HtmlFormException('Values can not be evaluated. No request bound.', HtmlFormException::NO_REQUEST_BOUND);

		}

		$tmp = new ValuesBag();

		foreach($this->elements as $name => $e) {

			if(is_array($e)) {

				$vals = [];

				foreach($e as $ndx => $elem) {

					if(!$elem->isValid()) {
						continue;
					}

					// @todo since elements in an array are all of same type they don't need to be checked individually
					
					if($elem->canSubmit() && !$getSubmits) {
						continue;
					}

					if($elem instanceof CheckboxElement && !in_array($elem->getValue(), $this->requestValues->get($name, []))) {
						continue;
					}

					$vals[$ndx] = $elem->getModifiedValue();
				}

				$tmp->set($name, $vals);

			}

			else {

				if(
					$e->canSubmit() && !$getSubmits ||
					!$e->isValid() ||
					$e instanceof CheckboxElement && !$this->requestValues->get($name)
				) {
					continue;
				}

				$tmp->set($name, $e->getModifiedValue());

			}
		}

		return $tmp;

	}
343187
public function ezodfGetChildren( $getParams, $getOptions, $postParams, $postOptions )
    {
        $nodeID = $getParams['nodeID'];
        $languageCode = $getOptions['languageCode'];
        $offset = $getOptions['offset'];
        $limit = $getOptions['limit'];

        $domDocument = new DOMDocument( '1.0', 'utf-8' );
        $childrenElement = $domDocument->createElement( 'Children' );

        // Set attributes.
        $childrenElement->setAttribute( 'offset', $offset );
        if ( $languageCode )
        {
            $childrenElement->setAttribute( 'languageCode', $languageCode );
        }
        $childrenElement->setAttribute( 'limit', $limit );

        // Get children, and add them to children list.
        $children = eZContentObjectTreeNode::subTreeByNodeID( array( 'Depth' => 1,
                                                                     'DepthOperator' => 'eq',
                                                                     'Limit' => $limit,
                                                                     'Offset' => $offset,
                                                                     'Language' => $languageCode ),
                                                              $nodeID );
        if ( $children )
        {
            foreach( $children as $childNode )
            {
                $childrenElement->appendChild( $this->createTreeNodeDOMElement( $domDocument, $childNode ) );
            }
            $childrenElement->setAttribute( 'count', count( $children ) );
        }
        else
        {
            $childrenElement->setAttribute( 'count', count( $children ) );
        }

        return $childrenElement;
    }