/** * Load setting fixture * * @access public * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $faker = \Faker\Factory::create(); $settings = array(array('name' => SettingsService::ADMIN_EMAIL, 'value' => $faker->freeEmail), array('name' => SettingsService::OPERATIONS_EMAIL, 'value' => $faker->freeEmail), array('name' => SettingsService::SYSTEM_EMAIL, 'value' => $faker->freeEmail)); foreach ($settings as $settingData) { $setting = new SettingEntity(); $setting->setName($settingData["name"])->setValue($settingData["value"]); $manager->persist($setting); } $manager->flush(); }
/** * Create new Setting * * * @access public * @uses Setting * @uses SettingForm * * @return ViewModel */ public function newAction() { $variables = array(); $query = $this->getServiceLocator()->get('wrapperQuery')->setEntity('System\\Entity\\Setting'); $setting = new Setting(); $form = new SettingForm(); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost()->toArray(); $form->setInputFilter($setting->getInputFilter($query)); $form->setData($data); if ($form->isValid()) { $query->save($setting, $data); $url = $this->getEvent()->getRouter()->assemble(array('action' => 'index'), array('name' => 'systemSettings')); $this->redirect()->toUrl($url); } } $variables['settingForm'] = $this->getFormView($form); return new ViewModel($variables); }