I am having some trouble when trying to create a new Entry in Craft3 via PHP. In Craft 2, I was able to do something like this:
$entry = new EntryModel(); $entry->getContent()->title = $name; $entry->getContent()->answer = $answer; $handle = "nameOfTheSectionIWantToSaveIn"; $entry->sectionId = craft()->sections->getSectionByHandle($handle)->id; $save = craft()->entries->saveEntry($entry);
Before asking, I took some time to read through the Craft3 Class Reference and came across the namespace:
I have come to the conclusion(could be wrong) that I need to use something like the following:
use craft\elements\Entry; $entry = new Entry();
However, I am a little confused as to where I go from here. I checked the available Craft Entry Public Methods and could not find a method like getContent(), which was used in Craft2. I did see a getContentTable(), but not sure if thats what I am looking for.