Skip to content

Commit

Permalink
changed some config parts
Browse files Browse the repository at this point in the history
changed some code styles
  • Loading branch information
kokspflanze committed Sep 20, 2015
1 parent 54f66ec commit 7d8aa9c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 29 deletions.
7 changes: 4 additions & 3 deletions src/PServerCMS/Form/ChangePwdFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class ChangePwdFilter extends ProvidesEventsInputFilter
{
/** @var ServiceLocatorInterface */
protected $serviceManager;

/**
Expand Down Expand Up @@ -72,19 +73,19 @@ public function __construct( ServiceLocatorInterface $serviceLocatorInterface )
}

/**
* @param ServiceManager $oServiceManager
* @param ServiceLocatorInterface $oServiceManager
*
* @return $this
*/
public function setServiceManager( ServiceManager $oServiceManager )
public function setServiceManager( ServiceLocatorInterface $oServiceManager )
{
$this->serviceManager = $oServiceManager;

return $this;
}

/**
* @return ServiceManager
* @return ServiceLocatorInterface
*/
protected function getServiceManager()
{
Expand Down
5 changes: 2 additions & 3 deletions src/PServerCMS/Form/Element/DateTimeJQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class DateTimeJQuery extends DateTimeLocal
{
/** @var string */
const DATETIME_LOCAL_FORMAT = 'Y-m-d';

/**
Expand All @@ -18,9 +19,7 @@ class DateTimeJQuery extends DateTimeLocal
'type' => 'text',
];

/**
* {@inheritDoc}
*/
/** @var string */
protected $format = self::DATETIME_LOCAL_FORMAT;

}
35 changes: 22 additions & 13 deletions src/PServerCMS/Form/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

namespace PServerCMS\Form;

use PServerCMS\Entity\User;
use PServerCMS\Entity\UserInterface;
use Zend\Form\Element;
use ZfcBase\Form\ProvidesEventsForm;
use Zend\ServiceManager\ServiceLocatorInterface;

class Password extends ProvidesEventsForm
{

/** @var ServiceLocatorInterface */
protected $serviceManager;
/** @var User */
/** @var UserInterface */
protected $user;
/** @var \Doctrine\ORM\EntityManager */
protected $entityManager;


/**
* @param ServiceLocatorInterface $serviceLocatorInterface
*/
public function __construct( ServiceLocatorInterface $serviceLocatorInterface )
{
parent::__construct();
Expand Down Expand Up @@ -64,11 +65,11 @@ public function __construct( ServiceLocatorInterface $serviceLocatorInterface )
}

/**
* @param User $user
* @param UserInterface $user
*/
public function addSecretQuestion(User $user)
public function addSecretQuestion(UserInterface $user)
{
if (!$this->getServiceManager()->get('pserver_configread_service')->get('pserver.password.secret_question')) {
if (!$this->getPasswordOptions()->isSecretQuestion()) {
return;
}

Expand Down Expand Up @@ -106,29 +107,29 @@ public function addSecretQuestion(User $user)
}

/**
* @param User $user
* @param UserInterface $user
*/
public function setUser( User $user )
public function setUser( UserInterface $user )
{
$this->user = $user;
}

/**
* @return User
* @return UserInterface
*/
public function getUser()
{
return $this->user;
}

/**
* @param ServiceLocatorInterface $oServiceManager
* @param ServiceLocatorInterface $serviceManager
*
* @return $this
*/
protected function setServiceManager( ServiceLocatorInterface $oServiceManager )
protected function setServiceManager( ServiceLocatorInterface $serviceManager )
{
$this->serviceManager = $oServiceManager;
$this->serviceManager = $serviceManager;

return $this;
}
Expand Down Expand Up @@ -160,4 +161,12 @@ protected function getEntityOptions()
{
return $this->getServiceManager()->get('pserver_entity_options');
}

/**
* @return \PServerCMS\Options\PasswordOptions
*/
public function getPasswordOptions()
{
return $this->getServiceManager()->get('pserver_password_options');
}
}
7 changes: 3 additions & 4 deletions src/PServerCMS/Form/PasswordFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PasswordFilter extends ProvidesEventsInputFilter
protected $similarText;
/** @var UserInterface */
protected $user;
/** @var ServiceLocatorInterface */
protected $serviceManager;

/**
Expand All @@ -22,11 +23,9 @@ public function __construct( ServiceLocatorInterface $serviceLocatorInterface )
{
$this->setServiceManager($serviceLocatorInterface);

/** @var \PServerCMS\Service\ConfigRead $configService */
$configService = $this->getServiceManager()->get( 'pserver_configread_service' );
if($configService->get('pserver.password.secret_question')) {
if ($this->getPasswordOptions()->isSecretQuestion()) {
/** @var \PServerCMS\Service\SecretQuestion $secretQuestion */
$secretQuestion = $this->getServiceManager()->get( 'pserver_secret_question' );
$secretQuestion = $this->getServiceManager()->get('pserver_secret_question');
$similarText = new \PServerCMS\Validator\SimilarText( $secretQuestion );
$this->setSimilarText( $similarText );
}
Expand Down
4 changes: 3 additions & 1 deletion src/PServerCMS/Form/PwLostFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class PwLostFilter extends ProvidesEventsInputFilter
/** @var AbstractRecord */
protected $userValidator;


/**
* @param AbstractRecord $userValidator
*/
public function __construct( AbstractRecord $userValidator )
{
$this->setUserValidator( $userValidator );
Expand Down
8 changes: 6 additions & 2 deletions src/PServerCMS/Form/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ public function __construct( ServiceLocatorInterface $sm )

/** @var \PServerCMS\Service\ConfigRead $configService */
$configService = $sm->get( 'pserver_configread_service' );
if($configService->get('pserver.password.secret_question')){
if ($configService->get('pserver.password.secret_question')) {

/** @var \PServerCMS\Options\EntityOptions $entityOptions */
$entityOptions = $sm->get('pserver_entity_options');

$this->add(array(
'name' => 'question',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'object_manager'=> $sm->get( 'Doctrine\ORM\EntityManager' ),
'target_class' => 'PServerCMS\Entity\SecretQuestion',
'target_class' => $entityOptions->getSecretQuestion(),
'property' => 'question',
'label' => 'SecretQuestion',
'empty_option' => '-- select --',
Expand Down
6 changes: 3 additions & 3 deletions src/PServerCMS/Service/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ public function lostPwConfirm( array $data, UserCodes $userCode )
}

$data = $form->getData();
$sPlainPassword = $data['password'];
$plainPassword = $data['password'];
$userEntity = $userCode->getUser();

$this->setNewPasswordAtUser( $userEntity, $sPlainPassword );
$this->setNewPasswordAtUser( $userEntity, $plainPassword );

$this->getUserCodesService()->deleteCode( $userCode );

if ($this->isSamePasswordOption()) {
$gameBackend = $this->getGameBackendService();
$gameBackend->setUser( $userEntity, $sPlainPassword );
$gameBackend->setUser( $userEntity, $plainPassword );
}

return $userEntity;
Expand Down

0 comments on commit 7d8aa9c

Please sign in to comment.