/**
  * Add custom view data.
  */
 public function onViewStart($event)
 {
     $request = $event->getArgument('request');
     $translator = $this->container->get('translator');
     if ($this->handleRequest($request->getRequestId())) {
         // create sources list
         $howDidYouHearSources = array();
         $source = new ZMObject();
         $source->setId('');
         $source->setName($translator->trans('Please select a source'));
         $howDidYouHearSources[] = $source;
         $sql = "SELECT sources_id, sources_name\n                    FROM %table.sources%\n                    ORDER BY sources_name";
         foreach (\ZMRuntime::getDatabase()->fetchAll($sql, array()) as $result) {
             $source = new ZMObject();
             $source->setId($result['sources_id']);
             $source->setName($result['sources_name']);
             $howDidYouHearSources[] = $source;
         }
         if ($this->isDisplayOther()) {
             $source = new ZMObject();
             $source->setId(ID_SOURCE_OTHER);
             $source->setName($translator->trans('Other - (please specify)'));
             $howDidYouHearSources[] = $source;
         }
         // create reliable form reference
         if (null != ($view = $event->getArgument('view')) && $view instanceof TemplateView) {
             $view->setVariable('howDidYouHearSources', $howDidYouHearSources);
             if (null != ($registration = $view->getVariable('registration'))) {
                 $view->setVariable('howDidYouHearForm', $registration);
             } elseif (null != ($shippingAddress = $view->getVariable('shippingAddress'))) {
                 // if we have an address we should have got the source as well...
                 $account = $this->container->get('security.context')->getToken()->getUser();
                 $addressList = $this->container->get('addressService')->getAddressesForAccountId($account->getId());
                 if ($this->isEnableOnGuestCheckout() && Account::GUEST == $account->getType() && 0 == count($addressList)) {
                     $view->setVariable('howDidYouHearForm', $shippingAddress);
                 }
             }
         }
     }
 }
 /**
  * Test create mapped SQL using obj.
  */
 public function testCreateMappedObjSQL()
 {
     $obj = new ZMObject();
     $obj->setName('foo4');
     $obj->setClassName('class4');
     $obj->setMethodName('method4');
     $obj->setParameterList('parameter4');
     $this->registerTableMapping();
     $sql = "INSERT INTO %table.create_update_tests%\n                (name, class_name, method_name, parameter_list) VALUES\n                (:name, :className, :methodName, :parameterList)";
     foreach (TestDatabase::getProviders() as $provider => $database) {
         $database->updateObj($sql, $obj, 'create_update_tests');
     }
 }