diff --git a/.gitignore b/.gitignore index 34a23d9..1a4b4e1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.idea/ composer.lock /components/ +.php_cs.cache diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..e58d5a2 --- /dev/null +++ b/.php_cs @@ -0,0 +1,25 @@ +setUsingLinter(false) + ->setUsingCache(true) + ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) + ->fixers([ + 'concat_with_spaces', + '-concat_without_spaces', + '-empty_return', + '-phpdoc_params', + '-phpdoc_separation', + '-phpdoc_to_comment', + '-spaces_cast', + '-blankline_after_open_tag', + '-single_blank_line_before_namespace', + ]) + ->finder( + Symfony\CS\Finder\DefaultFinder::create() + ->in(__DIR__) + ->exclude([ + 'vendor', + ]) + ) +; diff --git a/Client/RecommendationClient.php b/Client/RecommendationClient.php index 90a8330..7cd1444 100644 --- a/Client/RecommendationClient.php +++ b/Client/RecommendationClient.php @@ -1,6 +1,6 @@ notify(array(array( 'action' => 'update', 'uri' => $this->getContentUri($contentId), - 'contentTypeId' => $this->getContentTypeId($contentId) + 'contentTypeId' => $this->getContentTypeId($contentId), ))); } catch (RequestException $e) { if (isset($this->logger)) { - $this->logger->error("YooChoose Post notification error: ".$e->getMessage()); + $this->logger->error('YooChoose Post notification error: ' . $e->getMessage()); } } } @@ -127,11 +127,11 @@ public function deleteContent($contentId) $this->notify(array(array( 'action' => 'delete', 'uri' => $this->getContentUri($contentId), - 'contentTypeId' => $this->getContentTypeId($contentId) + 'contentTypeId' => $this->getContentTypeId($contentId), ))); } catch (RequestException $e) { if (isset($this->logger)) { - $this->logger->error("YooChoose Post notification error: ".$e->getMessage()); + $this->logger->error('YooChoose Post notification error: ' . $e->getMessage()); } } } @@ -155,7 +155,7 @@ private function getContentIdentifier($contentId) } /** - * Gets ContentType ID based on $contentId + * Gets ContentType ID based on $contentId. * * @param mixed $contentId * @@ -174,7 +174,7 @@ protected function getContentTypeId($contentId) } /** - * Generates the REST URI of content $contentId + * Generates the REST URI of content $contentId. * * @param $contentId * @@ -205,13 +205,13 @@ protected function getContentUri($contentId) protected function notify(array $events) { foreach ($events as $event) { - if (array_keys($event) != array( 'action', 'uri', 'contentTypeId' )) { + if (array_keys($event) != array('action', 'uri', 'contentTypeId')) { throw new InvalidArgumentException('Invalid action keys'); } } if (isset($this->logger)) { - $this->logger->debug("POST notification to YooChoose:".json_encode($events, true)); + $this->logger->debug('POST notification to YooChoose:' . json_encode($events, true)); } $response = $this->guzzle->post( @@ -219,17 +219,17 @@ protected function notify(array $events) array( 'json' => array( 'transaction' => null, - 'events' => $events + 'events' => $events, ), 'auth' => array( $this->options['customer-id'], - $this->options['license-key'] - ) + $this->options['license-key'], + ), ) ); if (isset($this->logger)) { - $this->logger->debug("Got ".$response->getStatusCode()." from YooChoose notification POST"); + $this->logger->debug('Got ' . $response->getStatusCode() . ' from YooChoose notification POST'); } } @@ -238,7 +238,7 @@ protected function notify(array $events) */ protected function configureOptions(OptionsResolver $resolver) { - $options = array( 'customer-id', 'license-key', 'api-endpoint', 'server-uri' ); + $options = array('customer-id', 'license-key', 'api-endpoint', 'server-uri'); // Could use setDefined() with symfony ~2.6 $resolver->setOptional($options); $resolver->setDefaults( @@ -246,13 +246,13 @@ protected function configureOptions(OptionsResolver $resolver) 'customer-id' => null, 'license-key' => null, 'server-uri' => null, - 'api-endpoint' => null + 'api-endpoint' => null, ) ); } /** - * Returns the yoochoose notification endpoint + * Returns the yoochoose notification endpoint. * * @return string */ diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e6887ac..e71c9d2 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,13 +17,13 @@ public function getConfigTreeBuilder() ->arrayNode('yoochoose') ->children() ->scalarNode('customer_id') - ->info("YooChoose customer ID") - ->example("12345") + ->info('YooChoose customer ID') + ->example('12345') ->isRequired() ->end() ->scalarNode('license_key') - ->info("YooChoose license key") - ->example("1234-5678-9012-3456-7890") + ->info('YooChoose license key') + ->example('1234-5678-9012-3456-7890') ->isRequired() ->end() ->end() @@ -39,8 +39,8 @@ public function getConfigTreeBuilder() ->end() ->end() ->scalarNode('server_uri') - ->info("HTTP base URI of the eZ Publish server") - ->example("http://site.com") + ->info('HTTP base URI of the eZ Publish server') + ->example('http://site.com') ->isRequired() ->end(); diff --git a/DependencyInjection/ConfigurationMapper.php b/DependencyInjection/ConfigurationMapper.php index b740d26..3fc9331 100644 --- a/DependencyInjection/ConfigurationMapper.php +++ b/DependencyInjection/ConfigurationMapper.php @@ -6,7 +6,6 @@ * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// */ - namespace EzSystems\RecommendationBundle\DependencyInjection; use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; diff --git a/DependencyInjection/EzSystemsRecommendationExtension.php b/DependencyInjection/EzSystemsRecommendationExtension.php index 9278dc7..93477ed 100644 --- a/DependencyInjection/EzSystemsRecommendationExtension.php +++ b/DependencyInjection/EzSystemsRecommendationExtension.php @@ -7,10 +7,9 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; -use EzSystems\RecommendationBundle\DependencyInjection; /** - * This is the class that loads and manages your bundle configuration + * This is the class that loads and manages your bundle configuration. * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} */ @@ -21,7 +20,7 @@ public function load(array $configs, ContainerBuilder $container) $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); $loader->load('slots.yml'); $loader->load('default_settings.yml'); diff --git a/EventListener/Login.php b/EventListener/Login.php index 995499d..6cc1acf 100644 --- a/EventListener/Login.php +++ b/EventListener/Login.php @@ -1,7 +1,7 @@ authorizationChecker = $authorizationChecker; $this->session = $session; $this->guzzleClient = $guzzleClient; @@ -69,7 +68,7 @@ public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY') | // user has just logged in $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { // user has logged in using remember_me cookie - $notificationUri = sprintf($this->getNotificationEndpoint().'%s/%s/%s', + $notificationUri = sprintf($this->getNotificationEndpoint() . '%s/%s/%s', 'login', $this->session->get('yc-session-id'), $event->getAuthenticationToken()->getUser()->getAPIUser()->id diff --git a/EventListener/SessionBackup.php b/EventListener/SessionBackup.php index 16bd514..a801c0a 100644 --- a/EventListener/SessionBackup.php +++ b/EventListener/SessionBackup.php @@ -1,7 +1,7 @@ array( array( 'action' => $action, - 'uri' => 'http://example.com/api/ezp/v2/content/objects/'.$contentId, + 'uri' => 'http://example.com/api/ezp/v2/content/objects/' . $contentId, ), ), ), @@ -62,7 +60,7 @@ protected function getNotificationBody($action, $contentId) } /** - * Returns the expected API endpoint for notifications + * Returns the expected API endpoint for notifications. * @return string */ protected function getExpectedEndpoint() diff --git a/Twig/RecommendationTwigExtension.php b/Twig/RecommendationTwigExtension.php index 0539ce1..f9650be 100644 --- a/Twig/RecommendationTwigExtension.php +++ b/Twig/RecommendationTwigExtension.php @@ -1,7 +1,7 @@ array('html'), - 'needs_environment' => true + 'needs_environment' => true, )), new Twig_SimpleFunction('yc_track_user', array($this, 'trackUser'), array( 'is_safe' => array('html'), - 'needs_environment' => true - )) + 'needs_environment' => true, + )), ); } @@ -149,8 +149,7 @@ public function getFunctions() */ public function trackUser(Twig_Environment $twigEnvironment, $contentId) { - if (!in_array($this->getContentIdentifier($contentId), $this->options['includedContentTypes'])) - { + if (!in_array($this->getContentIdentifier($contentId), $this->options['includedContentTypes'])) { return ''; } @@ -163,7 +162,7 @@ public function trackUser(Twig_Environment $twigEnvironment, $contentId) 'userId' => $this->getCurrentUserId(), 'customerId' => $this->options['customerId'], 'consumeTimeout' => ($this->options['consumeTimeout'] * 1000), - 'trackingScriptUrl' => $this->options['trackingScriptUrl'] + 'trackingScriptUrl' => $this->options['trackingScriptUrl'], ) ); } @@ -241,7 +240,7 @@ public function showRecommendations( 'feedbackUrl' => $this->getFeedbackUrl($this->getContentTypeId($contentType)), 'contentType' => $this->getContentTypeId($this->getContentIdentifier($contentId)), 'outputTypeId' => $this->getContentTypeId($contentType), - 'categoryPath' => $this->getLocationPathString($contentId) + 'categoryPath' => $this->getLocationPathString($contentId), ) ); } diff --git a/eZ/Publish/LegacySearch/ConfigurationMapper.php b/eZ/Publish/LegacySearch/ConfigurationMapper.php index aed0827..40b5a76 100644 --- a/eZ/Publish/LegacySearch/ConfigurationMapper.php +++ b/eZ/Publish/LegacySearch/ConfigurationMapper.php @@ -1,6 +1,6 @@ array( "onBuildKernel", 0 ), + LegacyEvents::POST_BUILD_LEGACY_KERNEL => array('onBuildKernel', 0), ); } public function onBuildKernel(PostBuildKernelEvent $event) { - $GLOBALS["eZSearchPlugin_" . $this->siteaccess->name] = $this->recommendationLegacySearch; + $GLOBALS['eZSearchPlugin_' . $this->siteaccess->name] = $this->recommendationLegacySearch; } } diff --git a/eZ/Publish/LegacySearch/LegacySearchFactory.php b/eZ/Publish/LegacySearch/LegacySearchFactory.php index ada6bd7..5d6f8bc 100644 --- a/eZ/Publish/LegacySearch/LegacySearchFactory.php +++ b/eZ/Publish/LegacySearch/LegacySearchFactory.php @@ -1,15 +1,12 @@ legacySearchEngine->commit(); } - public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved = false ) + public function addNodeAssignment($mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved = false) { - $this->recommendationClient->updateContent( $objectID ); - if ( method_exists( $this->legacySearchEngine, 'addNodeAssignment' ) ) - { - $this->legacySearchEngine->addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved ); + $this->recommendationClient->updateContent($objectID); + if (method_exists($this->legacySearchEngine, 'addNodeAssignment')) { + $this->legacySearchEngine->addNodeAssignment($mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved); } } } diff --git a/eZ/Publish/Slot/Base.php b/eZ/Publish/Slot/Base.php index b0ce866..3d9e022 100644 --- a/eZ/Publish/Slot/Base.php +++ b/eZ/Publish/Slot/Base.php @@ -6,7 +6,6 @@ * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// */ - namespace EzSystems\RecommendationBundle\eZ\Publish\Slot; use eZ\Publish\Core\SignalSlot\Slot as BaseSlot; diff --git a/eZ/Publish/Slot/CopyContent.php b/eZ/Publish/Slot/CopyContent.php index a1cf8b7..81e46f7 100644 --- a/eZ/Publish/Slot/CopyContent.php +++ b/eZ/Publish/Slot/CopyContent.php @@ -6,7 +6,6 @@ * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// */ - namespace EzSystems\RecommendationBundle\eZ\Publish\Slot; use eZ\Publish\Core\SignalSlot\Signal; @@ -14,7 +13,7 @@ class CopyContent extends Base { /** - * Receive the given $signal and react on it + * Receive the given $signal and react on it. * * @param \eZ\Publish\Core\SignalSlot\Signal $signal */ diff --git a/eZ/Publish/Slot/CopySubtree.php b/eZ/Publish/Slot/CopySubtree.php index f79c623..bc9f3f8 100644 --- a/eZ/Publish/Slot/CopySubtree.php +++ b/eZ/Publish/Slot/CopySubtree.php @@ -6,7 +6,6 @@ * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// */ - namespace EzSystems\RecommendationBundle\eZ\Publish\Slot; use eZ\Publish\Core\SignalSlot\Signal; diff --git a/eZ/Publish/Slot/CreateLocation.php b/eZ/Publish/Slot/CreateLocation.php index 2d2f213..0e3f971 100644 --- a/eZ/Publish/Slot/CreateLocation.php +++ b/eZ/Publish/Slot/CreateLocation.php @@ -6,7 +6,6 @@ * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// */ - namespace EzSystems\RecommendationBundle\eZ\Publish\Slot; use eZ\Publish\Core\SignalSlot\Signal; @@ -17,7 +16,7 @@ class CreateLocation extends Base { /** - * Receive the given $signal and react on it + * Receive the given $signal and react on it. * * @param \eZ\Publish\Core\SignalSlot\Signal $signal */ diff --git a/eZ/Publish/Slot/DeleteContent.php b/eZ/Publish/Slot/DeleteContent.php index d1c8430..9a03802 100644 --- a/eZ/Publish/Slot/DeleteContent.php +++ b/eZ/Publish/Slot/DeleteContent.php @@ -6,7 +6,6 @@ * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// */ - namespace EzSystems\RecommendationBundle\eZ\Publish\Slot; use eZ\Publish\Core\SignalSlot\Signal; diff --git a/eZ/Publish/Slot/DeleteLocation.php b/eZ/Publish/Slot/DeleteLocation.php index 92b605b..7fa8f35 100644 --- a/eZ/Publish/Slot/DeleteLocation.php +++ b/eZ/Publish/Slot/DeleteLocation.php @@ -1,12 +1,11 @@