Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
digitalascetic/google-api-client / EventListener / GoogleApiUserEventListener.php
Size: Mime:
<?php
/**
 * Created by PhpStorm.
 * User: eduarddezacastellano
 * Date: 02/10/2018
 * Time: 14:21
 */

namespace DigitalAscetic\GoogleApiClientBundle\EventListener;

use DigitalAscetic\GoogleApiClientBundle\Event\GoogleApiUserDisconnectEvent;
use DigitalAscetic\GoogleApiClientBundle\Service\IGoogleApiService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class GoogleApiUserEventListener implements EventSubscriberInterface
{

    const SERVICE_NAME = 'ascetic_google_api_client.listener.api';

    /** @var IGoogleApiService[] */
    private $googleApiServices;

    /**
     * GoogleApiUserEventListener constructor.
     * @param $configGoogleApiServices
     */
    public function __construct($configGoogleApiServices)
    {
        $this->googleApiServices = $configGoogleApiServices;
    }

    /**
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return array(
            GoogleApiUserDisconnectEvent::EVENT_NAME => 'googleApiUserDisconnect'
        );
    }

    public function googleApiUserDisconnect(GoogleApiUserDisconnectEvent $event)
    {
        /** @var IGoogleApiService $googleApiService */
        foreach ($this->googleApiServices as $googleApiService) {
            $googleApiService->disconnect($event->getGoogleApiUser(), $event->getHost());
        }
    }
}