예제 #1
0
파일: UrlTest.php 프로젝트: fliglio/web
 public function testHostAndPort()
 {
     $urlStr = 'foo:8080';
     $url = Url::fromString($urlStr);
     $this->assertEquals('foo', $url->getHost());
     $this->assertEquals('8080', $url->getPort());
 }
예제 #2
0
 /**
  * @param  RequestInterface $request
  * @param  MapInterface<string, AttributeInterface> $attributes
  * @param  UrlInterface $target
  */
 public function resolve(RequestInterface $request, MapInterface $attributes, UrlInterface $target) : UrlInterface
 {
     $base = $request->url();
     if ($attributes->contains(BaseParser::key())) {
         $base = $attributes->get(BaseParser::key())->content();
     }
     return Url::fromString($this->resolver->resolve((string) $base, (string) $target));
 }
예제 #3
0
 public function server(string $url) : ServerInterface
 {
     $url = Url::fromString($url);
     $hash = md5((string) $url);
     if ($this->servers->contains($hash)) {
         return $this->servers->get($hash);
     }
     $server = $this->makeServer($url);
     $this->servers = $this->servers->put($hash, $server);
     return $server;
 }
예제 #4
0
 public function get(string $name) : HttpResource
 {
     if (!$this->names()->contains($name)) {
         throw new InvalidArgumentException();
     }
     if ($this->definitions->contains($name)) {
         return $this->definitions->get($name);
     }
     $url = $this->resolver->resolve((string) $this->host, (string) $this->paths->get($name));
     $url = Url::fromString($url);
     $response = $this->transport->fulfill(new Request($url, new Method(Method::OPTIONS), new ProtocolVersion(1, 1), new Headers(new Map('string', HeaderInterface::class)), new NullStream()));
     $definition = $this->factory->make($name, $url, $response);
     $this->definitions = $this->definitions->put($name, $definition);
     return $definition;
 }
예제 #5
0
 /**
  * Returns protected var $oberserver.
  * @param string observer key
  * @return array
  */
 public function getTagList($param)
 {
     $id = $param['id'];
     $tree_id = $param['tree_id'];
     $url_edit = new Url();
     $url_del = new Url();
     $url_edit->fromString($param['href_edit_theme_tag']);
     $url_del->fromString($param['href_del_theme_tag']);
     try {
         $siteTag = new SystemSiteTag();
         $theme = $this->director->themeManager->getThemeFromId(array('id' => $id));
         $usedTags = $siteTag->getTagList(array('tree_id' => $tree_id));
         $taglist = $theme->getTagList();
         foreach ($taglist as &$item) {
             $item['userdefined'] = array_key_exists($item['id'], $usedTags) ? join(', ', $usedTags[$item['id']]) : '';
             $url_edit->setParameter('parent_tag', $item['id']);
             $url_del->setParameter('parent_tag', $item['id']);
             $item['href_edit'] = $url_edit->getUrl();
             $item['href_del'] = $item['userdefined'] ? $url_del->getUrl() : '';
         }
         return array_values($taglist);
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
예제 #6
0
 private function resolveUrl(UrlInterface $url, IdentityInterface $identity) : UrlInterface
 {
     $url = (string) $url;
     $url = rtrim($url, '/') . '/' . $identity;
     return Url::fromString($url);
 }
예제 #7
0
 /**
  * @param string $webhookUrl
  * @return Url|null
  */
 public function webhookUrl($webhookUrl = null)
 {
     if ($webhookUrl !== null) {
         $this->webhookUrl = Url::fromString($webhookUrl);
     }
     return $this->webhookUrl;
 }
예제 #8
0
 /**
  * @param array $order
  * @return Order
  */
 public static function fromArray(array $order)
 {
     Guard::keyExists($order, 'transactions');
     Guard::keyExists($order, 'amount');
     Guard::keyExists($order, 'currency');
     return new static(Transactions::fromArray($order['transactions']), Amount::fromInteger($order['amount']), Currency::fromString($order['currency']), array_key_exists('description', $order) ? Description::fromString($order['description']) : null, array_key_exists('merchant_order_id', $order) ? MerchantOrderId::fromString($order['merchant_order_id']) : null, array_key_exists('return_url', $order) ? Url::fromString($order['return_url']) : null, array_key_exists('expiration_period', $order) ? new \DateInterval($order['expiration_period']) : null, array_key_exists('id', $order) ? Uuid::fromString($order['id']) : null, array_key_exists('project_id', $order) ? Uuid::fromString($order['project_id']) : null, array_key_exists('created', $order) ? new Carbon($order['created']) : null, array_key_exists('modified', $order) ? new Carbon($order['modified']) : null, array_key_exists('completed', $order) ? new Carbon($order['completed']) : null, array_key_exists('status', $order) ? Status::fromString($order['status']) : null);
 }
예제 #9
0
 protected function parseValues(SetInterface $values)
 {
     return $values->reduce(new Set(UrlInterface::class), function (Set $urls, string $url) : Set {
         return $urls->add(Url::fromString($url));
     });
 }