Skip to content

Commit 0a85b9f

Browse files
authored
Merge pull request #447 from cultuurnet/WID-591-hide-social-buttons
WID-591 hide social functionality
2 parents 461551c + 75bdcec commit 0a85b9f

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

app/ApplicationBase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public function __construct()
7777
// Enable debug if requested.
7878
$this['debug'] = $this['config']['debug'] === true;
7979

80+
$this['disable_social_sharing'] = $this['config']['features']['disable_social_sharing'];
81+
8082
/**
8183
* PHP error reporting
8284
*/

app/ShareProxy/ShareProxyControllerProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public function connect(Application $app)
2222
$app['widget_page_deserializer'],
2323
$app['twig'],
2424
$app['request_stack'],
25-
$app['debug']
25+
$app['debug'],
26+
$app['disable_social_sharing']
2627
);
2728
};
2829

app/Widget/WidgetServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public function register(Container $pimple)
8484
),
8585
$pimple['translator'],
8686
$pimple['curatoren_api'],
87-
$pimple['uitpas_api']
87+
$pimple['uitpas_api'],
88+
$pimple['config']['features']['disable_social_sharing']
8889
);
8990
};
9091

src/ShareProxy/Controller/ShareProxyController.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use CultuurNet\SearchV3\SearchClient;
88
use CultuurNet\SearchV3\ValueObjects\Offer;
99
use Doctrine\ODM\MongoDB\DocumentRepository;
10+
use Symfony\Component\HttpFoundation\Response;
1011
use Symfony\Component\HttpFoundation\RequestStack;
1112

1213
/**
@@ -50,14 +51,20 @@ class ShareProxyController
5051
*/
5152
protected $debugMode;
5253

54+
/**
55+
* @var bool
56+
*/
57+
protected $disableSocialSharing;
58+
5359
public function __construct(
5460
RendererInterface $renderer,
5561
DocumentRepository $widgetRepository,
5662
SearchClient $searchClient,
5763
WidgetPageEntityDeserializer $widgetPageEntityDeserializer,
5864
\Twig_Environment $twig,
5965
RequestStack $requestStack,
60-
bool $debugMode
66+
bool $debugMode,
67+
bool $disableSocialSharing
6168
) {
6269
$this->renderer = $renderer;
6370
$this->widgetRepository = $widgetRepository;
@@ -66,16 +73,20 @@ public function __construct(
6673
$this->twig = $twig;
6774
$this->request = $requestStack->getCurrentRequest();
6875
$this->debugMode = $debugMode;
76+
$this->disableSocialSharing = $disableSocialSharing;
6977
}
7078

7179
/**
7280
* Social share proxy page.
7381
*
7482
* @param Offer $offer
75-
* @return string
83+
* @return mixed
7684
*/
7785
public function socialShareProxy($offer)
7886
{
87+
if ($this->disableSocialSharing) {
88+
return new Response('', 404);
89+
}
7990
$langcode = 'nl';
8091
// Get origin url.
8192
$originUrl = ($this->request->query->get('origin') ? $this->request->query->get('origin') : '');

src/Widget/Twig/TwigPreprocessor.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ class TwigPreprocessor
8181
*/
8282
private $fallbackImages;
8383

84+
/**
85+
* bool
86+
*/
87+
private $disableSocialSharing;
88+
8489
/**
8590
* TwigPreprocessor constructor.
8691
* @param \Twig_Environment $twig
@@ -95,7 +100,8 @@ public function __construct(
95100
TranslateTerm $translateTerm,
96101
TranslatorInterface $translator,
97102
CuratorenClient $curatorenClient,
98-
UitpasClient $uitpasClient
103+
UitpasClient $uitpasClient,
104+
bool $disableSocialSharing
99105
) {
100106
$this->twig = $twig;
101107
$this->request = $requestStack->getCurrentRequest();
@@ -106,6 +112,7 @@ public function __construct(
106112
$this->translator = $translator;
107113
$this->curatorenClient = $curatorenClient;
108114
$this->uitpasClient = $uitpasClient;
115+
$this->disableSocialSharing = $disableSocialSharing;
109116
$this->fallbackImages = [];
110117
}
111118

@@ -341,6 +348,7 @@ public function preprocessEventDetail(Event $event, string $langcode, array $set
341348
$variables['language_switcher'][$langcodeItem] = '<a href="' . $url->__toString() . '">' . strtoupper($langcodeItem) . '</a>';
342349
}
343350

351+
$variables['show_share_links'] = $this->disableSocialSharing ? false : $settings['share_buttons'];
344352
// Share links
345353
$shareUrl = Url::factory($this->socialHost . '/event/' . $event->getCdbid());
346354
$shareQuery = $shareUrl->getQuery();
@@ -350,7 +358,7 @@ public function preprocessEventDetail(Event $event, string $langcode, array $set
350358

351359
$variables['share_links'] = [
352360
'facebook' => 'https://www.facebook.com/sharer/sharer.php?u=' . urlencode($shareUrl->__toString()),
353-
'twitter' => 'https://twitter.com/intent/tweet?text=' . urlencode($shareUrl->__toString()),
361+
'twitter' => 'https://twitter.com/intent/tweet?text=' . urlencode($shareUrl->__toString()),
354362
];
355363
}
356364

views/widgets/search-results-widget/detail-page.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293

294294

295295

296-
{% if settings.share_buttons and event.share_links %}
296+
{% if event.show_share_links and event.share_links %}
297297
<dt>
298298
<em class="cnw_searchresult-detail-label">{{ 'event_detail_share'| transTo(preferredLanguage) }}</em>
299299
<i class="cnw-fa cnw-fa-share-alt"></i>

0 commit comments

Comments
 (0)