예제 #1
0
 public function testPostNotify()
 {
     $schema = new Schema();
     $postNotify = 'Some Post Notify';
     $expected = $postNotify;
     $schema->setPostNotify($postNotify);
     $actual = $schema->getPostNotify();
     $this->assertSame($expected, $actual);
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $schema = new Schema();
     $schema->setObjectClass('Opifer\\CmsBundle\\Entity\\Content');
     $schema->setName('page');
     $schema->setDisplayName('Page');
     $presentation = '{"id":' . $this->getReference("page-layout")->getId() . ',"name":"page", "filename":"OpiferCmsBundle:Layout:page.html.twig"}';
     $presentation = json_encode(json_decode($presentation, true));
     $schema->setPresentation($presentation);
     $manager->persist($schema);
     $this->addReference('page-schema', $schema);
     $manager->flush();
 }
예제 #3
0
 /**
  * Helper for setting schema attributes
  *
  * @param Schema $schemaEntity
  * @param array    $attributes
  *
  * @return array
  */
 protected function addSchemaAttributes($schemaEntity, $attributes)
 {
     foreach ($attributes as $id => $attribute) {
         if (!($attributeEntity = $schemaEntity->getAttribute($attribute['name']))) {
             $attributeEntity = new Attribute();
             $schemaEntity->addAttribute($attributeEntity);
         }
         $attributeEntity->setValueType($attribute['type'])->setName($attribute['name'])->setDisplayName($attribute['displayName'])->setSort($attribute['sort'])->setSchema($schemaEntity);
         if (isset($attribute['description'])) {
             $attributeEntity->setDescription($attribute['description']);
         }
         if (isset($attribute['allowedSchemas']) && is_array($attribute['allowedSchemas'])) {
             foreach ($attribute['allowedSchemas'] as $allowedReference) {
                 $attributeEntity->addAllowedSchema($this->getReference($allowedReference));
             }
         }
         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($schemaEntity);
     return $schemaEntity->getAttributes();
 }