/** * Initialize the object with parameters. * * If any unknown parameters passed, they will be ignored. * * @param array $parameters An associative array of parameters * @return self provides a fluent interface. */ public function initializeParameters($parameters = array()) { $this->parameters = new ParameterContainer(); Helper::initialize($this, $parameters); return $this; }
/** * Create a new gateway instance * * @param string $class Gateway name * @param ClientInterface|null $httpClient A Guzzle HTTP Client implementation * @param HttpRequestStack|null $httpRequestStack A Symfony HTTP Request stack * @throws RuntimeException If no such gateway is found * @return GatewayInterface An object of class $class is created and returned */ public function create($class, ClientInterface $httpClient = null, HttpRequestStack $httpRequestStack = null) { $class = Helper::getGatewayClassName($class); if (!class_exists($class)) { throw new RuntimeException("Class '{$class}' not found"); } /** @var AbstractGateway $gateway */ $gateway = new $class($httpClient, $httpRequestStack); $gatewayClassInfo = new ReflectionClass($gateway); $gateway->setPath(dirname($gatewayClassInfo->getFileName())); return $gateway; }
/** * @param string $class Document name * @param array $parameters Document parameters * @throws RuntimeException If no such document is found * @return AbstractDocument */ public function createDocument($class, $parameters = []) { $class = Helper::getDocumentClassName($class, $this->getShortName()); if (!class_exists($class)) { throw new RuntimeException("Class '{$class}' not found"); } $document = new $class(array_replace($this->getParameters(), $parameters)); /** @var AbstractDocument $document */ $document->addTemplatesFolder('gateway', $this->getPath() . '/Document/views'); return $document; }