diff --git a/app/AppCache.php b/app/AppCache.php index bf8246246c8..ddb51db0583 100644 --- a/app/AppCache.php +++ b/app/AppCache.php @@ -1,6 +1,6 @@ getRequestUri(), 'installer') !== false || !$this->isInstalled()) { define('MAUTIC_INSTALLER', 1); } @@ -91,7 +89,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ if (strpos($uri, 'installer') === false) { $base = $request->getBaseUrl(); //check to see if the .htaccess file exists or if not running under apache - if ((strpos(strtolower($_SERVER["SERVER_SOFTWARE"]), 'apache') === false + if ((strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') === false || !file_exists(__DIR__.'../.htaccess') && strpos( $base, @@ -106,7 +104,6 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ } if (false === $this->booted) { - $this->boot(); } @@ -121,7 +118,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ $this->getContainer()->get('translator')->trans( 'mautic.core.db.connection.error', [ - '%code%' => $e->getCode() + '%code%' => $e->getCode(), ] ) ); @@ -176,7 +173,7 @@ public function registerBundles() new Mautic\SmsBundle\MauticSmsBundle(), new Mautic\StageBundle\MauticStageBundle(), new Mautic\UserBundle\MauticUserBundle(), - new Mautic\WebhookBundle\MauticWebhookBundle() + new Mautic\WebhookBundle\MauticWebhookBundle(), ]; //dynamically register Mautic Plugin Bundles @@ -229,14 +226,13 @@ public function registerBundles() public function boot() { if (true === $this->booted) { - return; } if (!defined('MAUTIC_TABLE_PREFIX')) { //set the table prefix before boot $localParams = $this->getLocalParams(); - $prefix = isset($localParams['db_table_prefix']) ? $localParams['db_table_prefix'] : ''; + $prefix = isset($localParams['db_table_prefix']) ? $localParams['db_table_prefix'] : ''; define('MAUTIC_TABLE_PREFIX', $prefix); } @@ -270,7 +266,7 @@ public function boot() } /** - * Returns a list of addon bundles that are enabled + * Returns a list of addon bundles that are enabled. * * @return array */ @@ -288,7 +284,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) } /** - * Retrieves the application's version number + * Retrieves the application's version number. * * @return string */ @@ -298,7 +294,7 @@ public function getVersion() } /** - * Checks if the application has been installed + * Checks if the application has been installed. * * @return bool */ @@ -318,6 +314,7 @@ private function isInstalled() * @param array $params * * @return \Doctrine\DBAL\Connection + * * @throws Exception * @throws \Doctrine\DBAL\DBALException */ @@ -382,7 +379,7 @@ public function getLogDir() } /** - * Get Mautic's local configuration file + * Get Mautic's local configuration file. * * @return array */ @@ -421,7 +418,7 @@ public function getLocalParams() } /** - * Get local config file + * Get local config file. * * @param bool $checkExists If true, then return false if the file doesn't exist * @@ -444,7 +441,7 @@ public function getLocalConfigFile($checkExists = true) } /** - * Get the container file name or path + * Get the container file name or path. * * @param bool|true $fullPath * diff --git a/app/autoload.php b/app/autoload.php index 3f0e4810e2e..db8e161ea18 100644 --- a/app/autoload.php +++ b/app/autoload.php @@ -6,14 +6,14 @@ require_once __DIR__.'/bootstrap.php.cache'; } -use Doctrine\Common\Annotations\AnnotationRegistry; use Composer\Autoload\ClassLoader; +use Doctrine\Common\Annotations\AnnotationRegistry; /** - * @var ClassLoader $loader + * @var ClassLoader */ $loader = require __DIR__.'/../vendor/autoload.php'; -AnnotationRegistry::registerLoader(array($loader, 'loadClass')); +AnnotationRegistry::registerLoader([$loader, 'loadClass']); return $loader; diff --git a/app/bundles/ApiBundle/ApiEvents.php b/app/bundles/ApiBundle/ApiEvents.php index 0eb40ff276f..756a595fef7 100644 --- a/app/bundles/ApiBundle/ApiEvents.php +++ b/app/bundles/ApiBundle/ApiEvents.php @@ -1,16 +1,17 @@ array( - 'public' => array( +return [ + 'routes' => [ + 'public' => [ // OAuth1.0a - 'bazinga_oauth_server_requesttoken' => array( + 'bazinga_oauth_server_requesttoken' => [ 'path' => '/oauth/v1/request_token', 'controller' => 'bazinga.oauth.controller.server:requestTokenAction', - 'method' => 'GET|POST' - ), - 'bazinga_oauth_login_allow' => array( + 'method' => 'GET|POST', + ], + 'bazinga_oauth_login_allow' => [ 'path' => '/oauth/v1/authorize', 'controller' => 'MauticApiBundle:oAuth1/Authorize:allow', - 'method' => 'GET' - ), - 'bazinga_oauth_server_authorize' => array( + 'method' => 'GET', + ], + 'bazinga_oauth_server_authorize' => [ 'path' => '/oauth/v1/authorize', 'controller' => 'bazinga.oauth.controller.server:authorizeAction', - 'method' => 'POST' - ), - 'mautic_oauth1_server_auth_login' => array( + 'method' => 'POST', + ], + 'mautic_oauth1_server_auth_login' => [ 'path' => '/oauth/v1/authorize_login', 'controller' => 'MauticApiBundle:oAuth1/Security:login', - 'method' => 'GET|POST' - ), - 'mautic_oauth1_server_auth_login_check' => array( + 'method' => 'GET|POST', + ], + 'mautic_oauth1_server_auth_login_check' => [ 'path' => '/oauth/v1/authorize_login_check', 'controller' => 'MauticApiBundle:oAuth1/Security:loginCheck', - 'method' => 'GET|POST' - ), - 'bazinga_oauth_server_accesstoken' => array( + 'method' => 'GET|POST', + ], + 'bazinga_oauth_server_accesstoken' => [ 'path' => '/oauth/v1/access_token', 'controller' => 'bazinga.oauth.controller.server:accessTokenAction', - 'method' => 'GET|POST' - ), + 'method' => 'GET|POST', + ], // OAuth2 - 'fos_oauth_server_token' => array( + 'fos_oauth_server_token' => [ 'path' => '/oauth/v2/token', 'controller' => 'fos_oauth_server.controller.token:tokenAction', - 'method' => 'GET|POST' - ), - 'fos_oauth_server_authorize' => array( + 'method' => 'GET|POST', + ], + 'fos_oauth_server_authorize' => [ 'path' => '/oauth/v2/authorize', 'controller' => 'MauticApiBundle:oAuth2/Authorize:authorize', - 'method' => 'GET|POST' - ), - 'mautic_oauth2_server_auth_login' => array( + 'method' => 'GET|POST', + ], + 'mautic_oauth2_server_auth_login' => [ 'path' => '/oauth/v2/authorize_login', 'controller' => 'MauticApiBundle:oAuth2/Security:login', - 'method' => 'GET|POST' - ), - 'mautic_oauth2_server_auth_login_check' => array( + 'method' => 'GET|POST', + ], + 'mautic_oauth2_server_auth_login_check' => [ 'path' => '/oauth/v2/authorize_login_check', 'controller' => 'MauticApiBundle:oAuth2/Security:loginCheck', - 'method' => 'GET|POST' - ), - ), - 'main' => array( + 'method' => 'GET|POST', + ], + ], + 'main' => [ // Clients - 'mautic_client_index' => array( + 'mautic_client_index' => [ 'path' => '/credentials/{page}', - 'controller' => 'MauticApiBundle:Client:index' - ), - 'mautic_client_action' => array( + 'controller' => 'MauticApiBundle:Client:index', + ], + 'mautic_client_action' => [ 'path' => '/credentials/{objectAction}/{objectId}', - 'controller' => 'MauticApiBundle:Client:execute' - ) - ) - ), + 'controller' => 'MauticApiBundle:Client:execute', + ], + ], + ], - 'menu' => array( - 'admin' => array( - 'items' => array( - 'mautic.api.client.menu.index' => array( + 'menu' => [ + 'admin' => [ + 'items' => [ + 'mautic.api.client.menu.index' => [ 'route' => 'mautic_client_index', 'iconClass' => 'fa-puzzle-piece', 'access' => 'api:clients:view', - 'checks' => array( - 'parameters' => array( - 'api_enabled' => true - ) - ) - ) - ) - ) - ), + 'checks' => [ + 'parameters' => [ + 'api_enabled' => true, + ], + ], + ], + ], + ], + ], - 'services' => array( - 'events' => array( - 'mautic.api.subscriber' => array( - 'class' => 'Mautic\ApiBundle\EventListener\ApiSubscriber', + 'services' => [ + 'events' => [ + 'mautic.api.subscriber' => [ + 'class' => 'Mautic\ApiBundle\EventListener\ApiSubscriber', 'arguments' => [ 'mautic.helper.ip_lookup', 'mautic.helper.core_parameters', - 'mautic.core.model.auditlog' - ] - ), - 'mautic.api.configbundle.subscriber' => array( - 'class' => 'Mautic\ApiBundle\EventListener\ConfigSubscriber' - ), - 'mautic.api.search.subscriber' => array( - 'class' => 'Mautic\ApiBundle\EventListener\SearchSubscriber', + 'mautic.core.model.auditlog', + ], + ], + 'mautic.api.configbundle.subscriber' => [ + 'class' => 'Mautic\ApiBundle\EventListener\ConfigSubscriber', + ], + 'mautic.api.search.subscriber' => [ + 'class' => 'Mautic\ApiBundle\EventListener\SearchSubscriber', 'arguments' => [ - 'mautic.api.model.client' - ] - ) - ), - 'forms' => array( - 'mautic.form.type.apiclients' => array( + 'mautic.api.model.client', + ], + ], + ], + 'forms' => [ + 'mautic.form.type.apiclients' => [ 'class' => 'Mautic\ApiBundle\Form\Type\ClientType', 'arguments' => 'mautic.factory', - 'alias' => 'client' - ), - 'mautic.form.type.apiconfig' => array( + 'alias' => 'client', + ], + 'mautic.form.type.apiconfig' => [ 'class' => 'Mautic\ApiBundle\Form\Type\ConfigType', - 'alias' => 'apiconfig' - ) - ), - 'other' => array( - 'mautic.api.oauth.event_listener' => array( - 'class' => 'Mautic\ApiBundle\EventListener\OAuthEventListener', - 'arguments' => [ + 'alias' => 'apiconfig', + ], + ], + 'other' => [ + 'mautic.api.oauth.event_listener' => [ + 'class' => 'Mautic\ApiBundle\EventListener\OAuthEventListener', + 'arguments' => [ 'doctrine.orm.entity_manager', 'mautic.security', - 'translator' + 'translator', ], - 'tags' => array( + 'tags' => [ + 'kernel.event_listener', 'kernel.event_listener', - 'kernel.event_listener' - ), - 'tagArguments' => array( - array( + ], + 'tagArguments' => [ + [ 'event' => 'fos_oauth_server.pre_authorization_process', - 'method' => 'onPreAuthorizationProcess' - ), - array( + 'method' => 'onPreAuthorizationProcess', + ], + [ 'event' => 'fos_oauth_server.post_authorization_process', - 'method' => 'onPostAuthorizationProcess' - ) - ) - ), - 'mautic.api.oauth1.nonce_provider' => array( + 'method' => 'onPostAuthorizationProcess', + ], + ], + ], + 'mautic.api.oauth1.nonce_provider' => [ 'class' => 'Mautic\ApiBundle\Provider\NonceProvider', - 'arguments' => 'doctrine.orm.entity_manager' - ), + 'arguments' => 'doctrine.orm.entity_manager', + ], 'bazinga.oauth.security.authentication.provider.class' => 'Mautic\ApiBundle\Security\OAuth1\Authentication\Provider\OAuthProvider', 'bazinga.oauth.security.authentication.listener.class' => 'Mautic\ApiBundle\Security\OAuth1\Firewall\OAuthListener', 'bazinga.oauth.event_listener.request.class' => 'Mautic\ApiBundle\EventListener\OAuth1\OAuthRequestListener', @@ -159,25 +160,25 @@ 'jms_serializer.metadata.annotation_driver.class' => 'Mautic\ApiBundle\Serializer\Driver\AnnotationDriver', 'jms_serializer.metadata.php_driver.class' => 'Mautic\ApiBundle\Serializer\Driver\ApiMetadataDriver', - 'mautic.validator.oauthcallback' => array( - 'class' => 'Mautic\ApiBundle\Form\Validator\Constraints\OAuthCallbackValidator', - 'tag' => 'validator.constraint_validator', - 'alias' => 'oauth_callback' - ) - ), - 'models' => array( - 'mautic.api.model.client' => array( - 'class' => 'Mautic\ApiBundle\Model\ClientModel', - 'arguments' => array( - 'request_stack' - ) - ) - ) - ), + 'mautic.validator.oauthcallback' => [ + 'class' => 'Mautic\ApiBundle\Form\Validator\Constraints\OAuthCallbackValidator', + 'tag' => 'validator.constraint_validator', + 'alias' => 'oauth_callback', + ], + ], + 'models' => [ + 'mautic.api.model.client' => [ + 'class' => 'Mautic\ApiBundle\Model\ClientModel', + 'arguments' => [ + 'request_stack', + ], + ], + ], + ], - 'parameters' => array( - "api_enabled" => false, - "api_oauth2_access_token_lifetime" => 60, - "api_oauth2_refresh_token_lifetime" => 14 - ) -); \ No newline at end of file + 'parameters' => [ + 'api_enabled' => false, + 'api_oauth2_access_token_lifetime' => 60, + 'api_oauth2_refresh_token_lifetime' => 14, + ], +]; diff --git a/app/bundles/ApiBundle/Controller/ClientController.php b/app/bundles/ApiBundle/Controller/ClientController.php index b726c983d92..e3a7aadec05 100644 --- a/app/bundles/ApiBundle/Controller/ClientController.php +++ b/app/bundles/ApiBundle/Controller/ClientController.php @@ -1,9 +1,10 @@ $limit, 'filter' => $filter, 'orderBy' => $orderBy, - 'orderByDir' => $orderByDir + 'orderByDir' => $orderByDir, ] ); @@ -69,8 +69,8 @@ public function indexAction($page = 1) 'contentTemplate' => 'MauticApiBundle:Client:index', 'passthroughVars' => [ 'activeLink' => 'mautic_client_index', - 'mauticContent' => 'client' - ] + 'mauticContent' => 'client', + ], ] ); } @@ -94,7 +94,7 @@ public function indexAction($page = 1) $apiOptions['oauth2'] = 'OAuth 2'; $filters['api_mode'] = [ 'values' => [$apiMode], - 'options' => $apiOptions + 'options' => $apiOptions, ]; $parameters = [ @@ -104,7 +104,7 @@ public function indexAction($page = 1) 'permissions' => $permissions, 'tmpl' => $tmpl, 'searchValue' => $filter, - 'filters' => $filters + 'filters' => $filters, ]; return $this->delegateView( @@ -113,8 +113,8 @@ public function indexAction($page = 1) 'contentTemplate' => 'MauticApiBundle:Client:list.html.php', 'passthroughVars' => [ 'route' => $this->generateUrl('mautic_client_index', ['page' => $page]), - 'mauticContent' => 'client' - ] + 'mauticContent' => 'client', + ], ] ); } @@ -150,7 +150,7 @@ public function revokeAction($clientId) $flashes[] = [ 'type' => 'error', 'msg' => 'mautic.api.client.error.notfound', - 'msgVars' => ['%id%' => $clientId] + 'msgVars' => ['%id%' => $clientId], ]; } else { $name = $client->getName(); @@ -161,8 +161,8 @@ public function revokeAction($clientId) 'type' => 'notice', 'msg' => 'mautic.api.client.notice.revoked', 'msgVars' => [ - '%name%' => $name - ] + '%name%' => $name, + ], ]; } } @@ -172,9 +172,9 @@ public function revokeAction($clientId) 'returnUrl' => $this->generateUrl('mautic_user_account'), 'contentTemplate' => 'MauticUserBundle:Profile:index', 'passthroughVars' => [ - 'success' => $success + 'success' => $success, ], - 'flashes' => $flashes + 'flashes' => $flashes, ] ); } @@ -231,9 +231,9 @@ public function newAction($objectId = 0) 'mautic_client_action', [ 'objectAction' => 'edit', - 'objectId' => $client->getId() + 'objectId' => $client->getId(), ] - ) + ), ] ); } @@ -246,8 +246,8 @@ public function newAction($objectId = 0) 'contentTemplate' => 'MauticApiBundle:Client:index', 'passthroughVars' => [ 'activeLink' => '#mautic_client_index', - 'mauticContent' => 'client' - ] + 'mauticContent' => 'client', + ], ] ); } elseif ($valid && !$cancelled) { @@ -257,22 +257,22 @@ public function newAction($objectId = 0) return $this->delegateView( [ - 'viewParameters' => [ + 'viewParameters' => [ 'form' => $form->createView(), - 'tmpl' => $this->request->get('tmpl', 'form') + 'tmpl' => $this->request->get('tmpl', 'form'), ], 'contentTemplate' => 'MauticApiBundle:Client:form.html.php', 'passthroughVars' => [ 'activeLink' => '#mautic_client_new', 'route' => $action, - 'mauticContent' => 'client' - ] + 'mauticContent' => 'client', + ], ] ); } /** - * Generates edit form and processes post data + * Generates edit form and processes post data. * * @param int $objectId * @param bool $ignorePost @@ -282,7 +282,6 @@ public function newAction($objectId = 0) public function editAction($objectId, $ignorePost = false) { if (!$this->get('mautic.security')->isGranted('api:clients:editother')) { - return $this->accessDenied(); } @@ -296,8 +295,8 @@ public function editAction($objectId, $ignorePost = false) 'contentTemplate' => 'MauticApiBundle:Client:index', 'passthroughVars' => [ 'activeLink' => '#mautic_client_index', - 'mauticContent' => 'client' - ] + 'mauticContent' => 'client', + ], ]; //client not found @@ -310,9 +309,9 @@ public function editAction($objectId, $ignorePost = false) [ 'type' => 'error', 'msg' => 'mautic.api.client.error.notfound', - 'msgVars' => ['%id%' => $objectId] - ] - ] + 'msgVars' => ['%id%' => $objectId], + ], + ], ] ) ); @@ -342,9 +341,9 @@ public function editAction($objectId, $ignorePost = false) 'mautic_client_action', [ 'objectAction' => 'edit', - 'objectId' => $client->getId() + 'objectId' => $client->getId(), ] - ) + ), ] ); @@ -365,22 +364,22 @@ public function editAction($objectId, $ignorePost = false) return $this->delegateView( [ - 'viewParameters' => [ + 'viewParameters' => [ 'form' => $form->createView(), - 'tmpl' => $this->request->get('tmpl', 'form') + 'tmpl' => $this->request->get('tmpl', 'form'), ], 'contentTemplate' => 'MauticApiBundle:Client:form.html.php', 'passthroughVars' => [ 'activeLink' => '#mautic_client_index', 'route' => $action, - 'mauticContent' => 'client' - ] + 'mauticContent' => 'client', + ], ] ); } /** - * Deletes the entity + * Deletes the entity. * * @param int $objectId * @@ -402,8 +401,8 @@ public function deleteAction($objectId) 'passthroughVars' => [ 'activeLink' => '#mautic_client_index', 'success' => $success, - 'mauticContent' => 'client' - ] + 'mauticContent' => 'client', + ], ]; if ($this->request->getMethod() == 'POST') { @@ -414,7 +413,7 @@ public function deleteAction($objectId) $flashes[] = [ 'type' => 'error', 'msg' => 'mautic.api.client.error.notfound', - 'msgVars' => ['%id%' => $objectId] + 'msgVars' => ['%id%' => $objectId], ]; } elseif ($model->isLocked($entity)) { //deny access if the entity is locked @@ -427,8 +426,8 @@ public function deleteAction($objectId) 'msg' => 'mautic.core.notice.deleted', 'msgVars' => [ '%name%' => $name, - '%id%' => $objectId - ] + '%id%' => $objectId, + ], ]; } } @@ -437,7 +436,7 @@ public function deleteAction($objectId) array_merge( $postActionVars, [ - 'flashes' => $flashes + 'flashes' => $flashes, ] ) ); diff --git a/app/bundles/ApiBundle/Controller/CommonApiController.php b/app/bundles/ApiBundle/Controller/CommonApiController.php index cf91d3f0221..bb830907303 100644 --- a/app/bundles/ApiBundle/Controller/CommonApiController.php +++ b/app/bundles/ApiBundle/Controller/CommonApiController.php @@ -1,11 +1,11 @@ request->get('published', 0); if ($publishedOnly) { - $this->listFilters[] = array( + $this->listFilters[] = [ 'column' => $tableAlias.'.isPublished', 'expr' => 'eq', - 'value' => true - ); + 'value' => true, + ]; } - $args = array( - 'start' => $this->request->query->get('start', 0), - 'limit' => $this->request->query->get('limit', $this->coreParametersHelper->getParameter('default_pagelimit')), - 'filter' => array( + $args = [ + 'start' => $this->request->query->get('start', 0), + 'limit' => $this->request->query->get('limit', $this->coreParametersHelper->getParameter('default_pagelimit')), + 'filter' => [ 'string' => $this->request->query->get('search', ''), - 'force' => $this->listFilters - ), + 'force' => $this->listFilters, + ], 'orderBy' => $this->request->query->get('orderBy', ''), 'orderByDir' => $this->request->query->get('orderByDir', 'ASC'), - 'withTotalCount' => true //for repositories that break free of Paginator - ); + 'withTotalCount' => true, //for repositories that break free of Paginator + ]; $results = $this->model->getEntities($args); list($entities, $totalCount) = $this->prepareEntitiesForView($results); $view = $this->view( - array( + [ 'total' => $totalCount, - $this->entityNameMulti => $entities - ), + $this->entityNameMulti => $entities, + ], Codes::HTTP_OK ); $this->setSerializationContext($view); @@ -220,7 +217,7 @@ public function getEntitiesAction() } /** - * Obtains a specific entity as defined by the API URL + * Obtains a specific entity as defined by the API URL. * * @param int $id Entity ID * @@ -238,14 +235,14 @@ public function getEntityAction($id) } $this->preSerializeEntity($entity); - $view = $this->view(array($this->entityNameOne => $entity), Codes::HTTP_OK); + $view = $this->view([$this->entityNameOne => $entity], Codes::HTTP_OK); $this->setSerializationContext($view); return $this->handleView($view); } /** - * Creates a new entity + * Creates a new entity. * * @return Response */ @@ -262,9 +259,8 @@ public function newEntityAction() return $this->processForm($entity, $parameters, 'POST'); } - /** - * Edits an existing entity or creates one on PUT if it doesn't exist + * Edits an existing entity or creates one on PUT if it doesn't exist. * * @param int $id Entity ID * @@ -297,7 +293,7 @@ public function editEntityAction($id) } /** - * Deletes an entity + * Deletes an entity. * * @param int $id Entity ID * @@ -314,7 +310,7 @@ public function deleteEntityAction($id) $this->model->deleteEntity($entity); $this->preSerializeEntity($entity); - $view = $this->view(array($this->entityNameOne => $entity), Codes::HTTP_OK); + $view = $this->view([$this->entityNameOne => $entity], Codes::HTTP_OK); $this->setSerializationContext($view); return $this->handleView($view); @@ -324,7 +320,7 @@ public function deleteEntityAction($id) } /** - * Processes API Form + * Processes API Form. * * @param $entity * @param null $parameters @@ -359,22 +355,23 @@ protected function processForm($entity, $parameters = null, $method = 'PUT') if ($form->isValid()) { $this->preSaveEntity($entity, $form, $parameters, $action); $this->model->saveEntity($entity); - $headers = array(); + $headers = []; //return the newly created entities location if applicable if (Codes::HTTP_CREATED === $statusCode) { $headers['Location'] = $this->generateUrl( 'mautic_api_get'.$this->entityNameOne, - array('id' => $entity->getId()), + ['id' => $entity->getId()], true ); } $this->preSerializeEntity($entity, $action); - $view = $this->view(array($this->entityNameOne => $entity), $statusCode, $headers); + $view = $this->view([$this->entityNameOne => $entity], $statusCode, $headers); $this->setSerializationContext($view); } else { $formErrors = $this->getFormErrorMessages($form); - $msg = $this->getFormErrorMessage($formErrors); + $msg = $this->getFormErrorMessage($formErrors); + return $this->returnError($msg, Codes::HTTP_BAD_REQUEST, $formErrors); } @@ -432,7 +429,7 @@ public function getFormErrorMessages(\Symfony\Component\Form\Form $form) } /** - * Checks if user has permission to access retrieved entity + * Checks if user has permission to access retrieved entity. * * @param mixed $entity * @param string $action view|create|edit|publish|delete @@ -452,7 +449,7 @@ protected function checkEntityAccess($entity, $action = 'view') } /** - * Creates the form instance + * Creates the form instance. * * @param $entity * @@ -464,11 +461,9 @@ protected function createEntityForm($entity) } /** - * Set serialization groups and exclusion strategies + * Set serialization groups and exclusion strategies. * * @param \FOS\RestBundle\View\View $view - * - * @return void */ protected function setSerializationContext(&$view) { @@ -489,7 +484,7 @@ protected function setSerializationContext(&$view) } /** - * Convert posted parameters into what the form needs in order to successfully bind + * Convert posted parameters into what the form needs in order to successfully bind. * * @param $parameters * @param $entity @@ -503,7 +498,7 @@ protected function prepareParametersForBinding($parameters, $entity, $action) } /** - * Give the controller an opportunity to process the entity before persisting + * Give the controller an opportunity to process the entity before persisting. * * @param $entity * @param $form @@ -517,7 +512,7 @@ protected function preSaveEntity(&$entity, $form, $parameters, $action = 'edit') } /** - * Gives child controllers opportunity to analyze and do whatever to an entity before going through serializer + * Gives child controllers opportunity to analyze and do whatever to an entity before going through serializer. * * @param $entity * @param string $action @@ -529,7 +524,7 @@ protected function preSerializeEntity(&$entity, $action = 'view') } /** - * Gives child controllers opportunity to analyze and do whatever to an entity before populating the form + * Gives child controllers opportunity to analyze and do whatever to an entity before populating the form. * * @param $entity * @param $parameters @@ -542,11 +537,11 @@ protected function prePopulateForm(&$entity, $parameters, $action = 'edit') } /** - * Returns an error + * Returns an error. * - * @param string $msg - * @param integer $code - * @param array $details + * @param string $msg + * @param int $code + * @param array $details * * @return Response */ @@ -556,9 +551,9 @@ protected function returnError($msg, $code, $details = []) [ 'error' => [ 'code' => $code, - 'message' => $this->get('translator')->trans($msg, array(), 'flashes'), - 'details' => $details - ] + 'message' => $this->get('translator')->trans($msg, [], 'flashes'), + 'details' => $details, + ], ], $code ); @@ -567,7 +562,7 @@ protected function returnError($msg, $code, $details = []) } /** - * Returns a 403 Access Denied + * Returns a 403 Access Denied. * * @param string $msg * @@ -579,7 +574,7 @@ protected function accessDenied($msg = 'mautic.core.error.accessdenied') } /** - * Returns a 404 Not Found + * Returns a 404 Not Found. * * @param string $msg * @@ -591,7 +586,7 @@ protected function notFound($msg = 'mautic.core.error.notfound') } /** - * Returns a 400 Bad Request + * Returns a 400 Bad Request. * * @param string $msg * @@ -609,9 +604,8 @@ protected function badRequest($msg = 'mautic.core.error.badrequest') * @param null $statusCode * @param array $headers */ - protected function view($data = null, $statusCode = null, array $headers = array()) + protected function view($data = null, $statusCode = null, array $headers = []) { - if ($data instanceof Paginator) { // Get iterator out of Paginator class so that the entities are properly serialized by the serializer $data = $data->getIterator()->getArrayCopy(); @@ -621,7 +615,7 @@ protected function view($data = null, $statusCode = null, array $headers = array } /** - * Prepares entities returned from repository getEntities() + * Prepares entities returned from repository getEntities(). * * @param $results * @@ -629,7 +623,6 @@ protected function view($data = null, $statusCode = null, array $headers = array */ protected function prepareEntitiesForView($results) { - if ($results instanceof Paginator) { $totalCount = count($results); } elseif (isset($results['count'])) { @@ -641,7 +634,7 @@ protected function prepareEntitiesForView($results) //we have to convert them from paginated proxy functions to entities in order for them to be //returned by the serializer/rest bundle - $entities = array(); + $entities = []; foreach ($results as $r) { if (is_array($r) && isset($r[0])) { //entity has some extra something something tacked onto the entities @@ -669,11 +662,11 @@ protected function prepareEntitiesForView($results) } } - return array($entities, $totalCount); + return [$entities, $totalCount]; } /** - * Get a model instance from the service container + * Get a model instance from the service container. * * @param $modelNameKey * @@ -689,17 +682,17 @@ protected function getModel($modelNameKey) $parts = explode('.', $modelNameKey); if (count($parts) !== 2) { - throw new \InvalidArgumentException($modelNameKey . " is not a valid model key."); + throw new \InvalidArgumentException($modelNameKey.' is not a valid model key.'); } list($bundle, $name) = $parts; - $containerKey = str_replace(array('%bundle%', '%name%'), array($bundle, $name), 'mautic.%bundle%.model.%name%'); + $containerKey = str_replace(['%bundle%', '%name%'], [$bundle, $name], 'mautic.%bundle%.model.%name%'); if ($this->container->has($containerKey)) { return $this->container->get($containerKey); } - throw new \InvalidArgumentException($containerKey . ' is not a registered container key.'); + throw new \InvalidArgumentException($containerKey.' is not a registered container key.'); } } diff --git a/app/bundles/ApiBundle/Controller/oAuth1/AuthorizeController.php b/app/bundles/ApiBundle/Controller/oAuth1/AuthorizeController.php index c058639dbd2..5b789dc4090 100644 --- a/app/bundles/ApiBundle/Controller/oAuth1/AuthorizeController.php +++ b/app/bundles/ApiBundle/Controller/oAuth1/AuthorizeController.php @@ -1,9 +1,10 @@ setUserForRequestToken($token, $securityContext->getToken()->getUser()); - return new Response($this->container->get('templating')->render('MauticApiBundle:Authorize:oAuth1/authorize.html.php', array( + return new Response($this->container->get('templating')->render('MauticApiBundle:Authorize:oAuth1/authorize.html.php', [ 'consumer' => $token->getConsumer(), 'oauth_token' => $oauth_token, - 'oauth_callback' => $oauth_callback - ))); + 'oauth_callback' => $oauth_callback, + ])); } - throw new HttpException(404); } } diff --git a/app/bundles/ApiBundle/Controller/oAuth1/SecurityController.php b/app/bundles/ApiBundle/Controller/oAuth1/SecurityController.php index 0b61a712077..11dd3234dbc 100644 --- a/app/bundles/ApiBundle/Controller/oAuth1/SecurityController.php +++ b/app/bundles/ApiBundle/Controller/oAuth1/SecurityController.php @@ -1,9 +1,10 @@ getMessage(); } - $this->addFlash($msg, array(), 'error', null, false); + $this->addFlash($msg, [], 'error', null, false); } return $this->render( 'MauticApiBundle:Security:login.html.php', - array( + [ 'last_username' => $session->get(SecurityContext::LAST_USERNAME), - 'route' => 'mautic_oauth1_server_auth_login_check' - ) + 'route' => 'mautic_oauth1_server_auth_login_check', + ] ); } @@ -60,4 +60,4 @@ public function loginCheckAction() { return new Response('', 400); } -} \ No newline at end of file +} diff --git a/app/bundles/ApiBundle/Controller/oAuth2/AuthorizeController.php b/app/bundles/ApiBundle/Controller/oAuth2/AuthorizeController.php index bf87ebfb9bb..5c5ad1f1495 100644 --- a/app/bundles/ApiBundle/Controller/oAuth2/AuthorizeController.php +++ b/app/bundles/ApiBundle/Controller/oAuth2/AuthorizeController.php @@ -1,10 +1,11 @@ container->get('session')->set('_fos_oauth_server.ensure_logout', true); } - $form = $this->container->get('fos_oauth_server.authorize.form'); + $form = $this->container->get('fos_oauth_server.authorize.form'); $formHandler = $this->container->get('fos_oauth_server.authorize.form.handler'); $event = $this->container->get('event_dispatcher')->dispatch( @@ -67,10 +68,10 @@ public function authorizeAction(Request $request) return $this->container->get('templating')->renderResponse( 'MauticApiBundle:Authorize:oAuth2/authorize.html.php', - array( - 'form' => $form->createView(), - 'client' => $this->getClient(), - ) + [ + 'form' => $form->createView(), + 'client' => $this->getClient(), + ] ); } } diff --git a/app/bundles/ApiBundle/Controller/oAuth2/SecurityController.php b/app/bundles/ApiBundle/Controller/oAuth2/SecurityController.php index e1a7c551253..fed39885b6d 100644 --- a/app/bundles/ApiBundle/Controller/oAuth2/SecurityController.php +++ b/app/bundles/ApiBundle/Controller/oAuth2/SecurityController.php @@ -1,9 +1,10 @@ getMessage(); } - $this->addFlash($msg, array(), 'error', null, false); + $this->addFlash($msg, [], 'error', null, false); } if ($session->has('_security.target_path')) { @@ -54,10 +54,10 @@ public function loginAction(Request $request) return $this->render( 'MauticApiBundle:Security:login.html.php', - array( + [ 'last_username' => $session->get(SecurityContext::LAST_USERNAME), - 'route' => 'mautic_oauth2_server_auth_login_check' - ) + 'route' => 'mautic_oauth2_server_auth_login_check', + ] ); } diff --git a/app/bundles/ApiBundle/DependencyInjection/Compiler/OAuthPass.php b/app/bundles/ApiBundle/DependencyInjection/Compiler/OAuthPass.php index f7f28df3620..b91988a078a 100644 --- a/app/bundles/ApiBundle/DependencyInjection/Compiler/OAuthPass.php +++ b/app/bundles/ApiBundle/DependencyInjection/Compiler/OAuthPass.php @@ -1,9 +1,10 @@ hasDefinition('bazinga.oauth.security.authentication.provider')) { //Add a addMethodCall to set factory $container->getDefinition('bazinga.oauth.security.authentication.provider')->addMethodCall( - 'setFactory', array(new Reference('mautic.factory')) + 'setFactory', [new Reference('mautic.factory')] ); } if ($container->hasDefinition('bazinga.oauth.security.authentication.listener')) { //Add a addMethodCall to set factory $container->getDefinition('bazinga.oauth.security.authentication.listener')->addMethodCall( - 'setFactory', array(new Reference('mautic.factory')) + 'setFactory', [new Reference('mautic.factory')] ); } if ($container->hasDefinition('fos_oauth_server.security.authentication.listener')) { //Add a addMethodCall to set factory $container->getDefinition('fos_oauth_server.security.authentication.listener')->addMethodCall( - 'setFactory', array(new Reference('mautic.factory')) + 'setFactory', [new Reference('mautic.factory')] ); } } diff --git a/app/bundles/ApiBundle/DependencyInjection/Factory/ApiFactory.php b/app/bundles/ApiBundle/DependencyInjection/Factory/ApiFactory.php index ca3bdc59228..19bf175a841 100644 --- a/app/bundles/ApiBundle/DependencyInjection/Factory/ApiFactory.php +++ b/app/bundles/ApiBundle/DependencyInjection/Factory/ApiFactory.php @@ -1,22 +1,23 @@ setDefinition($listenerId, new DefinitionDecorator('mautic_api.security.authentication.listener')); - return array($providerId, $listenerId, $defaultEntryPoint); + return [$providerId, $listenerId, $defaultEntryPoint]; } /** diff --git a/app/bundles/ApiBundle/Entity/oAuth1/AccessToken.php b/app/bundles/ApiBundle/Entity/oAuth1/AccessToken.php index 5b43c340de9..ec24a2850ae 100644 --- a/app/bundles/ApiBundle/Entity/oAuth1/AccessToken.php +++ b/app/bundles/ApiBundle/Entity/oAuth1/AccessToken.php @@ -1,28 +1,26 @@ setTable('oauth1_access_tokens') - ->addIndex(array('token'), 'oauth1_access_token_search'); + ->addIndex(['token'], 'oauth1_access_token_search'); $builder->createField('id', 'integer') ->isPrimaryKey() @@ -88,25 +86,25 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getId () + public function getId() { return $this->id; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getToken () + public function getToken() { return $this->token; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setToken ($token) + public function setToken($token) { $this->token = $token; @@ -114,17 +112,17 @@ public function setToken ($token) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getSecret () + public function getSecret() { return $this->secret; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setSecret ($secret) + public function setSecret($secret) { $this->secret = $secret; @@ -132,17 +130,17 @@ public function setSecret ($secret) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getExpiresAt () + public function getExpiresAt() { return $this->expiresAt; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setExpiresAt ($expiresAt) + public function setExpiresAt($expiresAt) { $this->expiresAt = $expiresAt; @@ -150,9 +148,9 @@ public function setExpiresAt ($expiresAt) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getExpiresIn () + public function getExpiresIn() { if ($this->expiresAt) { return $this->expiresAt - time(); @@ -162,9 +160,9 @@ public function getExpiresIn () } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function hasExpired () + public function hasExpired() { if ($this->expiresAt) { return time() > $this->expiresAt; @@ -174,17 +172,17 @@ public function hasExpired () } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getUser () + public function getUser() { return $this->user; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setUser (UserInterface $user) + public function setUser(UserInterface $user) { $this->user = $user; @@ -192,9 +190,9 @@ public function setUser (UserInterface $user) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setConsumer (ConsumerInterface $consumer) + public function setConsumer(ConsumerInterface $consumer) { $this->consumer = $consumer; @@ -202,9 +200,9 @@ public function setConsumer (ConsumerInterface $consumer) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getConsumer () + public function getConsumer() { return $this->consumer; } diff --git a/app/bundles/ApiBundle/Entity/oAuth1/Consumer.php b/app/bundles/ApiBundle/Entity/oAuth1/Consumer.php index 33b1c4bcf28..089ad226541 100644 --- a/app/bundles/ApiBundle/Entity/oAuth1/Consumer.php +++ b/app/bundles/ApiBundle/Entity/oAuth1/Consumer.php @@ -1,9 +1,10 @@ accessTokens = new ArrayCollection(); } @@ -66,14 +64,14 @@ public function __construct () /** * @param ORM\ClassMetadata $metadata */ - public static function loadMetadata (ORM\ClassMetadata $metadata) + public static function loadMetadata(ORM\ClassMetadata $metadata) { $builder = new ClassMetadataBuilder($metadata); $builder->setTable('oauth1_consumers') ->setCustomRepositoryClass('Mautic\ApiBundle\Entity\oAuth1\ConsumerRepository') ->addLifecycleEvent('createConsumerKeys', 'prePersist') - ->addIndex(array('consumer_key'), 'consumer_search'); + ->addIndex(['consumer_key'], 'consumer_search'); $builder->addIdColumns('name', false); @@ -97,47 +95,47 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) /** * @param ClassMetadata $metadata */ - public static function loadValidatorMetadata (ClassMetadata $metadata) + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('name', new Assert\NotBlank( - array('message' => 'mautic.core.name.required') + ['message' => 'mautic.core.name.required'] )); } /** - * Proxy to get consumer key + * Proxy to get consumer key. * * @return mixed */ - public function getRandomId () + public function getRandomId() { return $this->consumerKey; } /** - * Proxy to consumer key + * Proxy to consumer key. * * @return mixed */ - public function getPublicId () + public function getPublicId() { return $this->consumerKey; } /** - * Proxy to consumer secret + * Proxy to consumer secret. * * @return mixed */ - public function getSecret () + public function getSecret() { return $this->consumerSecret; } /** - * Create consumer keys + * Create consumer keys. */ - public function createConsumerKeys () + public function createConsumerKeys() { if (empty($this->consumerKey)) { $this->consumerKey = Random::generateToken(); @@ -146,35 +144,35 @@ public function createConsumerKeys () } /** - * Proxy to callback + * Proxy to callback. * * @return array */ - public function getRedirectUris () + public function getRedirectUris() { - return array($this->callback); + return [$this->callback]; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getId () + public function getId() { return $this->id; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getName () + public function getName() { return $this->name; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setName ($name) + public function setName($name) { $this->name = $name; @@ -182,17 +180,17 @@ public function setName ($name) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getConsumerKey () + public function getConsumerKey() { return $this->consumerKey; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setConsumerKey ($consumerKey) + public function setConsumerKey($consumerKey) { $this->consumerKey = $consumerKey; @@ -200,17 +198,17 @@ public function setConsumerKey ($consumerKey) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getConsumerSecret () + public function getConsumerSecret() { return $this->consumerSecret; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setConsumerSecret ($consumerSecret) + public function setConsumerSecret($consumerSecret) { $this->consumerSecret = $consumerSecret; @@ -218,17 +216,17 @@ public function setConsumerSecret ($consumerSecret) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getCallback () + public function getCallback() { return $this->callback; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setCallback ($callback) + public function setCallback($callback) { $this->callback = $callback; diff --git a/app/bundles/ApiBundle/Entity/oAuth1/ConsumerRepository.php b/app/bundles/ApiBundle/Entity/oAuth1/ConsumerRepository.php index fd51cc3f278..c0dc47a9d98 100644 --- a/app/bundles/ApiBundle/Entity/oAuth1/ConsumerRepository.php +++ b/app/bundles/ApiBundle/Entity/oAuth1/ConsumerRepository.php @@ -1,24 +1,24 @@ expr()->eq('a.user', ':user') ) ) - ->setParameters(array( + ->setParameters([ 'consumer' => $consumer, - 'user' => $user - )); + 'user' => $user, + ]); $qb->getQuery()->execute(); } @@ -66,12 +64,13 @@ public function deleteAccessTokens(Consumer $consumer, User $user) /** * {@inheritdoc} */ - public function getEntities($args = array()) + public function getEntities($args = []) { $q = $this ->createQueryBuilder('c'); $query = $q->getQuery(); + return new Paginator($query); } @@ -80,8 +79,8 @@ public function getEntities($args = array()) */ protected function addCatchAllWhereClause(&$q, $filter) { - $unique = $this->generateRandomParameterName(); //ensure that the string has a unique parameter identifier - $string = ($filter->strict) ? $filter->string : "%{$filter->string}%"; + $unique = $this->generateRandomParameterName(); //ensure that the string has a unique parameter identifier + $string = ($filter->strict) ? $filter->string : "%{$filter->string}%"; $expr = $q->expr()->orX( $q->expr()->like('c.name', ':'.$unique), @@ -92,10 +91,10 @@ protected function addCatchAllWhereClause(&$q, $filter) $expr = $q->expr()->not($expr); } - return array( + return [ $expr, - array("$unique" => $string) - ); + ["$unique" => $string], + ]; } /** @@ -103,9 +102,9 @@ protected function addCatchAllWhereClause(&$q, $filter) */ protected function getDefaultOrder() { - return array( - array('c.name', 'ASC') - ); + return [ + ['c.name', 'ASC'], + ]; } /** diff --git a/app/bundles/ApiBundle/Entity/oAuth1/Nonce.php b/app/bundles/ApiBundle/Entity/oAuth1/Nonce.php index 23d39f5ac17..231f0972b14 100644 --- a/app/bundles/ApiBundle/Entity/oAuth1/Nonce.php +++ b/app/bundles/ApiBundle/Entity/oAuth1/Nonce.php @@ -1,9 +1,10 @@ nonce = $nonce; $this->timestamp = $timestamp; @@ -41,7 +39,7 @@ public function __construct ($nonce, $timestamp) /** * @param ORM\ClassMetadata $metadata */ - public static function loadMetadata (ORM\ClassMetadata $metadata) + public static function loadMetadata(ORM\ClassMetadata $metadata) { $builder = new ClassMetadataBuilder($metadata); @@ -58,7 +56,7 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) /** * @return mixed */ - public function getNonce () + public function getNonce() { return $this->nonce; } @@ -66,7 +64,7 @@ public function getNonce () /** * @return mixed */ - public function getTimestamp () + public function getTimestamp() { return $this->timestamp; } diff --git a/app/bundles/ApiBundle/Entity/oAuth1/NonceRepository.php b/app/bundles/ApiBundle/Entity/oAuth1/NonceRepository.php index ffb5ba80f3f..fa80733f8f5 100644 --- a/app/bundles/ApiBundle/Entity/oAuth1/NonceRepository.php +++ b/app/bundles/ApiBundle/Entity/oAuth1/NonceRepository.php @@ -1,9 +1,10 @@ setTable('oauth1_request_tokens') - ->addIndex(array('token'), 'oauth1_request_token_search'); + ->addIndex(['token'], 'oauth1_request_token_search'); $builder->createField('id', 'integer') ->isPrimaryKey() @@ -93,25 +91,25 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getId () + public function getId() { return $this->id; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getToken () + public function getToken() { return $this->token; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setToken ($token) + public function setToken($token) { $this->token = $token; @@ -119,17 +117,17 @@ public function setToken ($token) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getSecret () + public function getSecret() { return $this->secret; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setSecret ($secret) + public function setSecret($secret) { $this->secret = $secret; @@ -137,17 +135,17 @@ public function setSecret ($secret) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getExpiresAt () + public function getExpiresAt() { return $this->expiresAt; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setExpiresAt ($expiresAt) + public function setExpiresAt($expiresAt) { $this->expiresAt = $expiresAt; @@ -155,9 +153,9 @@ public function setExpiresAt ($expiresAt) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getExpiresIn () + public function getExpiresIn() { if ($this->expiresAt) { return $this->expiresAt - time(); @@ -167,9 +165,9 @@ public function getExpiresIn () } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function hasExpired () + public function hasExpired() { if ($this->expiresAt) { return time() > $this->expiresAt; @@ -179,17 +177,17 @@ public function hasExpired () } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getUser () + public function getUser() { return $this->user; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setUser (UserInterface $user) + public function setUser(UserInterface $user) { $this->user = $user; @@ -197,9 +195,9 @@ public function setUser (UserInterface $user) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setConsumer (ConsumerInterface $consumer) + public function setConsumer(ConsumerInterface $consumer) { $this->consumer = $consumer; @@ -207,25 +205,25 @@ public function setConsumer (ConsumerInterface $consumer) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getConsumer () + public function getConsumer() { return $this->consumer; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getVerifier () + public function getVerifier() { return $this->verifier; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function setVerifier ($verifier) + public function setVerifier($verifier) { $this->verifier = $verifier; } diff --git a/app/bundles/ApiBundle/Entity/oAuth2/AccessToken.php b/app/bundles/ApiBundle/Entity/oAuth2/AccessToken.php index 03452ebdfab..adb817f1dcf 100644 --- a/app/bundles/ApiBundle/Entity/oAuth2/AccessToken.php +++ b/app/bundles/ApiBundle/Entity/oAuth2/AccessToken.php @@ -1,28 +1,26 @@ setTable('oauth2_accesstokens') - ->addIndex(array('token'), 'oauth2_access_token_search'); + ->addIndex(['token'], 'oauth2_access_token_search'); $builder->createField('id', 'integer') ->isPrimaryKey() @@ -91,23 +89,23 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) } /** - * Get id + * Get id. * - * @return integer + * @return int */ - public function getId () + public function getId() { return $this->id; } /** - * Set client + * Set client. * * @param ClientInterface $client * * @return AccessToken */ - public function setClient (ClientInterface $client) + public function setClient(ClientInterface $client) { $this->client = $client; @@ -115,23 +113,23 @@ public function setClient (ClientInterface $client) } /** - * Get client + * Get client. * * @return ClientInterface */ - public function getClient () + public function getClient() { return $this->client; } /** - * Set user + * Set user. * * @param UserInterface $user * * @return AccessToken */ - public function setUser (UserInterface $user = null) + public function setUser(UserInterface $user = null) { $this->user = $user; @@ -139,11 +137,11 @@ public function setUser (UserInterface $user = null) } /** - * Get user + * Get user. * * @return UserInterface */ - public function getUser () + public function getUser() { return $this->user; } diff --git a/app/bundles/ApiBundle/Entity/oAuth2/AuthCode.php b/app/bundles/ApiBundle/Entity/oAuth2/AuthCode.php index df6921c7984..fd3748c26f6 100644 --- a/app/bundles/ApiBundle/Entity/oAuth2/AuthCode.php +++ b/app/bundles/ApiBundle/Entity/oAuth2/AuthCode.php @@ -1,28 +1,26 @@ id; } /** - * Set client + * Set client. * * @param ClientInterface $client * * @return RefreshToken */ - public function setClient (ClientInterface $client) + public function setClient(ClientInterface $client) { $this->client = $client; @@ -123,23 +121,23 @@ public function setClient (ClientInterface $client) } /** - * Get client + * Get client. * * @return ClientInterface */ - public function getClient () + public function getClient() { return $this->client; } /** - * Set user + * Set user. * * @param UserInterface $user * * @return RefreshToken */ - public function setUser (UserInterface $user = null) + public function setUser(UserInterface $user = null) { $this->user = $user; @@ -147,11 +145,11 @@ public function setUser (UserInterface $user = null) } /** - * Get user + * Get user. * * @return UserInterface */ - public function getUser () + public function getUser() { return $this->user; } diff --git a/app/bundles/ApiBundle/Entity/oAuth2/Client.php b/app/bundles/ApiBundle/Entity/oAuth2/Client.php index f32eae761ab..e66aa6b593c 100644 --- a/app/bundles/ApiBundle/Entity/oAuth2/Client.php +++ b/app/bundles/ApiBundle/Entity/oAuth2/Client.php @@ -1,17 +1,18 @@ allowedGrantTypes = array( + $this->allowedGrantTypes = [ OAuth2::GRANT_TYPE_AUTH_CODE, OAuth2::GRANT_TYPE_REFRESH_TOKEN, - ); + ]; $this->users = new ArrayCollection(); } @@ -79,13 +77,13 @@ public function __construct () /** * @param ORM\ClassMetadata $metadata */ - public static function loadMetadata (ORM\ClassMetadata $metadata) + public static function loadMetadata(ORM\ClassMetadata $metadata) { $builder = new ClassMetadataBuilder($metadata); $builder->setTable('oauth2_clients') ->setCustomRepositoryClass('Mautic\ApiBundle\Entity\oAuth2\ClientRepository') - ->addIndex(array('random_id'), 'client_id_search'); + ->addIndex(['random_id'], 'client_id_search'); $builder->addIdColumns('name', false); @@ -114,14 +112,14 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) /** * @param ClassMetadata $metadata */ - public static function loadValidatorMetadata (ClassMetadata $metadata) + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('name', new Assert\NotBlank( - array('message' => 'mautic.core.name.required') + ['message' => 'mautic.core.name.required'] )); $metadata->addPropertyConstraint('redirectUris', new Assert\NotBlank( - array('message' => 'mautic.api.client.redirecturis.notblank') + ['message' => 'mautic.api.client.redirecturis.notblank'] )); } @@ -133,44 +131,42 @@ public static function loadValidatorMetadata (ClassMetadata $metadata) /** * @param $prop * @param $val - * - * @return void */ - protected function isChanged ($prop, $val) + protected function isChanged($prop, $val) { - $getter = "get" . ucfirst($prop); + $getter = 'get'.ucfirst($prop); $current = $this->$getter(); if ($current != $val) { - $this->changes[$prop] = array($current, $val); + $this->changes[$prop] = [$current, $val]; } } /** * @return array */ - public function getChanges () + public function getChanges() { return $this->changes; } /** - * Get id + * Get id. * - * @return integer + * @return int */ - public function getId () + public function getId() { return $this->id; } /** - * Set name + * Set name. * * @param string $name * * @return Client */ - public function setName ($name) + public function setName($name) { $this->isChanged('name', $name); @@ -180,11 +176,11 @@ public function setName ($name) } /** - * Get name + * Get name. * * @return string */ - public function getName () + public function getName() { return $this->name; } @@ -192,7 +188,7 @@ public function getName () /** * {@inheritdoc} */ - public function setRedirectUris (array $redirectUris) + public function setRedirectUris(array $redirectUris) { $this->isChanged('redirectUris', $redirectUris); @@ -200,13 +196,13 @@ public function setRedirectUris (array $redirectUris) } /** - * Add authCodes + * Add authCodes. * * @param AuthCode $authCodes * * @return Client */ - public function addAuthCode (AuthCode $authCodes) + public function addAuthCode(AuthCode $authCodes) { $this->authCodes[] = $authCodes; @@ -214,33 +210,33 @@ public function addAuthCode (AuthCode $authCodes) } /** - * Remove authCodes + * Remove authCodes. * * @param AuthCode $authCodes */ - public function removeAuthCode (AuthCode $authCodes) + public function removeAuthCode(AuthCode $authCodes) { $this->authCodes->removeElement($authCodes); } /** - * Get authCodes + * Get authCodes. * * @return \Doctrine\Common\Collections\Collection */ - public function getAuthCodes () + public function getAuthCodes() { return $this->authCodes; } /** - * Determines if a client attempting API access is already authorized by the user + * Determines if a client attempting API access is already authorized by the user. * * @param User $user * * @return bool */ - public function isAuthorizedClient (User $user) + public function isAuthorizedClient(User $user) { $users = $this->getUsers(); @@ -248,13 +244,13 @@ public function isAuthorizedClient (User $user) } /** - * Add users + * Add users. * * @param \Mautic\UserBundle\Entity\User $users * * @return Client */ - public function addUser (\Mautic\UserBundle\Entity\User $users) + public function addUser(\Mautic\UserBundle\Entity\User $users) { $this->users[] = $users; @@ -262,21 +258,21 @@ public function addUser (\Mautic\UserBundle\Entity\User $users) } /** - * Remove users + * Remove users. * * @param \Mautic\UserBundle\Entity\User $users */ - public function removeUser (\Mautic\UserBundle\Entity\User $users) + public function removeUser(\Mautic\UserBundle\Entity\User $users) { $this->users->removeElement($users); } /** - * Get users + * Get users. * * @return \Doctrine\Common\Collections\Collection */ - public function getUsers () + public function getUsers() { return $this->users; } diff --git a/app/bundles/ApiBundle/Entity/oAuth2/ClientRepository.php b/app/bundles/ApiBundle/Entity/oAuth2/ClientRepository.php index 9c82eadf1ab..882a1295eaf 100644 --- a/app/bundles/ApiBundle/Entity/oAuth2/ClientRepository.php +++ b/app/bundles/ApiBundle/Entity/oAuth2/ClientRepository.php @@ -1,24 +1,24 @@ createQueryBuilder('c'); $query = $q->getQuery(); + return new Paginator($query); } @@ -52,8 +53,8 @@ public function getEntities($args = array()) */ protected function addCatchAllWhereClause(&$q, $filter) { - $unique = $this->generateRandomParameterName(); //ensure that the string has a unique parameter identifier - $string = ($filter->strict) ? $filter->string : "%{$filter->string}%"; + $unique = $this->generateRandomParameterName(); //ensure that the string has a unique parameter identifier + $string = ($filter->strict) ? $filter->string : "%{$filter->string}%"; $expr = $q->expr()->orX( $q->expr()->like('c.name', ':'.$unique), @@ -64,10 +65,10 @@ protected function addCatchAllWhereClause(&$q, $filter) $expr = $q->expr()->not($expr); } - return array( + return [ $expr, - array("$unique" => $string) - ); + ["$unique" => $string], + ]; } /** @@ -75,9 +76,9 @@ protected function addCatchAllWhereClause(&$q, $filter) */ protected function getDefaultOrder() { - return array( - array('c.name', 'ASC') - ); + return [ + ['c.name', 'ASC'], + ]; } /** diff --git a/app/bundles/ApiBundle/Entity/oAuth2/RefreshToken.php b/app/bundles/ApiBundle/Entity/oAuth2/RefreshToken.php index 8254f85358e..f3a857bae54 100644 --- a/app/bundles/ApiBundle/Entity/oAuth2/RefreshToken.php +++ b/app/bundles/ApiBundle/Entity/oAuth2/RefreshToken.php @@ -1,28 +1,26 @@ setTable('oauth2_refreshtokens') - ->addIndex(array('token'), 'oauth2_refresh_token_search'); + ->addIndex(['token'], 'oauth2_refresh_token_search'); $builder->createField('id', 'integer') ->isPrimaryKey() @@ -91,23 +89,23 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) } /** - * Get id + * Get id. * - * @return integer + * @return int */ - public function getId () + public function getId() { return $this->id; } /** - * Set client + * Set client. * * @param ClientInterface $client * * @return RefreshToken */ - public function setClient (ClientInterface $client) + public function setClient(ClientInterface $client) { $this->client = $client; @@ -115,23 +113,23 @@ public function setClient (ClientInterface $client) } /** - * Get client + * Get client. * * @return ClientInterface */ - public function getClient () + public function getClient() { return $this->client; } /** - * Set user + * Set user. * * @param UserInterface $user * * @return RefreshToken */ - public function setUser (UserInterface $user = null) + public function setUser(UserInterface $user = null) { $this->user = $user; @@ -139,12 +137,12 @@ public function setUser (UserInterface $user = null) } /** - * Get user + * Get user. * * @return UserInterface */ - public function getUser () + public function getUser() { return $this->user; } -} \ No newline at end of file +} diff --git a/app/bundles/ApiBundle/Event/ClientEvent.php b/app/bundles/ApiBundle/Event/ClientEvent.php index 53bd69d3c01..69482cbe335 100644 --- a/app/bundles/ApiBundle/Event/ClientEvent.php +++ b/app/bundles/ApiBundle/Event/ClientEvent.php @@ -1,25 +1,25 @@ apiMode = ($client instanceof Client) ? 'oauth2' : 'oauth1'; @@ -42,7 +42,7 @@ public function __construct($client, $isNew = false) } /** - * Returns the Client entity + * Returns the Client entity. * * @return Client */ @@ -52,7 +52,7 @@ public function getClient() } /** - * Returns the api mode + * Returns the api mode. * * @return string */ diff --git a/app/bundles/ApiBundle/EventListener/ApiSubscriber.php b/app/bundles/ApiBundle/EventListener/ApiSubscriber.php index 333c4b543d4..d7b5ceecdd0 100644 --- a/app/bundles/ApiBundle/EventListener/ApiSubscriber.php +++ b/app/bundles/ApiBundle/EventListener/ApiSubscriber.php @@ -1,16 +1,16 @@ ipLookupHelper = $ipLookupHelper; + $this->ipLookupHelper = $ipLookupHelper; $this->coreParametersHelper = $coreParametersHelper; - $this->auditLogModel = $auditLogModel; + $this->auditLogModel = $auditLogModel; } /** @@ -59,15 +59,15 @@ public function __construct(IpLookupHelper $ipLookupHelper, CoreParametersHelper */ public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 255), - ApiEvents::CLIENT_POST_SAVE => array('onClientPostSave', 0), - ApiEvents::CLIENT_POST_DELETE => array('onClientDelete', 0) - ); + return [ + KernelEvents::REQUEST => ['onKernelRequest', 255], + ApiEvents::CLIENT_POST_SAVE => ['onClientPostSave', 0], + ApiEvents::CLIENT_POST_DELETE => ['onClientDelete', 0], + ]; } /** - * Check for API requests and throw denied access if API is disabled + * Check for API requests and throw denied access if API is disabled. * * @param GetResponseEvent $event */ @@ -86,20 +86,19 @@ public function onKernelRequest(GetResponseEvent $event) defined('MAUTIC_API_REQUEST') or define('MAUTIC_API_REQUEST', $isApiRequest); if ($isApiRequest && !$apiEnabled) { - throw new AccessDeniedHttpException( $this->translator->trans( 'mautic.core.url.error.401', - array( - '%url%' => $request->getRequestUri() - ) + [ + '%url%' => $request->getRequestUri(), + ] ) ); } } /** - * Add a client change entry to the audit log + * Add a client change entry to the audit log. * * @param Events\ClientEvent $event */ @@ -107,34 +106,34 @@ public function onClientPostSave(Events\ClientEvent $event) { $client = $event->getClient(); if ($details = $event->getChanges()) { - $log = array( + $log = [ 'bundle' => 'api', 'object' => 'client', 'objectId' => $client->getId(), 'action' => ($event->isNew()) ? 'create' : 'update', 'details' => $details, - 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest() - ); + 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest(), + ]; $this->auditLogModel->writeToLog($log); } } /** - * Add a role delete entry to the audit log + * Add a role delete entry to the audit log. * * @param Events\ClientEvent $event */ public function onClientDelete(Events\ClientEvent $event) { $client = $event->getClient(); - $log = array( - 'bundle' => 'api', - 'object' => 'client', - 'objectId' => $client->deletedId, - 'action' => 'delete', - 'details' => array('name' => $client->getName()), - 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest() - ); + $log = [ + 'bundle' => 'api', + 'object' => 'client', + 'objectId' => $client->deletedId, + 'action' => 'delete', + 'details' => ['name' => $client->getName()], + 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest(), + ]; $this->auditLogModel->writeToLog($log); } } diff --git a/app/bundles/ApiBundle/EventListener/ConfigSubscriber.php b/app/bundles/ApiBundle/EventListener/ConfigSubscriber.php index 8fb6844224d..0f9b7d2888f 100644 --- a/app/bundles/ApiBundle/EventListener/ConfigSubscriber.php +++ b/app/bundles/ApiBundle/EventListener/ConfigSubscriber.php @@ -1,42 +1,41 @@ array('onConfigGenerate', 0) - ); + return [ + ConfigEvents::CONFIG_ON_GENERATE => ['onConfigGenerate', 0], + ]; } - public function onConfigGenerate (ConfigBuilderEvent $event) + public function onConfigGenerate(ConfigBuilderEvent $event) { - $event->addForm(array( + $event->addForm([ 'bundle' => 'ApiBundle', 'formAlias' => 'apiconfig', 'formTheme' => 'MauticApiBundle:FormTheme\Config', - 'parameters' => $event->getParametersFromConfig('MauticApiBundle') - )); + 'parameters' => $event->getParametersFromConfig('MauticApiBundle'), + ]); } } diff --git a/app/bundles/ApiBundle/EventListener/OAuth1/OAuthRequestListener.php b/app/bundles/ApiBundle/EventListener/OAuth1/OAuthRequestListener.php index 40c4a2938b9..9c31326d6ba 100644 --- a/app/bundles/ApiBundle/EventListener/OAuth1/OAuthRequestListener.php +++ b/app/bundles/ApiBundle/EventListener/OAuth1/OAuthRequestListener.php @@ -1,9 +1,10 @@ getUser($event)) { //check to see if user has api access - if (!$this->mauticSecurity->isGranted("api:access:full")) { - throw new AccessDeniedException($this->translator->trans('mautic.core.error.accessdenied', array(), 'flashes')); + if (!$this->mauticSecurity->isGranted('api:access:full')) { + throw new AccessDeniedException($this->translator->trans('mautic.core.error.accessdenied', [], 'flashes')); } $client = $event->getClient(); $event->setAuthorizedClient( @@ -68,8 +68,6 @@ public function onPreAuthorizationProcess(OAuthEvent $event) /** * @param OAuthEvent $event - * - * @return void */ public function onPostAuthorizationProcess(OAuthEvent $event) { diff --git a/app/bundles/ApiBundle/EventListener/SearchSubscriber.php b/app/bundles/ApiBundle/EventListener/SearchSubscriber.php index afe01ea3f86..b8eb62e37c4 100644 --- a/app/bundles/ApiBundle/EventListener/SearchSubscriber.php +++ b/app/bundles/ApiBundle/EventListener/SearchSubscriber.php @@ -1,23 +1,22 @@ array('onGlobalSearch', 0), - CoreEvents::BUILD_COMMAND_LIST => array('onBuildCommandList', 0) - ); + return [ + CoreEvents::GLOBAL_SEARCH => ['onGlobalSearch', 0], + CoreEvents::BUILD_COMMAND_LIST => ['onBuildCommandList', 0], + ]; } /** @@ -59,31 +58,31 @@ public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event) } $clients = $this->apiClientModel->getEntities( - array( + [ 'limit' => 5, - 'filter' => $str - )); + 'filter' => $str, + ]); if (count($clients) > 0) { - $clientResults = array(); - $canEdit = $this->security->isGranted('api:clients:edit'); + $clientResults = []; + $canEdit = $this->security->isGranted('api:clients:edit'); foreach ($clients as $client) { $clientResults[] = $this->templating->renderResponse( 'MauticApiBundle:SubscribedEvents\Search:global.html.php', - array( + [ 'client' => $client, - 'canEdit' => $canEdit - ) + 'canEdit' => $canEdit, + ] )->getContent(); } if (count($clients) > 5) { $clientResults[] = $this->templating->renderResponse( 'MauticApiBundle:SubscribedEvents\Search:global.html.php', - array( + [ 'showMore' => true, 'searchString' => $str, - 'remaining' => (count($clients) - 5) - ) + 'remaining' => (count($clients) - 5), + ] )->getContent(); } $clientResults['count'] = count($clients); @@ -97,7 +96,7 @@ public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event) */ public function onBuildCommandList(MauticEvents\CommandListEvent $event) { - $security = $this->security; + $security = $this->security; if ($security->isGranted('api:clients:view')) { $event->addCommands( 'mautic.api.client.header.index', @@ -105,4 +104,4 @@ public function onBuildCommandList(MauticEvents\CommandListEvent $event) ); } } -} \ No newline at end of file +} diff --git a/app/bundles/ApiBundle/Form/Type/ClientType.php b/app/bundles/ApiBundle/Form/Type/ClientType.php index 4a10e0b92d6..17e46d7efda 100644 --- a/app/bundles/ApiBundle/Form/Type/ClientType.php +++ b/app/bundles/ApiBundle/Form/Type/ClientType.php @@ -1,9 +1,10 @@ add( 'api_mode', 'choice', - array( - 'mapped' => false, - 'label' => 'mautic.api.client.form.auth_protocol', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array( + [ + 'mapped' => false, + 'label' => 'mautic.api.client.form.auth_protocol', + 'label_attr' => ['class' => 'control-label'], + 'attr' => [ 'class' => 'form-control', - 'onchange' => 'Mautic.refreshApiClientForm(\'' . $this->router->generate('mautic_client_action', array('objectAction' => 'new')) . '\', this)' - ), - 'choices' => array( + 'onchange' => 'Mautic.refreshApiClientForm(\''.$this->router->generate('mautic_client_action', ['objectAction' => 'new']).'\', this)', + ], + 'choices' => [ 'oauth1a' => 'OAuth 1.0a', - 'oauth2' => 'OAuth 2' - ), + 'oauth2' => 'OAuth 2', + ], 'required' => false, 'empty_value' => false, - 'data' => $this->apiMode - ) + 'data' => $this->apiMode, + ] ); } $builder->add( 'name', 'text', - array( + [ 'label' => 'mautic.core.name', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array('class' => 'form-control') - ) + 'label_attr' => ['class' => 'control-label'], + 'attr' => ['class' => 'form-control'], + ] ); if ($this->apiMode == 'oauth2') { @@ -106,14 +105,14 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->create( 'redirectUris', 'text', - array( + [ 'label' => 'mautic.api.client.redirecturis', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array( + 'label_attr' => ['class' => 'control-label'], + 'attr' => [ 'class' => 'form-control', 'tooltip' => 'mautic.api.client.form.help.requesturis', - ) - ) + ], + ] ) ->addViewTransformer($arrayStringTransformer) ); @@ -121,27 +120,27 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add( 'publicId', 'text', - array( + [ 'label' => 'mautic.api.client.form.clientid', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array('class' => 'form-control'), + 'label_attr' => ['class' => 'control-label'], + 'attr' => ['class' => 'form-control'], 'disabled' => true, 'required' => false, 'mapped' => false, - 'data' => $options['data']->getPublicId() - ) + 'data' => $options['data']->getPublicId(), + ] ); $builder->add( 'secret', 'text', - array( + [ 'label' => 'mautic.api.client.form.clientsecret', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array('class' => 'form-control'), + 'label_attr' => ['class' => 'control-label'], + 'attr' => ['class' => 'form-control'], 'disabled' => true, - 'required' => false - ) + 'required' => false, + ] ); $translator = $this->translator; @@ -155,10 +154,10 @@ function (FormEvent $event) use ($translator, $validator) { if ($form->has('redirectUris')) { foreach ($data->getRedirectUris() as $uri) { - $urlConstraint = new OAuthCallback(); + $urlConstraint = new OAuthCallback(); $urlConstraint->message = $translator->trans( 'mautic.api.client.redirecturl.invalid', - array('%url%' => $uri), + ['%url%' => $uri], 'validators' ); @@ -181,48 +180,48 @@ function (FormEvent $event) use ($translator, $validator) { $builder->create( 'callback', 'text', - array( + [ 'label' => 'mautic.api.client.form.callback', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array( + 'label_attr' => ['class' => 'control-label'], + 'attr' => [ 'class' => 'form-control', 'tooltip' => 'mautic.api.client.form.help.callback', - ), - 'required' => false - ) + ], + 'required' => false, + ] )->addModelTransformer(new Transformers\NullToEmptyTransformer()) ); $builder->add( 'consumerKey', 'text', - array( + [ 'label' => 'mautic.api.client.form.consumerkey', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array( + 'label_attr' => ['class' => 'control-label'], + 'attr' => [ 'class' => 'form-control', - 'onclick' => 'this.setSelectionRange(0, this.value.length);' - ), - 'read_only' => true, - 'required' => false, - 'mapped' => false, - 'data' => $options['data']->getConsumerKey() - ) + 'onclick' => 'this.setSelectionRange(0, this.value.length);', + ], + 'read_only' => true, + 'required' => false, + 'mapped' => false, + 'data' => $options['data']->getConsumerKey(), + ] ); $builder->add( 'consumerSecret', 'text', - array( + [ 'label' => 'mautic.api.client.form.consumersecret', - 'label_attr' => array('class' => 'control-label'), - 'attr' => array( + 'label_attr' => ['class' => 'control-label'], + 'attr' => [ 'class' => 'form-control', - 'onclick' => 'this.setSelectionRange(0, this.value.length);' - ), - 'read_only' => true, - 'required' => false - ) + 'onclick' => 'this.setSelectionRange(0, this.value.length);', + ], + 'read_only' => true, + 'required' => false, + ] ); $translator = $this->translator; @@ -235,9 +234,9 @@ function (FormEvent $event) use ($translator, $validator) { $data = $event->getData(); if ($form->has('callback')) { - $uri = $data->getCallback(); - $urlConstraint = new OAuthCallback(); - $urlConstraint->message = $translator->trans('mautic.api.client.redirecturl.invalid', array('%url%' => $uri), 'validators'); + $uri = $data->getCallback(); + $urlConstraint = new OAuthCallback(); + $urlConstraint->message = $translator->trans('mautic.api.client.redirecturl.invalid', ['%url%' => $uri], 'validators'); $errors = $validator->validateValue( $uri, @@ -256,8 +255,8 @@ function (FormEvent $event) use ($translator, $validator) { $builder->add('buttons', 'form_buttons'); - if (!empty($options["action"])) { - $builder->setAction($options["action"]); + if (!empty($options['action'])) { + $builder->setAction($options['action']); } } @@ -268,9 +267,9 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) { $dataClass = ($this->apiMode == 'oauth2') ? 'Mautic\ApiBundle\Entity\oAuth2\Client' : 'Mautic\ApiBundle\Entity\oAuth1\Consumer'; $resolver->setDefaults( - array( - 'data_class' => $dataClass - ) + [ + 'data_class' => $dataClass, + ] ); } @@ -279,6 +278,6 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) */ public function getName() { - return "client"; + return 'client'; } } diff --git a/app/bundles/ApiBundle/Form/Type/ConfigType.php b/app/bundles/ApiBundle/Form/Type/ConfigType.php index 8a01f75b62a..aa8e61e6925 100644 --- a/app/bundles/ApiBundle/Form/Type/ConfigType.php +++ b/app/bundles/ApiBundle/Form/Type/ConfigType.php @@ -1,23 +1,21 @@ add( 'api_enabled', 'yesno_button_group', - array( + [ 'label' => 'mautic.api.config.form.api.enabled', 'data' => (bool) $options['data']['api_enabled'], - 'attr' => array( - 'tooltip' => 'mautic.api.config.form.api.enabled.tooltip' - ) - ) + 'attr' => [ + 'tooltip' => 'mautic.api.config.form.api.enabled.tooltip', + ], + ] ); $builder->add( 'api_oauth2_access_token_lifetime', 'number', - array( - 'label' => 'mautic.api.config.form.api.oauth2_access_token_lifetime', - 'attr' => array( + [ + 'label' => 'mautic.api.config.form.api.oauth2_access_token_lifetime', + 'attr' => [ 'tooltip' => 'mautic.api.config.form.api.oauth2_access_token_lifetime.tooltip', 'class' => 'form-control', 'data-show-on' => '{"config_apiconfig_api_enabled_1":"checked"}', - ), - 'constraints' => array( + ], + 'constraints' => [ new NotBlank( - array( - 'message' => 'mautic.core.value.required' - ) - ) - ) - ) + [ + 'message' => 'mautic.core.value.required', + ] + ), + ], + ] ); $builder->add( 'api_oauth2_refresh_token_lifetime', 'number', - array( - 'label' => 'mautic.api.config.form.api.oauth2_refresh_token_lifetime', - 'attr' => array( + [ + 'label' => 'mautic.api.config.form.api.oauth2_refresh_token_lifetime', + 'attr' => [ 'tooltip' => 'mautic.api.config.form.api.oauth2_refresh_token_lifetime.tooltip', 'class' => 'form-control', 'data-show-on' => '{"config_apiconfig_api_enabled_1":"checked"}', - ), - 'constraints' => array( + ], + 'constraints' => [ new NotBlank( - array( - 'message' => 'mautic.core.value.required' - ) - ) - ) - ) + [ + 'message' => 'mautic.core.value.required', + ] + ), + ], + ] ); } @@ -87,4 +85,4 @@ public function getName() { return 'apiconfig'; } -} \ No newline at end of file +} diff --git a/app/bundles/ApiBundle/Form/Validator/Constraints/OAuthCallback.php b/app/bundles/ApiBundle/Form/Validator/Constraints/OAuthCallback.php index ae36a55a1e3..44b50b21e3d 100644 --- a/app/bundles/ApiBundle/Form/Validator/Constraints/OAuthCallback.php +++ b/app/bundles/ApiBundle/Form/Validator/Constraints/OAuthCallback.php @@ -1,9 +1,10 @@ addViolation(); } } -} \ No newline at end of file +} diff --git a/app/bundles/ApiBundle/MauticApiBundle.php b/app/bundles/ApiBundle/MauticApiBundle.php index 0fd96c5163b..9a9600b4504 100644 --- a/app/bundles/ApiBundle/MauticApiBundle.php +++ b/app/bundles/ApiBundle/MauticApiBundle.php @@ -1,9 +1,10 @@ $action) : array(); + $params = (!empty($action)) ? ['action' => $action] : []; + return $formFactory->create('client', $entity, $params); } @@ -117,7 +118,6 @@ public function getEntity($id = null) return parent::getEntity($id); } - /** * {@inheritdoc} * @@ -126,14 +126,14 @@ public function getEntity($id = null) protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null) { if (!$entity instanceof Client && !$entity instanceof Consumer) { - throw new MethodNotAllowedHttpException(array('Client', 'Consumer')); + throw new MethodNotAllowedHttpException(['Client', 'Consumer']); } switch ($action) { - case "post_save": + case 'post_save': $name = ApiEvents::CLIENT_POST_SAVE; break; - case "post_delete": + case 'post_delete': $name = ApiEvents::CLIENT_POST_DELETE; break; default: @@ -146,6 +146,7 @@ protected function dispatchEvent($action, &$entity, $isNew = false, Event $event $event->setEntityManager($this->em); } $this->dispatcher->dispatch($name, $event); + return $event; } @@ -164,13 +165,11 @@ public function getUserClients(User $user) /** * @param $entity - * - * @return void */ public function revokeAccess($entity) { if (!$entity instanceof Client && !$entity instanceof Consumer) { - throw new MethodNotAllowedHttpException(array('Client', 'Consumer')); + throw new MethodNotAllowedHttpException(['Client', 'Consumer']); } //remove the user from the client diff --git a/app/bundles/ApiBundle/Provider/NonceProvider.php b/app/bundles/ApiBundle/Provider/NonceProvider.php index e5032adc877..ab816fc8a06 100644 --- a/app/bundles/ApiBundle/Provider/NonceProvider.php +++ b/app/bundles/ApiBundle/Provider/NonceProvider.php @@ -1,9 +1,10 @@ = $lastFifteen) { //make sure nonce has not been used before - $usedNonces = $this->repo->findBy(array('nonce' => $nonce)); + $usedNonces = $this->repo->findBy(['nonce' => $nonce]); if (count($usedNonces) === 0) { $notUsed = true; @@ -82,11 +82,11 @@ public function checkNonceAndTimestampUnicity($nonce, $timestamp, ConsumerInterf } /** - * @param $nonce - * @param $timestamp - * @param \Bazinga\OAuthServerBundle\Model\ConsumerInterface $consumer + * @param $nonce + * @param $timestamp + * @param \Bazinga\OAuthServerBundle\Model\ConsumerInterface $consumer * - * @return boolean + * @return bool */ public function registerNonceAndTimestamp($nonce, $timestamp, ConsumerInterface $consumer) { diff --git a/app/bundles/ApiBundle/Security/OAuth1/Authentication/Provider/OAuthProvider.php b/app/bundles/ApiBundle/Security/OAuth1/Authentication/Provider/OAuthProvider.php index 27d817da42b..44e2abb1e85 100644 --- a/app/bundles/ApiBundle/Security/OAuth1/Authentication/Provider/OAuthProvider.php +++ b/app/bundles/ApiBundle/Security/OAuth1/Authentication/Provider/OAuthProvider.php @@ -1,9 +1,10 @@ permissions = array( - 'access' => array( - 'full' => 1024 - ) - ); + $this->permissions = [ + 'access' => [ + 'full' => 1024, + ], + ]; $this->addStandardPermissions('clients', false); } @@ -47,15 +46,15 @@ public function getName() */ public function buildForm(FormBuilderInterface &$builder, array $options, array $data) { - $builder->add('api:access', 'permissionlist', array( - 'choices' => array( - 'full' => 'mautic.api.permissions.granted', - ), - 'label' => 'mautic.api.permissions.apiaccess', - 'data' => (!empty($data['access']) ? $data['access'] : array()), - 'bundle' => 'api', - 'level' => 'access' - )); + $builder->add('api:access', 'permissionlist', [ + 'choices' => [ + 'full' => 'mautic.api.permissions.granted', + ], + 'label' => 'mautic.api.permissions.apiaccess', + 'data' => (!empty($data['access']) ? $data['access'] : []), + 'bundle' => 'api', + 'level' => 'access', + ]); $this->addStandardFormFields('api', 'clients', $builder, $data, false); } @@ -87,7 +86,7 @@ public function isEnabled() protected function getSynonym($name, $level) { if ($name == 'access' && $level == 'granted') { - return array($name, 'full'); + return [$name, 'full']; } return parent::getSynonym($name, $level); diff --git a/app/bundles/ApiBundle/Serializer/Driver/AnnotationDriver.php b/app/bundles/ApiBundle/Serializer/Driver/AnnotationDriver.php index a8616945960..db8e22012cf 100644 --- a/app/bundles/ApiBundle/Serializer/Driver/AnnotationDriver.php +++ b/app/bundles/ApiBundle/Serializer/Driver/AnnotationDriver.php @@ -1,9 +1,10 @@ hasMethod('loadApiMetadata')) { - $this->metadata = new ClassMetadata($class->getName()); + $this->metadata = new ClassMetadata($class->getName()); - $this->properties = array(); + $this->properties = []; $this->defaultVersion = '1.0'; $this->groupPrefix = ''; @@ -66,7 +67,7 @@ protected function loadMetadataFromFile(\ReflectionClass $class, $file) } /** - * Set the root (base key) + * Set the root (base key). * * @param $root * @@ -80,7 +81,7 @@ public function setRoot($root) } /** - * Set prefix for the List and Details groups + * Set prefix for the List and Details groups. * * @param $name * @@ -94,7 +95,7 @@ public function setGroupPrefix($name) } /** - * Set the default version for the properties if different than 1.0 + * Set the default version for the properties if different than 1.0. * * @param $version * @@ -108,7 +109,7 @@ public function setDefaultVersion($version) } /** - * Create a new property + * Create a new property. * * @param $name * @@ -123,7 +124,7 @@ public function createProperty($name) } /** - * Add property and set default version and Details group + * Add property and set default version and Details group. * * @param $name * @@ -140,14 +141,14 @@ public function addProperty($name) if ($this->groupPrefix !== null) { // Auto add to the Details group - $this->addGroup($this->groupPrefix . 'Details'); + $this->addGroup($this->groupPrefix.'Details'); } return $this; } /** - * Create properties + * Create properties. * * @param array $properties * @param bool|false $addToListGroup @@ -168,7 +169,7 @@ public function addProperties(array $properties, $addToListGroup = false) } /** - * Create properties and add to the List group + * Create properties and add to the List group. * * @param array $properties * @@ -233,17 +234,17 @@ public function setSerializedName($name, $property = null) } /** - * Set the groups a property belongs to + * Set the groups a property belongs to. * - * @param $groups - * @param $property + * @param $groups + * @param $property * * @return $this */ public function setGroups($groups, $property = null) { if (!is_array($groups)) { - $groups = array($groups); + $groups = [$groups]; } if ($property === null) { @@ -256,7 +257,7 @@ public function setGroups($groups, $property = null) } /** - * Add a group the property belongs to + * Add a group the property belongs to. * * @param $group * @param null $property @@ -275,7 +276,7 @@ public function addGroup($group, $property = null) } /** - * Add property to the List group + * Add property to the List group. * * @return $this */ @@ -288,7 +289,7 @@ public function inListGroup() } /** - * Set max depth for the property if an association + * Set max depth for the property if an association. * * @param $depth * @param null $property @@ -307,7 +308,7 @@ public function setMaxDepth($depth, $property = null) } /** - * Push the properties into ClassMetadata + * Push the properties into ClassMetadata. */ public function build() { @@ -316,6 +317,6 @@ public function build() } $this->currentPropertyName = null; - $this->properties = array(); + $this->properties = []; } -} \ No newline at end of file +} diff --git a/app/bundles/ApiBundle/Serializer/Exclusion/PublishDetailsExclusionStrategy.php b/app/bundles/ApiBundle/Serializer/Exclusion/PublishDetailsExclusionStrategy.php index 4ec4a0f9b28..9bbc4151df1 100644 --- a/app/bundles/ApiBundle/Serializer/Exclusion/PublishDetailsExclusionStrategy.php +++ b/app/bundles/ApiBundle/Serializer/Exclusion/PublishDetailsExclusionStrategy.php @@ -1,47 +1,47 @@ fields = array( + $this->fields = [ 'isPublished', 'dateAdded', 'createdBy', 'dateModified', 'modifiedBy', 'checkedOut', - 'checkedOutBy' - ); + 'checkedOutBy', + ]; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function shouldSkipClass(ClassMetadata $metadata, Context $navigatorContext) { @@ -49,7 +49,7 @@ public function shouldSkipClass(ClassMetadata $metadata, Context $navigatorConte } /** - * {@inheritDoc} + * {@inheritdoc} */ public function shouldSkipProperty(PropertyMetadata $property, Context $navigatorContext) { diff --git a/app/bundles/ApiBundle/Views/Authorize/oAuth1/authorize.html.php b/app/bundles/ApiBundle/Views/Authorize/oAuth1/authorize.html.php index 51e4196edb4..c1ff0fbb64d 100644 --- a/app/bundles/ApiBundle/Views/Authorize/oAuth1/authorize.html.php +++ b/app/bundles/ApiBundle/Views/Authorize/oAuth1/authorize.html.php @@ -1,16 +1,16 @@ extend('MauticUserBundle:Security:base.html.php'); $view['slots']->set('header', $view['translator']->trans('mautic.api.oauth.header')); $name = $consumer->getName(); -$msg = (!empty($name)) ? $view['translator']->trans('mautic.api.oauth.clientwithname', array('%name%' => $name)) : +$msg = (!empty($name)) ? $view['translator']->trans('mautic.api.oauth.clientwithname', ['%name%' => $name]) : $view['translator']->trans('mautic.api.oauth.clientnoname'); ?>
diff --git a/app/bundles/ApiBundle/Views/Authorize/oAuth2/authorize.html.php b/app/bundles/ApiBundle/Views/Authorize/oAuth2/authorize.html.php index 62dce422659..a810edf46d2 100644 --- a/app/bundles/ApiBundle/Views/Authorize/oAuth2/authorize.html.php +++ b/app/bundles/ApiBundle/Views/Authorize/oAuth2/authorize.html.php @@ -1,16 +1,16 @@ extend('MauticUserBundle:Security:base.html.php'); $view['slots']->set('header', $view['translator']->trans('mautic.api.oauth.header')); $name = $client->getName(); -$msg = (!empty($name)) ? $view['translator']->trans('mautic.api.oauth.clientwithname', array('%name%' => $name)) : +$msg = (!empty($name)) ? $view['translator']->trans('mautic.api.oauth.clientwithname', ['%name%' => $name]) : $view['translator']->trans('mautic.api.oauth.clientnoname'); ?> diff --git a/app/bundles/ApiBundle/Views/Client/authorized.html.php b/app/bundles/ApiBundle/Views/Client/authorized.html.php index 7a2aa2b838d..f97a858fa30 100644 --- a/app/bundles/ApiBundle/Views/Client/authorized.html.php +++ b/app/bundles/ApiBundle/Views/Client/authorized.html.php @@ -1,9 +1,10 @@ @@ -19,14 +20,14 @@trans('mautic.install.sentence.major.problems', array('%majors%' => count($majors))); ?>
+trans('mautic.install.sentence.major.problems', ['%majors%' => count($majors)]); ?>
/
trans('mautic.user.role.permission.isadmin.message'); ?>
diff --git a/app/bundles/UserBundle/Views/Role/index.html.php b/app/bundles/UserBundle/Views/Role/index.html.php index 1fe2891ad87..a910c89ab55 100644 --- a/app/bundles/UserBundle/Views/Role/index.html.php +++ b/app/bundles/UserBundle/Views/Role/index.html.php @@ -1,34 +1,34 @@ extend('MauticCoreBundle:Default:content.html.php'); $view['slots']->set('mauticContent', 'role'); $view['slots']->set('headerTitle', $view['translator']->trans('mautic.user.roles')); $view['slots']->set('actions', $view->render('MauticCoreBundle:Helper:page_actions.html.php', [ 'templateButtons' => [ - 'new' => $permissions['create'] + 'new' => $permissions['create'], ], 'routeBase' => 'role', - 'langVar' => 'user.role' + 'langVar' => 'user.role', ])); ?> render('MauticCoreBundle:Helper:list_toolbar.html.php', [ - 'searchValue' => $searchValue, - 'searchHelp' => 'mautic.user.role.help.searchcommands', - 'action' => $currentRoute, - 'langVar' => 'user.role', - 'routeBase' => 'role', + 'searchValue' => $searchValue, + 'searchHelp' => 'mautic.user.role.help.searchcommands', + 'action' => $currentRoute, + 'langVar' => 'user.role', + 'routeBase' => 'role', 'templateButtons' => [ - 'delete' => $permissions['delete'] - ] + 'delete' => $permissions['delete'], + ], ]); ?>trans('mautic.integration.sso.' . $sso->getName()); ?>
+trans('mautic.integration.sso.'.$sso->getName()); ?>