public function listen()
    {
        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
            throw new InvalidRequestException('Expected a POST request.');
        }

        $remoteAddress = $this->getRemoteAddress();
        if (!$this->isValidRemoteAddress($remoteAddress)) {
            throw new InvalidRequestException('Invalid remote address.');
        }

        if (empty($_POST[$this->parameter])) {
            throw new InvalidRequestException('Expected the parameter ' . $this->parameter);
        }

        $payload = new Payload($_POST['payload']);
        $configuration = $this->getConfiguration($payload->getRepository());
        if (!$configuration) {
            throw new InvalidRequestException('Invalid repository: ' . $payload->getRepository());
        }

        if ($configuration->getDriver() != 'git') {
            throw new InvalidRequestException('Project is not a git repository but ' . $configuration->getDriver());
        }

        $driverConfig = new DriverConfig();
        $driverConfig->setDirectory($configuration->getSource());
        $driverConfig->setBranch($payload->getBranch());
        $driverConfig->setRepository($configuration->getRepository());

        $driver = new GitDriver();
        $driver->install($driverConfig);

        $generator = $this->configureGenerator($configuration, $payload);
        $generator->generate();
    }
public function listen()
    {
        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
            throw new InvalidRequestException('Expected a POST request.');
        }

        $remoteAddress = $this->getRemoteAddress();
        if (!$this->isValidRemoteAddress($remoteAddress)) {
            throw new InvalidRequestException('Invalid remote address.');
        }

        if (empty($_POST[$this->parameter])) {
            throw new InvalidRequestException('Expected the parameter ' . $this->parameter);
        }

        $payload = new Payload($_POST['payload']);
        $configuration = $this->getConfiguration($payload->getRepository());
        if (!$configuration) {
            throw new InvalidRequestException('Invalid repository: ' . $payload->getRepository());
        }

        if ($configuration->getDriver() != 'git') {
            throw new InvalidRequestException('Project is not a git repository but ' . $configuration->getDriver());
        }

        $driverConfig = new DriverConfig();
        $driverConfig->setDirectory($configuration->getSource());
        $driverConfig->setBranch($payload->getBranch());
        $driverConfig->setRepository($configuration->getRepository());

        $driver = new GitDriver();
        $driver->install($driverConfig);

        $generator = $this->configureGenerator($configuration, $payload);
        $generator->generate();
    }
public function listen ( ) { if ( $ _SERVER [ 'REQUEST_METHOD' ] != 'POST' ) { throw new InvalidRequestException ( 'Expected a POST request.' ) ; } $ remoteAddress = $ this -> getRemoteAddress ( ) ; if ( ! $ this -> isValidRemoteAddress ( $ remoteAddress ) ) { throw new InvalidRequestException ( 'Invalid remote address.' ) ; } if ( empty ( $ _POST [ $ this -> parameter ] ) ) { throw new InvalidRequestException ( 'Expected the parameter ' . $ this -> parameter ) ; } $ payload = new Payload ( $ _POST [ 'payload' ] ) ; $ configuration = $ this -> getConfiguration ( $ payload -> getRepository ( ) ) ; if ( ! $ configuration ) { throw new InvalidRequestException ( 'Invalid repository: ' . $ payload -> getRepository ( ) ) ; } if ( $ configuration -> getDriver ( ) != 'git' ) { throw new InvalidRequestException ( 'Project is not a git repository but ' . $ configuration -> getDriver ( ) ) ; } $ driverConfig = new DriverConfig ( ) ; $ driverConfig -> setDirectory ( $ configuration -> getSource ( ) ) ; $ driverConfig -> setBranch ( $ payload -> getBranch ( ) ) ; $ driverConfig -> setRepository ( $ configuration -> getRepository ( ) ) ; $ driver = new GitDriver ( ) ; $ driver -> install ( $ driverConfig ) ; $ generator = $ this -> configureGenerator ( $ configuration , $ payload ) ; $ generator -> generate ( ) ; }
Listens for incoming requests.

@throws InvalidRequestException
Listens for incoming requests .