public function testPostNotify() { $template = new Template(); $postNotify = 'Some Post Notify'; $expected = $postNotify; $template->setPostNotify($postNotify); $actual = $template->getPostNotify(); $this->assertSame($expected, $actual); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $template = new Template(); $template->setObjectClass('Opifer\\CmsBundle\\Entity\\Content'); $template->setName('page'); $template->setDisplayName('Page'); $presentation = '{"id":' . $this->getReference("page-layout")->getId() . ',"name":"page", "filename":"OpiferCmsBundle:Layout:page.html.twig"}'; $presentation = json_encode(json_decode($presentation, true)); $template->setPresentation($presentation); $manager->persist($template); $this->addReference('page-template', $template); $manager->flush(); }
/** * Helper for setting template attributes * * @param Template $templateEntity * @param array $attributes * * @return array */ protected function addTemplateAttributes($templateEntity, $attributes) { foreach ($attributes as $id => $attribute) { if (!($attributeEntity = $templateEntity->getAttribute($attribute['name']))) { $attributeEntity = new Attribute(); $templateEntity->addAttribute($attributeEntity); } $attributeEntity->setValueType($attribute['type'])->setName($attribute['name'])->setDisplayName($attribute['displayName'])->setDescription(isset($attribute['description']) ? $attribute['description'] : '')->setSort($attribute['sort'])->setTemplate($templateEntity); if (isset($attribute['options']) && is_array($attribute['options'])) { $i = 1; foreach ($attribute['options'] as $key => $option) { if (!($optionEntity = $attributeEntity->getOptionByName($key))) { $optionEntity = new Option(); $attributeEntity->addOption($optionEntity); } $optionEntity->setName($key)->setDisplayName($option)->setSort($i * 10)->setAttribute($attributeEntity); $attributeEntity->addOption($optionEntity); $this->entityManager->persist($optionEntity); $i++; } } $this->entityManager->persist($attributeEntity); } $this->entityManager->persist($templateEntity); return $templateEntity->getAttributes(); }