Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 protected function generateUrl($path, array $parameters = array())
 {
     $url = Url::createFromUrl($this->baseUrl);
     $url->getPath()->set($path);
     $url->getQuery()->set($parameters);
     return (string) $url;
 }
Ejemplo n.º 2
0
 /**
  * Joins a candidate uri to a base url if it is relative.
  *
  * @param string $baseUrl      the base url which SHOULD be absolute.
  * @param string $candidateUri a candidate relative or absolute URI.
  *
  * @return string               Absolute URL
  */
 public function join($baseUrl, $candidateUri)
 {
     if (preg_match('/:\\/\\//', $candidateUri) === 0) {
         $currentUrl = Url::createFromUrl($baseUrl);
         $pathParts = $output = preg_split("/(\\\\|\\/)/", $candidateUri);
         $resetPath = preg_match('/^(\\/|\\\\)/', $candidateUri) === 1;
         if ($resetPath) {
             $currentUrl->setPath(new Path());
         }
         foreach ($pathParts as $pathPart) {
             switch ($pathPart) {
                 case '..':
                     $lastElementPos = count($currentUrl->getPath()) - 1;
                     unset($currentUrl->getPath()[$lastElementPos]);
                     break;
                 case '':
                 case '.':
                     break;
                 default:
                     $currentUrl->getPath()->append($pathPart);
                     break;
             }
         }
         return (string) $currentUrl;
     }
     return $candidateUri;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function createToken($gatewayName, $model, $targetPath, array $targetParameters = array(), $afterPath = null, array $afterParameters = array())
 {
     /** @var TokenInterface $token */
     $token = $this->tokenStorage->create();
     $token->setHash($token->getHash() ?: Random::generateToken());
     $token->setGatewayName($gatewayName);
     if ($model instanceof IdentityInterface) {
         $token->setDetails($model);
     } elseif (null !== $model) {
         $token->setDetails($this->storageRegistry->getStorage($model)->identify($model));
     }
     if (0 === strpos($targetPath, 'http')) {
         $targetUrl = Url::createFromUrl($targetPath);
         $targetUrl->getQuery()->set(array_replace(array('payum_token' => $token->getHash()), $targetUrl->getQuery()->toArray(), $targetParameters));
         $token->setTargetUrl((string) $targetUrl);
     } else {
         $token->setTargetUrl($this->generateUrl($targetPath, array_replace(array('payum_token' => $token->getHash()), $targetParameters)));
     }
     if ($afterPath && 0 === strpos($afterPath, 'http')) {
         $afterUrl = Url::createFromUrl($afterPath);
         $afterUrl->getQuery()->modify($afterParameters);
         $token->setAfterUrl((string) $afterUrl);
     } elseif ($afterPath) {
         $token->setAfterUrl($this->generateUrl($afterPath, $afterParameters));
     }
     $this->tokenStorage->update($token);
     return $token;
 }
Ejemplo n.º 4
0
 public function testSameValueAs()
 {
     $url1 = Url::createFromUrl('example.com');
     $url2 = UrlImmutable::createFromUrl('//example.com');
     $url3 = UrlImmutable::createFromUrl('//example.com?foo=toto+le+heros');
     $this->assertTrue($url1->sameValueAs($url2));
     $this->assertFalse($url3->sameValueAs($url2));
 }
Ejemplo n.º 5
0
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('League\\Url\\Url', function ($app, $parameters) {
         return Url::createFromUrl(array_values($parameters)[0]);
     });
     $this->app->singleton('resolver', function ($app) {
         return new Resolver(new Steps());
     });
 }
 /**
  * @param string $url       Url to generate access link for
  * @param int    $expires   Unix timestamp at which link should expire
  * @param string $secretKey The secret key set for file container
  *
  * @return string Url with embedded signature
  */
 public function signFileDownloadLink($url, $expires, $secretKey)
 {
     $method = 'GET';
     $url = Url::createFromUrl($url);
     $path = $url->getRelativeUrl();
     $body = sprintf("%s\n%s\n%s", $method, $expires, $path);
     $signature = hash_hmac('sha1', $body, $secretKey);
     $url->getQuery()->modify(['temp_url_sig' => $signature, 'temp_url_expires' => $expires]);
     return (string) $url;
 }
Ejemplo n.º 7
0
 /**
  * Return an array with the Thumbs pictures url
  *
  * @param Crawler $node
  * @return array
  */
 public function getThumbs(Crawler $node = null)
 {
     if (!$node instanceof Crawler) {
         $node = $this->crawler;
     }
     $pictures = [];
     $node->filter('.lbcImages > meta[itemprop="image"]')->each(function (Crawler $link, $i) use(&$pictures) {
         $pictures[$i] = Url::createFromUrl($link->attr('content'))->setScheme('http')->__toString();
     });
     return $pictures;
 }
 public function __construct($url)
 {
     $this->url = Url::createFromUrl($url);
     /**
      * Clean the URL by removing every params (no need)
      */
     $query = $this->url->getQuery();
     foreach ($query->keys() as $paramName) {
         unset($query[$paramName]);
     }
     preg_match('/\\/(.*)\\/(.*)\\.htm/', parse_url($this->url, PHP_URL_PATH), $matches);
     $this->category = $matches[1];
     $this->id = $matches[2];
 }
Ejemplo n.º 9
0
 /**
  * Determine the namespace of a type from the XMLSchema
  *
  * @param \Goetas\XML\XSDReader\Schema\Type\Type|\Sapone\Util\SimpleXMLElement $type
  * @return string
  */
 public function inflectNamespace($type)
 {
     if ($type instanceof Type) {
         if ($type->getSchema()->getTargetNamespace() === SchemaReader::XSD_NS) {
             // XMLSchema primitive types do not have a namespace
             $namespace = null;
         } else {
             $namespace = array();
             // prepend the base namespace
             if ($this->config->getNamespace()) {
                 $namespace[] = $this->config->getNamespace();
             }
             if ($this->config->isAxisNamespaces()) {
                 // append the XMLSchema namespace, formatted in Apache Axis style
                 $url = Url::createFromUrl($type->getSchema()->getTargetNamespace());
                 // the namespace is an url
                 $namespace = array_merge($namespace, array_reverse(explode('.', $url->getHost()->get())));
                 if (!empty($url->getPath()->get())) {
                     $namespace = array_merge($namespace, explode('/', $url->getPath()->get()));
                 }
             }
             $namespace = implode('\\', $namespace);
         }
         return $namespace;
     } elseif ($type instanceof SimpleXMLElement) {
         if ($type->getNamespace() === SchemaReader::XSD_NS) {
             // XMLSchema primitive types do not have a namespace
             $namespace = null;
         } else {
             $namespace = array();
             // prepend the base namespace
             if ($this->config->getNamespace()) {
                 $namespace[] = $this->config->getNamespace();
             }
             if ($this->config->isAxisNamespaces()) {
                 // append the XMLSchema namespace, formatted in Apache Axis style
                 $url = Url::createFromUrl($type->getNamespace());
                 // the namespace is an url
                 $namespace = array_merge($namespace, array_reverse(explode('.', $url->getHost()->get())));
                 if (!empty($url->getPath()->get())) {
                     $namespace = array_merge($namespace, explode('/', $url->getPath()->get()));
                 }
             }
             $namespace = implode('\\', $namespace);
         }
         return $namespace;
     } else {
         throw new \InvalidArgumentException('Expected an instance of Goetas\\XML\\XSDReader\\Schema\\Type\\Type or Sapone\\Util\\SimpleXMLElement');
     }
 }
 /**
  * {@inheritDoc}
  */
 public function execute($request)
 {
     /** @var $request Capture */
     RequestNotSupportedException::assertSupports($this, $request);
     $details = ArrayObject::ensureArrayObject($request->getModel());
     $details->validateNotEmpty('PAYMENTREQUEST_0_PAYMENTACTION');
     $details->defaults(array('AUTHORIZE_TOKEN_USERACTION' => Api::USERACTION_COMMIT));
     $this->gateway->execute($httpRequest = new GetHttpRequest());
     if (isset($httpRequest->query['cancelled'])) {
         $details['CANCELLED'] = true;
         return;
     }
     if (false == $details['TOKEN']) {
         if (false == $details['RETURNURL'] && $request->getToken()) {
             $details['RETURNURL'] = $request->getToken()->getTargetUrl();
         }
         if (false == $details['CANCELURL'] && $request->getToken()) {
             $details['CANCELURL'] = $request->getToken()->getTargetUrl();
         }
         if (empty($details['PAYMENTREQUEST_0_NOTIFYURL']) && $request->getToken() && $this->tokenFactory) {
             $notifyToken = $this->tokenFactory->createNotifyToken($request->getToken()->getGatewayName(), $request->getToken()->getDetails());
             $details['PAYMENTREQUEST_0_NOTIFYURL'] = $notifyToken->getTargetUrl();
         }
         if ($details['CANCELURL']) {
             $cancelUrl = Url::createFromUrl($details['CANCELURL']);
             $query = $cancelUrl->getQuery();
             $query->modify(['cancelled' => 1]);
             $cancelUrl->setQuery($query);
             $details['CANCELURL'] = (string) $cancelUrl;
         }
         $this->gateway->execute(new SetExpressCheckout($details));
         if ($details['L_ERRORCODE0']) {
             return;
         }
     }
     $this->gateway->execute(new Sync($details));
     if ($details['PAYERID'] && Api::CHECKOUTSTATUS_PAYMENT_ACTION_NOT_INITIATED == $details['CHECKOUTSTATUS'] && $details['PAYMENTREQUEST_0_AMT'] > 0) {
         if (Api::USERACTION_COMMIT !== $details['AUTHORIZE_TOKEN_USERACTION']) {
             $confirmOrder = new ConfirmOrder($request->getFirstModel());
             $confirmOrder->setModel($request->getModel());
             $this->gateway->execute($confirmOrder);
         }
         $this->gateway->execute(new DoExpressCheckoutPayment($details));
     }
     if (false == $details['PAYERID']) {
         $this->gateway->execute(new AuthorizeToken($details));
     }
     $this->gateway->execute(new Sync($details));
 }
Ejemplo n.º 11
0
 /**
  * {@inheritDoc}
  *
  * @param Capture $request
  */
 public function execute($request)
 {
     RequestNotSupportedException::assertSupports($this, $request);
     $this->gateway->execute($httpRequest = new GetHttpRequest());
     //we are back from be2bill site so we have to just update model.
     if (empty($httpRequest->query['EXTRADATA'])) {
         throw new HttpResponse('The capture is invalid. Code Be2Bell1', 400);
     }
     $extraDataJson = $httpRequest->query['EXTRADATA'];
     if (false == ($extraData = json_decode($extraDataJson, true))) {
         throw new HttpResponse('The capture is invalid. Code Be2Bell2', 400);
     }
     if (empty($extraData['capture_token'])) {
         throw new HttpResponse('The capture is invalid. Code Be2Bell3', 400);
     }
     $this->gateway->execute($getToken = new GetToken($extraData['capture_token']));
     $url = Url::createFromUrl($getToken->getToken()->getTargetUrl());
     $url->setQuery($httpRequest->query);
     throw new HttpRedirect((string) $url);
 }
Ejemplo n.º 12
0
 /**
  * Send request upstream
  *
  * @param  Request  $request
  *
  * @return Response
  * @throws HttpException
  */
 public static function makeRequest(Request $request)
 {
     try {
         $url = Url::createFromUrl($request->fullUrl());
         $host = static::getHostFromUrl($url);
         $client = new Client(['base_uri' => $url->getScheme() . '://' . $host]);
         $proxyRequest = new GuzzleRequest($request->method(), $request->path());
         $headers = $request->header();
         array_walk($headers, function ($value, $key) use($proxyRequest) {
             $proxyRequest->withHeader($key, $value);
         });
         $stream = \GuzzleHttp\Psr7\stream_for(json_encode($request->json()->all()));
         $response = $client->send($proxyRequest, ['timeout' => 2, 'body' => $stream, 'query' => $request->query(), 'form_params' => $request->input()]);
         return static::createLocalResponse($response);
     } catch (Exception $e) {
         if (get_class($e) == GuzzleException\ClientException::class) {
             return static::createLocalResponse($e->getResponse());
         }
         abort(404);
     }
 }
Ejemplo n.º 13
0
 protected function handlePath(UrlInterface $url, $path, $args)
 {
     $path_object = $this->basePath($url, $path, $args);
     $components = parse_url($path);
     $reset = false;
     // Were we passed a built URL? If so, just return it.
     if ($string = array_get($components, 'scheme')) {
         try {
             $url = Url::createFromUrl($path);
             $path_object = $url->getPath();
             $reset = true;
         } catch (\Exception $e) {
         }
     }
     if (!$reset) {
         if ($string = array_get($components, 'path')) {
             $path_object->append($string);
         }
         if ($string = array_get($components, 'query')) {
             $url = $url->setQuery($string);
         }
         if ($string = array_get($components, 'fragment')) {
             $url = $url->setFragment($string);
         }
     }
     foreach ($args as $segment) {
         if (!is_array($segment)) {
             $segment = (string) $segment;
             // sometimes integers foul this up when we pass them in as URL arguments.
         }
         $path_object->append($segment);
     }
     if (!$reset) {
         $url_path = $url->getPath();
         $url_path->append($path_object);
     } else {
         $url_path = $path_object;
     }
     return $url->setPath($url_path);
 }
 /**
  * Get a navigation service mock that expects that the $expectedUrl is called once
  *
  * @param string $expectedUrl
  * @param string $convertFunctionName
  * @param array $getObjectUrlParams
  * @return NavigationService|PHPUnit_Framework_MockObject_MockObject
  */
 protected function getNavigationServiceMockForParameterizedQueryTest($expectedUrl, $convertFunctionName, $getObjectUrlParams)
 {
     $responseData = array('foo' => 'bar');
     $responseMock = $this->getMockBuilder('\\GuzzleHttp\\Message\\Response')->disableOriginalConstructor()->setMethods(array('json'))->getMock();
     $responseMock->expects($this->any())->method('json')->willReturn($responseData);
     $jsonConverterMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Converter\\JsonConverter')->setMethods(array($convertFunctionName))->getMock();
     $dummyObjectData = new ObjectData();
     $jsonConverterMock->expects($this->once())->method($convertFunctionName)->with($responseData)->willReturn($dummyObjectData);
     $cmisBindingsHelperMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Bindings\\CmisBindingsHelper')->setMethods(array('getJsonConverter'))->getMock();
     $cmisBindingsHelperMock->expects($this->any())->method('getJsonConverter')->willReturn($jsonConverterMock);
     /** @var NavigationService|PHPUnit_Framework_MockObject_MockObject $navigationService */
     $navigationService = $this->getMockBuilder(self::CLASS_TO_TEST)->setConstructorArgs(array($this->getSessionMock(), $cmisBindingsHelperMock))->setMethods(array('getObjectUrl', 'read'))->getMock();
     list($repositoryId, $objectId, $selector) = $getObjectUrlParams;
     $navigationService->expects($this->once())->method('getObjectUrl')->with($repositoryId, $objectId, $selector)->willReturn(Url::createFromUrl(self::BROWSER_URL_TEST));
     $navigationService->expects($this->once())->method('read')->with($expectedUrl)->willReturn($responseMock);
     return $navigationService;
 }
 /**
  * Data provider for updateType
  *
  * @return array
  */
 public function updateTypeDataProvider()
 {
     $typeDefinitionArrayRepresentation = array('foo' => 'bar');
     $typeDefinitionJsonRepresentation = '{"foo":"bar"}';
     return array(array(Url::createFromUrl(self::BROWSER_URL_TEST . '?cmisaction=updateType&type=' . $typeDefinitionJsonRepresentation), $typeDefinitionArrayRepresentation, 'repositoryId', new ItemTypeDefinition('typeId')));
 }
Ejemplo n.º 16
0
 /**
  * @expectedException RuntimeException
  */
 public function testCreateFromUrlBadName2()
 {
     Url::createFromUrl('sdfsdfqsdfsdf');
 }
 /**
  * Build an instance of \League\Url\Url for the given url
  *
  * @param string $url
  * @return Url
  */
 public function buildUrl($url)
 {
     return Url::createFromUrl($url);
 }
 /**
  * Return the thumb picture url
  *
  * @return null|string
  */
 public function getThumb()
 {
     $image = $this->node->filter('.item_imagePic .lazyload[data-imgsrc]')->first();
     if (0 === $image->count()) {
         return;
     }
     $src = $image->attr('data-imgsrc');
     return Url::createFromUrl($src)->setScheme('http')->__toString();
 }
 public function testBuildUrlReturnsUrlInstanceBasedOnGivenUrlString()
 {
     $urlString = 'http://foo.bar.baz';
     $url = Url::createFromUrl($urlString);
     $this->assertEquals($url, $this->repositoryUrlCache->buildUrl($urlString));
 }
Ejemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function resolve($url)
 {
     $relative = Url\Url::createFromUrl($url);
     if ($relative->isAbsolute()) {
         return $relative->withoutDotSegments();
     }
     if (!$relative->host->isEmpty() && $relative->getAuthority() != $this->getAuthority()) {
         return $relative->withScheme($this->scheme)->withoutDotSegments();
     }
     return $this->resolveRelative($relative)->withoutDotSegments();
 }
Ejemplo n.º 21
0
 public function __construct(\GuzzleHttp\Client $client)
 {
     $this->apiURL = Url::createFromUrl(self::BASE_URL);
     $this->client = $client;
 }
Ejemplo n.º 22
0
 /**
  * Format an object according to the formatter properties
  *
  * @param Interfaces\UrlPart|Url|string $input
  *
  * @return string
  */
 public function format($input)
 {
     if ($input instanceof Interfaces\UrlPart) {
         return $this->formatUrlPart($input);
     }
     if (!$input instanceof Url) {
         $input = Url::createFromUrl($input);
     }
     return $this->formatUrl($input);
 }
 /**
  * Data provider for getContentChanges
  *
  * @return array
  */
 public function getContentChangesDataProvider()
 {
     return array(array(Url::createFromUrl(self::BROWSER_URL_TEST . '?changeLogToken=changeLogToken&includeProperties=false' . '&includePolicyIds=false&includeACL=false&maxItems=99&succinct=false'), 'repositoryId', 'changeLogToken', false, false, false, 99), array(Url::createFromUrl(self::BROWSER_URL_TEST . '?includeProperties=true' . '&includePolicyIds=true&includeACL=true&succinct=false'), 'repositoryId', null, true, true, true, null));
 }
Ejemplo n.º 24
0
 /**
  * @param $url
  * @param array $params
  * @return string
  * @throws InvalidConfigException
  */
 public function signUrl($url, array $params = [])
 {
     $url = Url::createFromUrl($url);
     $path = $url->getPath()->getUriComponent();
     $query = array_merge($url->getQuery()->toArray(), $params);
     $signature = $this->getHttpSignature()->generateSignature($path, $query);
     $query = array_merge($query, ['s' => $signature]);
     $url->setQuery($query);
     return (string) $url;
 }
Ejemplo n.º 25
0
 /**
  * POST authorize data.
  *
  * @param   $request [description]
  *
  * @return [type] [description]
  */
 public function authorizePost($request)
 {
     $postParams = new Set($request->post());
     $params = new Set($request->get());
     // CSRF protection
     if (!$postParams->has('csrfToken') || !isset($_SESSION['csrfToken']) || $postParams->get('csrfToken') !== $_SESSION['csrfToken']) {
         throw new \Exception('Invalid CSRF token.', Resource::STATUS_BAD_REQUEST);
     }
     // TODO: Improve this, load stuff from config, add documented error codes, separate stuff into functions, etc.
     if ($postParams->get('action') === 'accept') {
         $expiresAt = time() + 3600;
         $collection = $this->getDocumentManager()->getCollection('oAuthClients');
         $cursor = $collection->find();
         $cursor->where('clientId', $params->get('client_id'));
         $clientDocument = $cursor->current();
         $collection = $this->getDocumentManager()->getCollection('users');
         $userDocument = $collection->getDocument($_SESSION['userId']);
         $collection = $this->getDocumentManager()->getCollection('authScopes');
         $scopeDocuments = [];
         $scopes = explode(',', $params->get('scope'));
         foreach ($scopes as $scope) {
             $cursor = $collection->find();
             $cursor->where('name', $scope);
             $scopeDocument = $cursor->current();
             if (null === $scopeDocument) {
                 throw new \Exception('Invalid scope given!', Resource::STATUS_BAD_REQUEST);
             }
             $scopeDocuments[] = $scopeDocument;
         }
         $code = Util\OAuth::generateToken();
         $token = $this->addToken($expiresAt, $userDocument, $clientDocument, $scopeDocuments, $code);
         $this->token = $token;
         $redirectUri = Url::createFromUrl($params->get('redirect_uri'));
         $redirectUri->getQuery()->modify(['code' => $token->getCode()]);
         //We could also use just $code
         $this->redirectUri = $redirectUri;
     } elseif ($postParams->get('action') === 'deny') {
         $redirectUri = Url::createFromUrl($params->get('redirect_uri'));
         $redirectUri->getQuery()->modify(['error' => 'User denied authorization!']);
         $this->redirectUri = $redirectUri;
     } else {
         throw new Exception('Invalid.', Resource::STATUS_BAD_REQUEST);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function modifyUrl($url)
 {
     $url = Url::createFromUrl($url);
     $url->getQuery()->modify(array('mtid' => $this->getTransactionId(), 'subid' => $this->getSubId(), 'amount' => $this->getAmount(), 'currency' => $this->getCurrency()));
     return (string) $url;
 }
 public function getRepositoriesInternalDataProvider()
 {
     $repositoryUrlCacheMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Bindings\\Browser\\RepositoryUrlCache')->setMethods(array('getRepositoryUrl', 'buildUrl', 'addRepository'))->disableProxyingToOriginalMethods()->getMock();
     $repositoryUrlCacheMock->expects($this->any())->method('buildUrl')->willReturn(Url::createFromUrl('http://foo.bar.baz'));
     $repositoryUrlCacheMockWithRepositoryUrlEntry = clone $repositoryUrlCacheMock;
     $repositoryUrlCacheMockWithRepositoryUrlEntry->expects($this->any())->method('getRepositoryUrl')->willReturn(Url::createFromUrl('http://foo.bar.baz'));
     $repositoryUrlCacheMockWithRepositoryUrlEntry->expects($this->once())->method('addRepository');
     return array('no repository id - repository url cache builds url' => array(null, $repositoryUrlCacheMock), 'with repository id - repository url cache does NOT return repository url - url is build' => array('repository-id', $repositoryUrlCacheMock), 'with repository id - repository url cache does return repository url - url is fetched from cache' => array('repository-id', $repositoryUrlCacheMockWithRepositoryUrlEntry));
 }
Ejemplo n.º 28
0
 /**
  * Execute the code generation
  */
 public function generate()
 {
     /*
      * PROXY CONFIGURATION
      */
     $proxy = current(array_filter(array(getenv('HTTP_PROXY'), getenv('http_proxy')), 'strlen'));
     if ($proxy) {
         $parsedWsdlPath = Url::createFromUrl($this->config->getWsdlDocumentPath());
         // if not fetching the wsdl file from filesystem and a proxy has been set
         if ($parsedWsdlPath->getScheme()->get() !== 'file') {
             $proxy = Url::createFromUrl($proxy);
             libxml_set_streams_context(stream_context_get_default(array($proxy->getScheme()->get() => array('proxy' => 'tcp://' . $proxy->getAuthority() . $proxy->getRelativeUrl(), 'request_fulluri' => true))));
         }
     }
     unset($proxy);
     /*
      * LOAD THE WSDL DOCUMENT
      */
     $wsdlDocument = SimpleXMLElement::loadFile($this->config->getWsdlDocumentPath());
     $wsdlDocument->registerXPathNamespace('wsdl', static::WSDL_NS);
     $schemaReader = new SchemaReader();
     /* @var \Goetas\XML\XSDReader\Schema\Schema[] $schemas */
     $schemas = array();
     /* @var \Goetas\XML\XSDReader\Schema\Type\Type[] $types */
     $types = array();
     /*
      * LOAD THE XML SCHEMAS
      */
     // read the schemas included in the wsdl document
     foreach ($wsdlDocument->xpath('/wsdl:definitions/wsdl:types/xsd:schema') as $schemaNode) {
         $schemas[] = $schemaReader->readNode(dom_import_simplexml($schemaNode));
     }
     // exclude the schemas having the following namespaces
     $unusedSchemaNamespaces = array(SchemaReader::XML_NS, SchemaReader::XSD_NS);
     // recursively read all the schema chain
     $processedSchemas = array();
     while (!empty($schemas)) {
         /* @var \Goetas\XML\XSDReader\Schema\Schema $currentSchema */
         $currentSchema = array_shift($schemas);
         if (!in_array($currentSchema, $processedSchemas) and !in_array($currentSchema->getTargetNamespace(), $unusedSchemaNamespaces)) {
             $processedSchemas[] = $currentSchema;
             $schemas = array_merge($schemas, $currentSchema->getSchemas());
         }
     }
     $schemas = $processedSchemas;
     // cleanup
     unset($currentSchema);
     unset($processedSchemas);
     unset($unusedSchemaNamespaces);
     unset($schemaNode);
     unset($schemaReader);
     /*
      * LOAD THE DEFINED TYPES
      */
     // get the complete list of defined types
     foreach ($schemas as $schema) {
         $types = array_merge($types, $schema->getTypes());
     }
     /*
      * LOAD THE SERVICES
      */
     $services = $wsdlDocument->xpath('/wsdl:definitions/wsdl:portType');
     /*
      * CODE GENERATION
      */
     $classFactory = new ClassFactory($this->config, $schemas, $types);
     foreach ($types as $type) {
         if ($type instanceof SimpleType) {
             // build the inheritance chain of the current SimpleType
             /* @var \Goetas\XML\XSDReader\Schema\Type\SimpleType[] $inheritanceChain */
             $inheritanceChain = array($type->getRestriction());
             // loop through the type inheritance chain untill the base type
             while (end($inheritanceChain) !== null) {
                 $inheritanceChain[] = end($inheritanceChain)->getBase()->getParent();
             }
             // remove the null value
             array_pop($inheritanceChain);
             // remove the 'anySimpleType'
             array_pop($inheritanceChain);
             // now the last element of the chain is the base simple type
             // enums are built only of string enumerations
             if (end($inheritanceChain)->getBase()->getName() === 'string' and array_key_exists('enumeration', $type->getRestriction()->getChecks())) {
                 $className = $classFactory->createEnum($type);
                 $this->eventDispatcher->dispatch(Event::ENUM_CREATE, new Event($className));
             }
         } elseif ($type instanceof ComplexType) {
             $className = $classFactory->createDTO($type);
             $this->eventDispatcher->dispatch(Event::DTO_CREATE, new Event($className));
         }
     }
     foreach ($services as $service) {
         $className = $classFactory->createService($service);
         $this->eventDispatcher->dispatch(Event::SERVICE_CREATE, new Event($className));
     }
     $className = $classFactory->createClassmap();
     $this->eventDispatcher->dispatch(Event::CLASSMAP_CREATE, new Event($className));
     /*
      * GENERATED CODE FIX
      */
     // create the coding standards fixer
     $fixer = new Fixer();
     $config = new FixerConfig();
     $config->setDir($this->config->getOutputPath());
     // register all the existing fixers
     $fixer->registerBuiltInFixers();
     $config->fixers(array_filter($fixer->getFixers(), function (FixerInterface $fixer) {
         return $fixer->getLevel() === FixerInterface::PSR2_LEVEL;
     }));
     // fix the generated code
     $fixer->fix($config);
 }
Ejemplo n.º 29
0
 public function setUp()
 {
     $this->url = Url::createFromUrl(
         'https://*****:*****@secure.example.com:443/test/query.php?kingkong=toto#doc3'
     );
 }
Ejemplo n.º 30
0
</td>
        			<td><?php 
            echo h($upa['upaHandle']);
            ?>
</td>
        			<td><?php 
            echo number_format($upa['upaDefaultPoints']);
            ?>
</td>
        			<td><?php 
            echo h($upa['gName']);
            ?>
</td>
        			<td style="text-align: right">
                        <?php 
            $delete_url = \League\Url\Url::createFromUrl($view->action('delete', $upa['upaID']));
            $delete_url = $delete_url->setQuery(array('ccm_token' => \Core::make('helper/validation/token')->generate('delete_action')));
            ?>
        			    <a href="<?php 
            echo $view->action($upa['upaID']);
            ?>
" class="btn btn-sm btn-default"><?php 
            echo t('Edit');
            ?>
</a>
        			    <a href="<?php 
            echo $delete_url;
            ?>
" class="btn btn-sm btn-danger"><?php 
            echo t('Delete');
            ?>