/** * {@inheritDoc} */ public function load(ObjectManager $manager) { /** * Create field "title" for module "employees". */ $field1 = new Field(); $field1->setModule($this->getReference('module-employees')); $field1->setFieldset($this->getReference('fieldset-details')); $field1->setName('Title'); $field1->setColumnType('string'); $field1->setFormType('text'); $field1->setIdentifier('title'); $field1->setSequence(1); $manager->persist($field1); /** * Create field "description" for module "employees". */ $field2 = new Field(); $field2->setModule($this->getReference('module-employees')); $field2->setFieldset($this->getReference('fieldset-details')); $field2->setName('Description'); $field2->setColumnType('text'); $field2->setFormType('textarea'); $field2->setIdentifier('description'); $field2->setSequence(2); $manager->persist($field2); $manager->flush(); $this->addReference('field-title', $field1); $this->addReference('field-description', $field2); }
/** * createModuleData. */ public function createModuleData() { $aFields = $this->getFields(); $aContent = array(); foreach ($aFields as $field) { $aContent[$field['identifier']] = $field['testData']; } $oModule = new Module(); $oModule->setName('Test Module'); $oModule->setDescription('test'); $sequence = 0; foreach ($aFields as $field) { $oField = new Field(); $oField->setName($field['name']); $oField->setFormType($field['form']); $oField->setIdentifier($field['identifier']); $this->em->persist($oField); $oModuleHasField = new ModuleHasField(); $oModuleHasField->setField($oField); $oModuleHasField->setModule($oModule); $oModuleHasField->setSequence($sequence); $this->em->persist($oModuleHasField); ++$sequence; } $this->em->flush(); for ($i = 0; $i < $this->rows; ++$i) { $container = new Container(); $container->setModule($oModule); $container->setSequence(999); $this->em->persist($container); $this->em->flush(); $this->container->enterScope('request'); $this->container->set('request', new Request(), 'request'); $object = $this->container->get('eav.module.manager'); $object->setModule($oModule); $object->save($container, $aContent); } $this->em->clear(); }