public function getContent(array $contentData)
    {
        // check if all mandatory fields are present
        foreach ($this->mandatoryFields as $mandatoryField) {
            if (!array_key_exists($mandatoryField, $contentData)) {
                throw new ContentException("The field '$mandatoryField' is missing in the given content data");
            }
        }

        // try to create a content model from the available data
        try {

            // title
            $title = "";
            if (isset($contentData[self::FIELD_TITLE])) {
                $title = $contentData[self::FIELD_TITLE];
            }

            // summary
            $summary = "";
            if (isset($contentData[self::FIELD_SUMMARY])) {
                $summary = $contentData[self::FIELD_SUMMARY];
            }

            // description
            $description = "";
            if (isset($contentData[self::FIELD_DESCRIPTION])) {
                $description = $contentData[self::FIELD_DESCRIPTION];
            }

            $content = new Content($title, $summary, $description);
            return $content;

        } catch (\Exception $contentException) {
            throw new ContentException(sprintf("Failed to create a content model from the given data: %s",
                $contentException->getMessage()), $contentException);
        }
    }
public function getContent(array $contentData)
    {
        // check if all mandatory fields are present
        foreach ($this->mandatoryFields as $mandatoryField) {
            if (!array_key_exists($mandatoryField, $contentData)) {
                throw new ContentException("The field '$mandatoryField' is missing in the given content data");
            }
        }

        // try to create a content model from the available data
        try {

            // title
            $title = "";
            if (isset($contentData[self::FIELD_TITLE])) {
                $title = $contentData[self::FIELD_TITLE];
            }

            // summary
            $summary = "";
            if (isset($contentData[self::FIELD_SUMMARY])) {
                $summary = $contentData[self::FIELD_SUMMARY];
            }

            // description
            $description = "";
            if (isset($contentData[self::FIELD_DESCRIPTION])) {
                $description = $contentData[self::FIELD_DESCRIPTION];
            }

            $content = new Content($title, $summary, $description);
            return $content;

        } catch (\Exception $contentException) {
            throw new ContentException(sprintf("Failed to create a content model from the given data: %s",
                $contentException->getMessage()), $contentException);
        }
    }
public function getContent ( array $ contentData ) { // check if all mandatory fields are present foreach ( $ this -> mandatoryFields as $ mandatoryField ) { if ( ! array_key_exists ( $ mandatoryField , $ contentData ) ) { throw new ContentException ( "The field '$mandatoryField' is missing in the given content data" ) ; } } // try to create a content model from the available data try { // title $ title = "" ; if ( isset ( $ contentData [ self :: FIELD_TITLE ] ) ) { $ title = $ contentData [ self :: FIELD_TITLE ] ; } // summary $ summary = "" ; if ( isset ( $ contentData [ self :: FIELD_SUMMARY ] ) ) { $ summary = $ contentData [ self :: FIELD_SUMMARY ] ; } // description $ description = "" ; if ( isset ( $ contentData [ self :: FIELD_DESCRIPTION ] ) ) { $ description = $ contentData [ self :: FIELD_DESCRIPTION ] ; } $ content = new Content ( $ title , $ summary , $ description ) ; return $ content ; } catch ( \ Exception $ contentException ) { throw new ContentException ( sprintf ( "Failed to create a content model from the given data: %s" , $ contentException -> getMessage ( ) ) , $ contentException ) ; } }
Get a Content model from an array of unstructured product content data

@param array $contentData An array containing content attributes

@return Content

@throws ContentException If a mandatory field is missing
@throws ContentException If the no Content could be created from the given product data
Get a Content model from an array of unstructured product content data