fix formatting

This commit is contained in:
Antonio Ramirez
2016-12-14 02:50:12 +01:00
parent f3f4b31bb4
commit 3ba01b4674
140 changed files with 512 additions and 523 deletions

View File

@ -1,9 +1,8 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
use Da\User\Event\UserEvent;
use Da\User\Model\Token;
use Da\User\Model\User;
use Da\User\Query\TokenQuery;
@ -43,5 +42,4 @@ class AccountConfirmationService implements ServiceInterface
return false;
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
@ -55,14 +56,13 @@ class AuthItemEditionService implements ServiceInterface
$this->model->item = $item;
return $this->updateChildren();
} catch (Exception $e) {
return false;
}
}
/**
* Updates Auth Item children
* Updates Auth Item children.
*
* @return bool
*/
@ -78,7 +78,6 @@ class AuthItemEditionService implements ServiceInterface
if (!$this->getAuthManager()->removeChild($this->model->item, $children[$item])) {
return false;
}
}
// add new children
foreach (array_diff($this->model->children, $childrenNames) as $item) {

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\MailChangeStrategyInterface;
@ -44,9 +45,7 @@ class EmailChangeService implements ServiceInterface
$token->delete();
if (empty($this->model->unconfirmed_email)) {
Yii::$app->session->setFlash('danger', Yii::t('user', 'An error occurred processing your request'));
} elseif ($this->userQuery->whereEmail($this->model->unconfirmed_email)->exists() === false) {
if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_SECURE) {
if ($token->type === Token::TYPE_CONFIRM_NEW_EMAIL) {
$this->model->flags |= User::NEW_EMAIL_CONFIRMED;
@ -54,7 +53,7 @@ class EmailChangeService implements ServiceInterface
'success',
Yii::t(
'user',
'Awesome, almost there. ' .
'Awesome, almost there. '.
'Now you need to click the confirmation link sent to your old email address.'
)
);
@ -64,7 +63,7 @@ class EmailChangeService implements ServiceInterface
'success',
Yii::t(
'user',
'Awesome, almost there. ' .
'Awesome, almost there. '.
'Now you need to click the confirmation link sent to your new email address.'
)
);
@ -81,7 +80,7 @@ class EmailChangeService implements ServiceInterface
return $this->model->save(false);
}
}
return false;
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
@ -19,11 +20,11 @@ class MailService implements ServiceInterface
/**
* MailService constructor.
*
* @param string $from
* @param string $to
* @param string $subject
* @param string $view
* @param array $params
* @param string $from
* @param string $to
* @param string $subject
* @param string $view
* @param array $params
* @param MailerInterface $mailer
*/
public function __construct($from, $to, $subject, $view, array $params, BaseMailer $mailer)

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
@ -51,12 +52,10 @@ class PasswordRecoveryService implements ServiceInterface
);
return true;
} catch (Exception $e) {
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
return false;
}
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
use Da\User\Factory\TokenFactory;
@ -22,7 +22,7 @@ class ResendConfirmationService implements ServiceInterface
public function run()
{
if($this->model && !$this->model->getIsConfirmed()) {
if ($this->model && !$this->model->getIsConfirmed()) {
$token = TokenFactory::makeConfirmationToken($this->model->id);
$this->mailService->setViewParam('token', $token);
@ -31,5 +31,4 @@ class ResendConfirmationService implements ServiceInterface
return false;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
use Da\User\Helper\SecurityHelper;
@ -21,12 +21,10 @@ class ResetPasswordService implements ServiceInterface
public function run()
{
return $this->model && (bool)$this->model->updateAttributes(
return $this->model && (bool) $this->model->updateAttributes(
[
'password_hash' => $this->securityHelper->generatePasswordHash($this->password)
'password_hash' => $this->securityHelper->generatePasswordHash($this->password),
]
);
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\AuthClientInterface;
use Da\User\Contracts\ServiceInterface;
@ -12,7 +12,6 @@ use Da\User\Query\SocialNetworkAccountQuery;
use Da\User\Traits\ContainerTrait;
use Yii;
class SocialNetworkAccountConnectService implements ServiceInterface
{
use ContainerTrait;
@ -24,8 +23,8 @@ class SocialNetworkAccountConnectService implements ServiceInterface
/**
* SocialNetworkAccountUserLinkService constructor.
*
* @param SecurityController $controller
* @param AuthClientInterface $client
* @param SecurityController $controller
* @param AuthClientInterface $client
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
*/
public function __construct(
@ -54,7 +53,6 @@ class SocialNetworkAccountConnectService implements ServiceInterface
$this->controller->trigger(SocialNetworkAuthEvent::EVENT_AFTER_CONNECT, $event);
return true;
} else {
Yii::$app->session->setFlash(
'danger',
@ -77,7 +75,7 @@ class SocialNetworkAccountConnectService implements ServiceInterface
[
'provider' => $this->client->getId(),
'client_id' => $data['id'],
'data' => json_encode($data)
'data' => json_encode($data),
]
);

View File

@ -1,6 +1,6 @@
<?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\AuthClientInterface;
use Da\User\Contracts\ServiceInterface;
@ -17,7 +17,6 @@ use yii\helpers\Url;
class SocialNetworkAuthenticateService implements ServiceInterface
{
protected $controller;
protected $authAction;
protected $client;
@ -38,7 +37,6 @@ class SocialNetworkAuthenticateService implements ServiceInterface
$this->userQuery = $userQuery;
}
public function run()
{
$account = $this->socialNetworkAccountQuery->whereClient($this->client)->one();
@ -87,7 +85,7 @@ class SocialNetworkAuthenticateService implements ServiceInterface
'client_id' => $data['id'],
'data' => json_encode($data),
'username' => $this->client->getUserName(),
'email' => $this->client->getEmail()
'email' => $this->client->getEmail(),
]
);
@ -113,7 +111,7 @@ class SocialNetworkAuthenticateService implements ServiceInterface
[
'scenario' => 'connect',
'username' => $account->username,
'email' => $account->email
'email' => $account->email,
]
);

View File

@ -1,6 +1,6 @@
<?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
use Da\User\Model\Assignment;
@ -39,6 +39,5 @@ class UpdateAuthAssignmentsService implements ServiceInterface
}
return $this->model->updated = true;
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
@ -30,15 +31,16 @@ class UserBlockService implements ServiceInterface
{
if ($this->model->getIsBlocked()) {
$this->controller->trigger(UserEvent::EVENT_BEFORE_UNBLOCK, $this->event);
$result = (bool)$this->model->updateAttributes(['blocked_at' => null]);
$result = (bool) $this->model->updateAttributes(['blocked_at' => null]);
$this->controller->trigger(UserEvent::EVENT_AFTER_UNBLOCK, $this->event);
} else {
$this->controller->trigger(UserEvent::EVENT_BEFORE_BLOCK, $this->event);
$result = (bool)$this->model->updateAttributes(
$result = (bool) $this->model->updateAttributes(
['blocked_at' => time(), 'auth_key' => $this->securityHelper->generateRandomString()]
);
$this->controller->trigger(UserEvent::EVENT_AFTER_BLOCK, $this->event);
}
return $result;
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
@ -17,11 +18,12 @@ class UserConfirmationService implements ServiceInterface
public function run()
{
$this->model->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION);
if ((bool)$this->model->updateAttributes(['confirmed_at' => time()])) {
if ((bool) $this->model->updateAttributes(['confirmed_at' => time()])) {
$this->model->trigger(UserEvent::EVENT_AFTER_CONFIRMATION);
return true;
}
return false;
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
@ -7,7 +8,6 @@ use Da\User\Helper\SecurityHelper;
use Da\User\Model\User;
use yii\base\InvalidCallException;
use Exception;
use yii\db\ActiveRecord;
use yii\log\Logger;
class UserCreateService implements ServiceInterface
@ -58,14 +58,11 @@ class UserCreateService implements ServiceInterface
$transaction->commit();
return true;
} catch (Exception $e) {
$transaction->rollBack();
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
return false;
}
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
@ -47,16 +48,17 @@ class UserRegisterService implements ServiceInterface
$model->trigger(UserEvent::EVENT_BEFORE_REGISTER);
if(!$model->save()) {
if (!$model->save()) {
$transaction->rollBack();
return false;
}
if($this->getModule()->enableEmailConfirmation) {
if ($this->getModule()->enableEmailConfirmation) {
$token = TokenFactory::makeConfirmationToken($model->id);
}
if(isset($token)) {
if (isset($token)) {
$this->mailService->setViewParam('token', $token);
}
$this->mailService->run();
@ -66,13 +68,11 @@ class UserRegisterService implements ServiceInterface
$transaction->commit();
return true;
} catch(Exception $e) {
} catch (Exception $e) {
$transaction->rollBack();
$this->logger->log($e->getMessage(), Logger::LEVEL_WARNING);
return false;
}
}
}