public function getContentByReference($reference)
    {
        if (is_numeric($reference)) {
            // If the reference is numeric, it must be the content ID from an existing
            // content item, which has to be updated.
            $nestedContent = $this->getRepository()->find($reference);
        } else {
            // If not, $reference is a template name for a to-be-created content item.
            $template = $this->em->getRepository($this->templateClass)->findOneByName($reference);

            $nestedContent = $this->eavManager->initializeEntity($template);
            $nestedContent->setNestedDefaults();
        }

        return $nestedContent;
    }
public function getContentByReference($reference)
    {
        if (is_numeric($reference)) {
            // If the reference is numeric, it must be the content ID from an existing
            // content item, which has to be updated.
            $nestedContent = $this->getRepository()->find($reference);
        } else {
            // If not, $reference is a template name for a to-be-created content item.
            $template = $this->em->getRepository($this->templateClass)->findOneByName($reference);

            $nestedContent = $this->eavManager->initializeEntity($template);
            $nestedContent->setNestedDefaults();
        }

        return $nestedContent;
    }
public function getContentByReference ( $ reference ) { if ( is_numeric ( $ reference ) ) { // If the reference is numeric, it must be the content ID from an existing // content item, which has to be updated. $ nestedContent = $ this -> getRepository ( ) -> find ( $ reference ) ; } else { // If not, $reference is a template name for a to-be-created content item. $ template = $ this -> em -> getRepository ( $ this -> templateClass ) -> findOneByName ( $ reference ) ; $ nestedContent = $ this -> eavManager -> initializeEntity ( $ template ) ; $ nestedContent -> setNestedDefaults ( ) ; } return $ nestedContent ; }
Get the content by a reference

If the passed reference is a numeric, it must be the content ID from a
to-be-updated content item.
If not, the reference must be the template name for a to-be-created
content item.

@param int|string $reference

@return ContentInterface
Get the content by a reference