getFields() 공개 메소드

Getter for field
public getFields ( ) : mixed
리턴 mixed
예제 #1
0
 /**
  * Setter for Template
  *
  * @param Newscoop\Entity\Snippet\SnippetTemplate $template
  *
  * @return Newscoop\Entity\Snippet
  */
 public function setTemplate(SnippetTemplate $template)
 {
     $this->template = $template;
     foreach ($template->getFields() as $templateField) {
         $field = new SnippetField($templateField);
         $field->setSnippet($this);
         $this->addField($field);
     }
     $this->setModified();
     return $this;
 }
 public function save(SnippetTemplate $snippetTemplate)
 {
     if (!$snippetTemplate->hasName()) {
         throw new \InvalidArgumentException("SnippetTemplate name cannot be empty");
     }
     if (!$snippetTemplate->hasTemplateCode()) {
         throw new \InvalidArgumentException("SnippetTemplate templateCode cannot be empty");
     }
     if (!$snippetTemplate->hasFields()) {
         throw new \InvalidArgumentException("SnippetTemplate requires at least 1 SnippetTemplateField");
     }
     foreach ($snippetTemplate->getFields()->toArray() as $field) {
         $field->setTemplate($snippetTemplate);
     }
     $em = $this->getEntityManager();
     $em->persist($snippetTemplate);
     $em->flush();
 }