예제 #1
0
 /**
  * Create a new pagetype
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("manage/pagetypes/new"));
     $field = $form->newField();
     $field->setLegend('New page type');
     $element = $field->newElement('TextInput', 'name');
     $element->setLabel('Name');
     $element->addFilter(new \Foundation\Form\Filter\Safe($element));
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('TextInput', 'class');
     $element->setLabel('Class');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Add Page');
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         if (!class_exists($input->get('class'))) {
             $this->addMessage('error', "That is not a valid class name");
         } else {
             $pageType = new \Jazzee\Entity\PageType();
             $pageType->setName($input->get('name'));
             $pageType->setClass($input->get('class'));
             $this->addMessage('success', $input->get('name') . "  added.");
             $this->_em->persist($pageType);
             $this->redirectPath('manage/pagetypes');
         }
     }
 }
예제 #2
0
파일: Defaults.php 프로젝트: Jazzee/Jazzee
 /**
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $entityManager = $this->getHelper('em')->getEntityManager();
     $output->write('<comment>Installing default components...</comment>' . PHP_EOL);
     $pageTypes = array('\\Jazzee\\Page\\Branching' => 'Branching', '\\Jazzee\\Page\\ETSMatch' => 'ETS Score Matching', '\\Jazzee\\Page\\Education' => 'Education', '\\Jazzee\\Page\\ExternalId' => 'External ID', '\\Jazzee\\Page\\Lock' => 'Lock Application', '\\Jazzee\\Page\\Payment' => 'Payment', '\\Jazzee\\Page\\QASAddress' => 'Address Verification QAS', '\\Jazzee\\Page\\Recommenders' => 'Recommenders', '\\Jazzee\\Page\\Standard' => 'Standard', '\\Jazzee\\Page\\Text' => 'Plain Text');
     foreach ($pageTypes as $class => $name) {
         $pageType = new \Jazzee\Entity\PageType();
         $pageType->setName($name);
         $pageType->setClass($class);
         $entityManager->persist($pageType);
     }
     $entityManager->flush();
     $output->write('<info>Default Page types added</info>' . PHP_EOL);
     $elementTypes = array('\\Jazzee\\Element\\CheckboxList' => 'Checkboxes', '\\Jazzee\\Element\\Date' => 'Date', '\\Jazzee\\Element\\EmailAddress' => 'Email Address', '\\Jazzee\\Element\\EncryptedTextInput' => 'Encrypted Text Input', '\\Jazzee\\Element\\PDFFileInput' => 'PDF Upload', '\\Jazzee\\Element\\Phonenumber' => 'Phone Number', '\\Jazzee\\Element\\RadioList' => 'Radio Buttons', '\\Jazzee\\Element\\RankingList' => 'Rank Order Dropdown', '\\Jazzee\\Element\\SearchList' => 'Search', '\\Jazzee\\Element\\SelectList' => 'Dropdown List', '\\Jazzee\\Element\\ShortDate' => 'Short Date', '\\Jazzee\\Element\\TextInput' => 'Single Line Text', '\\Jazzee\\Element\\Textarea' => 'Text Area', '\\Jazzee\\Element\\USSocialSecurityNumber' => 'US Social Security Number');
     foreach ($elementTypes as $class => $name) {
         $elementType = new \Jazzee\Entity\ElementType();
         $elementType->setName($name);
         $elementType->setClass($class);
         $entityManager->persist($elementType);
     }
     $entityManager->flush();
     $output->write('<info>Default Element types added</info>' . PHP_EOL);
     $role = new \Jazzee\Entity\Role();
     $role->makeGlobal();
     $role->setName('Administrator');
     $entityManager->persist($role);
     \Foundation\VC\Config::addControllerPath(__DIR__ . '/../../controllers/');
     foreach (array('admin', 'applicants', 'manage', 'scores', 'setup') as $path) {
         $path = \realpath(__DIR__ . '/../../controllers/' . $path);
         \Foundation\VC\Config::addControllerPath($path . '/');
         //scan the directory but drop the relative paths
         foreach (array_diff(scandir($path), array('.', '..')) as $fileName) {
             $controller = basename($fileName, '.php');
             \Foundation\VC\Config::includeController($controller);
             $class = \Foundation\VC\Config::getControllerClassName($controller);
             foreach (get_class_methods($class) as $method) {
                 if (substr($method, 0, 6) == 'action') {
                     $constant = 'ACTION_' . strtoupper(substr($method, 6));
                     if (defined("{$class}::{$constant}")) {
                         $roleAction = new \Jazzee\Entity\RoleAction();
                         $roleAction->setController($controller);
                         $roleAction->setAction(substr($method, 6));
                         $roleAction->setRole($role);
                         $entityManager->persist($roleAction);
                     }
                 }
             }
         }
     }
     $entityManager->flush();
     $output->write("<info>Administrator role created</info>" . PHP_EOL);
 }
예제 #3
0
 /**
  * Setup the temporary database with data from the real one
  * @param \Doctrine\ORM\EntityManager $em
  */
 protected function buildTemporaryDatabase(\Doctrine\ORM\EntityManager $em)
 {
     $classes = $this->_em->getMetadataFactory()->getAllMetadata();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->dropDatabase();
     $tool->createSchema($classes);
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\PageType')->findAll() as $type) {
         $newType = new \Jazzee\Entity\PageType();
         $newType->setClass($type->getClass());
         $newType->setName($type->getName());
         $em->persist($newType);
     }
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\ElementType')->findAll() as $type) {
         $newType = new \Jazzee\Entity\ElementType();
         $newType->setClass($type->getClass());
         $newType->setName($type->getName());
         $em->persist($newType);
     }
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\PaymentType')->findAll() as $type) {
         $newType = new \Jazzee\Entity\PaymentType();
         $newType->setClass($type->getClass());
         $newType->setName($type->getName());
         if ($type->isExpired()) {
             $newType->expire();
         }
         foreach ($type->getVariables() as $var) {
             $newVar = new Jazzee\Entity\PaymentTypeVariable();
             $newVar->setName($var->getName());
             $newVar->setValue($var->getValue());
             $newVar->setType($newType);
             $em->persist($newVar);
         }
         $em->persist($newType);
     }
     $em->flush();
     $em->clear();
     $count = 0;
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\School')->findAllArray() as $arr) {
         $newSchool = new \Jazzee\Entity\School();
         $newSchool->setCity($arr['city']);
         $newSchool->setCode($arr['code']);
         $newSchool->setCountry($arr['country']);
         $newSchool->setName($arr['name']);
         $newSchool->setPostalCode($arr['postalCode']);
         $newSchool->setSearchTerms($arr['searchTerms']);
         $newSchool->setState($arr['state']);
         $em->persist($newSchool);
         $count++;
         if ($count > 1000) {
             $count = 0;
             $em->flush();
             $em->clear();
         }
     }
     $em->flush();
 }