/**
  * Constructs a new view for the account profile hook
  * @return null
  */
 public function __construct(ProfileForm $form)
 {
     parent::__construct(self::TEMPLATE);
     $this->set('user', $form->getUser());
     $this->set('form', $form);
     $this->addInlineJavascript('$("#formProfileEmail").focus();');
 }
 /**
  * Action to view and change the profile
  * @return null
  */
 public function indexAction()
 {
     $user = SecurityManager::getInstance()->getUser();
     if (!$user) {
         throw new UnauthorizedException();
     }
     $form = new ProfileForm($this->request->getBasePath(), $user);
     $form->addHook(new AccountProfileHook());
     Zibo::getInstance()->runEvent(self::EVENT_PREPARE_FORM, $form);
     if ($form->isSubmitted()) {
         try {
             $form->validate();
             $form->processSubmit($this);
             if (!$this->response->getView() && !$this->response->willRedirect()) {
                 $this->response->setRedirect($this->request->getBasePath());
             }
             return;
         } catch (ValidationException $exception) {
             $form->setValidationException($exception);
         }
     }
     $translator = $this->getTranslator();
     $view = new ProfileView($form);
     $view->setPageTitle($translator->translate(self::TRANSLATION_TITLE));
     $this->response->setView($view);
 }
 /**
  * Constructs a new password reset view
  * @param zibo\admin\form\ProfileForm $form Form of the view
  * @return null
  */
 public function __construct(ProfileForm $form)
 {
     parent::__construct(self::TEMPLATE);
     $subviewNames = array();
     $subviews = $form->getHookViews();
     foreach ($subviews as $index => $subview) {
         $subviewName = 'profileHook' . $index;
         $subviewNames[] = $subviewName;
         $this->setSubview($subviewName, $subview);
     }
     $this->set('form', $form);
     $this->set('subviewNames', $subviewNames);
 }
 /**
  * Sets the profile form
  * @param ProfileForm $form The profile form
  * @return null
  */
 public function setProfileForm(ProfileForm $form)
 {
     $this->profileForm = $form;
     $this->user = $form->getUser();
 }