/** * Generate single page class. * * @param string $className * @return string|bool * @throws \InvalidArgumentException */ public function generate($className) { $classNameParts = explode('\\', $className); $classDataKey = 'page/' . end($classNameParts); if (!$this->configData->get($classDataKey)) { throw new \InvalidArgumentException('Invalid class name: ' . $className); } return $this->generateClass(end($classNameParts), $this->configData->get($classDataKey)); }
/** * Authorize customer on backend * * @throws \Exception * @return void */ protected function authorize() { $url = $_ENV['app_backend_url'] . $this->configuration->get('application/0/backendLoginUrl/0/value'); $data = ['login[username]' => $this->configuration->get('application/0/backendLogin/0/value'), 'login[password]' => $this->configuration->get('application/0/backendPassword/0/value')]; $this->transport->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $this->read(); if (strpos($response, 'page-login')) { throw new \Exception('Admin user cannot be logged in by curl handler!'); } }
/** * Authorize customer on backend. * * @throws \Exception * @return void */ protected function _authorize() { $url = $_ENV['app_backend_url']; $data = ['login[username]' => $this->_configuration->get('application/0/backendLogin/0/value'), 'login[password]' => $this->_configuration->get('application/0/backendPassword/0/value'), 'form_key' => $this->_formKey]; $this->_transport->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $this->read(); if (!strpos($response, 'link-logout')) { throw new \Exception("Admin user cannot be logged in by curl handler!\n Post url: {$url}"); } }
/** * Authorize customer on backend. * * @throws \Exception * @return void */ protected function authorize() { // Perform GET to backend url so form_key is set $url = $_ENV['app_backend_url']; $this->transport->write($url, [], CurlInterface::GET); $this->read(); $url = $_ENV['app_backend_url'] . $this->configuration->get('application/0/backendLoginUrl/0/value'); $data = ['login[username]' => $this->configuration->get('application/0/backendLogin/0/value'), 'login[password]' => $this->configuration->get('application/0/backendPassword/0/value'), 'form_key' => $this->formKey]; $this->transport->write($url, $data, CurlInterface::POST); $response = $this->read(); if (strpos($response, 'page-login')) { throw new \Exception('Admin user cannot be logged in by curl handler!'); } }
/** * Send request to the remote server. * * @param string $url * @param array $params * @param string $method * @param array $headers * @return void */ public function write($url, $params = [], $method = CurlInterface::POST, $headers = []) { $headers = array_merge(['Authorization: Bearer ' . $this->configuration->get(self::CONFIG_TOKEN_PATH)], $this->headers, $headers); $this->transport->write($url, json_encode($params), $method, $headers); }