Sonata\Component\Payment\BasePaypal::checkPaypalFiles PHP Method

checkPaypalFiles() public method

Check openssl configuration, throw an RuntimeException if something is wrong.
public checkPaypalFiles ( )
    public function checkPaypalFiles()
    {
        $key_file = $this->getOption('key_file');
        $cert_file = $this->getOption('cert_file');
        $paypal_cert_file = $this->getOption('paypal_cert_file');
        $openssl = $this->getOption('openssl');
        // key file
        if (!file_exists($key_file)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency(sprintf('Merchant key file not found : %s', $key_file));
            }
            throw new \RuntimeException(sprintf('Merchant key file not found : %s', $key_file));
        }
        if (!is_readable($key_file)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency('Merchant key file is not readable');
            }
            throw new \RuntimeException('Merchant key file is not readable');
        }
        // cert file
        if (!file_exists($cert_file)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency('Merchant certificate file not found');
            }
            throw new \RuntimeException('Merchant certificate file not found');
        }
        if (!is_readable($cert_file)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency('Merchant certificate file is not readable');
            }
            throw new \RuntimeException('Merchant certificate file is not readable');
        }
        // paypal cert file
        if (!file_exists($paypal_cert_file)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency('PayPal certificate file not found');
            }
            throw new \RuntimeException('PayPal certificate file not found');
        }
        if (!is_readable($cert_file)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency('PayPal certificate file is not readable');
            }
            throw new \RuntimeException('PayPal certificate file is not readable');
        }
        // open ssl
        if (!file_exists($openssl)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency('openssl command not found');
            }
            throw new \RuntimeException('openssl command not found');
        }
        if (!is_executable($openssl)) {
            if ($this->getLogger()) {
                $this->getLogger()->emergency('openssl is not executable');
            }
            throw new \RuntimeException('openssl is not executable');
        }
    }