eZ\Bundle\EzPublishCoreBundle\Features\Context\FieldTypeContext::createAndPublishContent PHP Method

createAndPublishContent() private method

Creates and publishes the content with a given field and based on the internal ContentType.
private createAndPublishContent ( $field, $value )
    private function createAndPublishContent($field, $value)
    {
        $languageCode = self::DEFAULT_LANGUAGE;
        $locationCreateStruct = $this->locationService->newLocationCreateStruct('2');
        $contentType = $this->fieldConstructionObject['contentType'];
        $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, $languageCode);
        if ($field != null && $value != null) {
            $value = $value == 'empty' ? null : $value;
            $value = is_numeric($value) ? $value + 0 : $value;
            $contentCreateStruct->setField($field, $value);
        }
        $draft = $this->contentService->createContent($contentCreateStruct, array($locationCreateStruct));
        $content = $this->contentService->publishVersion($draft->versionInfo);
        $this->fieldConstructionObject['content'] = $content;
        $this->fieldConstructionObject['objectState'] = self::CONTENT_PUBLISHED;
    }