SocialApiController.php in Social API 3.x
File
src/Controller/SocialApiController.php
View source
<?php
namespace Drupal\social_api\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\social_api\Plugin\NetworkManager;
class SocialApiController extends ControllerBase {
private $networkManager;
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.network.manager'));
}
public function __construct(NetworkManager $networkManager) {
$this->networkManager = $networkManager;
}
public function integrations($type) {
$networks = $this->networkManager
->getDefinitions();
$header = [
$this
->t('Module'),
$this
->t('Social Network'),
];
$data = [];
foreach ($networks as $network) {
if ($network['type'] == $type) {
$data[] = [
$network['id'],
$network['social_network'],
];
}
}
return [
'#theme' => 'table',
'#header' => $header,
'#rows' => $data,
'#empty' => $this
->t('There are no social integrations enabled.'),
];
}
}