当前位置: 首页>>代码示例>>PHP>>正文


PHP self::setPath方法代码示例

本文整理汇总了PHP中self::setPath方法的典型用法代码示例。如果您正苦于以下问题:PHP self::setPath方法的具体用法?PHP self::setPath怎么用?PHP self::setPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在self的用法示例。


在下文中一共展示了self::setPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: import

 /**
  * Constructs a SiteUrl object from request variables
  *
  * @param HttpUrlDictionary $dictionary dictionary of values to be used in building the SiteUrl
  * @param string $baseHost optional host to be treated as base host
  * @param string $baseUri optional uri to be treated as base uri
  *
  * @return SiteUrl
  */
 static function import(HttpUrlDictionary $dictionary, $baseHost = null, $baseUri = '/')
 {
     $url = new self();
     if ($baseHost) {
         $url->setBaseHost($baseHost);
     }
     $url->setBasePath($baseUri);
     $url->setScheme($dictionary->getField(HttpUrlDictionary::HTTPS) ? 'https' : 'http')->setHost($dictionary->getField(HttpUrlDictionary::HOST))->setPort($dictionary->getField(HttpUrlDictionary::PORT));
     //get the URI itself
     $uri = $dictionary->getField(HttpUrlDictionary::URI);
     if (!preg_match('/^https?:\\/\\//', $uri)) {
         $uri = '/' . ltrim($uri, '/');
     }
     $parts = parse_url($uri);
     if (isset($parts['path'])) {
         $path = urldecode($parts['path']);
         $url->setPath($path);
     }
     if (isset($parts['query'])) {
         $newQuery = $query = array();
         parse_str($parts['query'], $query);
         foreach ($query as $k => $v) {
             $newQuery[urldecode($k)] = is_array($v) ? $v : urldecode($v);
         }
         $url->setQuery($newQuery);
     }
     return $url;
 }
开发者ID:phoebius,项目名称:ajax-example,代码行数:37,代码来源:SiteUrl.class.php

示例2: import

 /**
  * Constructs a SiteUrl object from request variables
  *
  * @return SiteUrl
  */
 static function import($scheme, $host, $port, $uri, $baseHost = null, $baseUri = '/')
 {
     $url = new self();
     if ($baseHost) {
         $url->setBaseHost($baseHost);
     }
     $url->setBasePath($baseUri);
     $url->setScheme($scheme)->setHost($host)->setPort($port);
     //get the URI itself
     if (!preg_match('/^https?:\\/\\//', $uri)) {
         $uri = '/' . ltrim($uri, '/');
     }
     $parts = parse_url($uri);
     if (isset($parts['path'])) {
         $path = urldecode($parts['path']);
         $url->setPath($path);
     }
     if (isset($parts['query'])) {
         $newQuery = $query = array();
         parse_str($parts['query'], $query);
         foreach ($query as $k => $v) {
             $newQuery[urldecode($k)] = is_array($v) ? $v : urldecode($v);
         }
         $url->setQuery($newQuery);
     }
     return $url;
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:32,代码来源:SiteUrl.class.php

示例3: addThumb

 public function addThumb($maxDim, $folder)
 {
     $thumb = new self();
     $thumb->setPath($this->getFolderPath());
     $thumb->setMaxDim($maxDim);
     $thumb->setFolder($folder);
     $this->thumbs[$folder] = $thumb;
 }
开发者ID:sergiowebmaster,项目名称:CleanCode,代码行数:8,代码来源:CleanCodeImage.php

示例4: factory

 /**
  * @param Schema   $schema
  * @param Property $property
  * @param string $operationType
  * @return Operation
  */
 public static function factory(Schema $schema, Property $property, $operationType)
 {
     $operation = new self();
     $operation->setType($operationType);
     $operation->setSchema($schema);
     $operation->setPath($property->getPath());
     $operation->setValue($property->getValue());
     return $operation;
 }
开发者ID:svn2github,项目名称:rackspace-cloud-files-cdn,代码行数:15,代码来源:Operation.php

示例5: byPath

 public static function byPath($_pathfile)
 {
     if (!file_exists($_pathfile)) {
         throw new Exception('Chemin jusqu\'au widget non trouvé : ' . $_pathfile);
     }
     $path_parts = pathinfo($_pathfile);
     $informations = explode('.', $path_parts['basename']);
     $widget = new self();
     $widget->setType($informations[1]);
     $widget->setSubtype($informations[2]);
     $widget->setName($informations[3]);
     $folder = explode('/', $path_parts['dirname']);
     $widget->setVersion($folder[count($folder) - 1]);
     $widget->setContent(file_get_contents($_pathfile));
     $widget->setPath($_pathfile);
     return $widget;
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:17,代码来源:widget.class.php

示例6: fromInput

 /**
  * @return Request
  */
 public static function fromInput()
 {
     global $module;
     $model = new self();
     $model->setMethod(self::getMethodFromInput());
     if (isset($module)) {
         $model->setPath($module);
         $input = explode('/', $module);
         $model->setSegments($input);
     }
     $model->setBody(InputStream::getInput());
     $model->setHeaders(self::getHeadersFromInput());
     $model->setParameters($_GET);
     $model->setCookies($_COOKIE);
     $model->setPost($_POST);
     $model->setEnvironment($_SERVER);
     $model->setStatus(http_response_code());
     $model->setUrl(self::getCurrentUri());
     $model->parseData();
     return $model;
 }
开发者ID:catlabinteractive,项目名称:neuron,代码行数:24,代码来源:Request.php

示例7: createFromCategoryEntity

 /**
  * @param CategoryEntity $category
  * @return Category
  */
 public static function createFromCategoryEntity(CategoryEntity $category)
 {
     $struct = new self();
     $struct->setId($category->getId());
     $struct->setName($category->getName());
     $struct->setPosition($category->getPosition());
     $struct->setParentId($category->getParentId());
     $path = $category->getPath();
     if ($path) {
         $path = ltrim($path, '|');
         $path = rtrim($path, '|');
         $path = explode('|', $path);
         $struct->setPath(array_reverse($path));
     }
     return $struct;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:20,代码来源:Category.php

示例8: createFromGlobals

 /**
  * @param wfWAFRequest|null $request
  * @return wfWAFRequest
  */
 public static function createFromGlobals($request = null)
 {
     if ($request === null) {
         if (version_compare(phpversion(), '5.3.0') > 0) {
             $class = get_called_class();
             $request = new $class();
         } else {
             $request = new self();
         }
     }
     $request->setAuth(array());
     $request->setCookies(array());
     $request->setFileNames(array());
     $request->setFiles(array());
     $request->setHeaders(array());
     $request->setHost('');
     $request->setIP('');
     $request->setMethod('');
     $request->setPath('');
     $request->setProtocol('');
     $request->setTimestamp('');
     $request->setURI('');
     $request->setBody(wfWAFUtils::stripMagicQuotes($_POST));
     $request->setQueryString(wfWAFUtils::stripMagicQuotes($_GET));
     $request->setCookies(wfWAFUtils::stripMagicQuotes($_COOKIE));
     $request->setFiles(wfWAFUtils::stripMagicQuotes($_FILES));
     if (!empty($_FILES)) {
         $fileNames = array();
         foreach ($_FILES as $input => $file) {
             $fileNames[$input] = wfWAFUtils::stripMagicQuotes($file['name']);
         }
         $request->setFileNames($fileNames);
     }
     if (is_array($_SERVER)) {
         //All of these depend on $_SERVER being non-null and an array
         $auth = array();
         if (array_key_exists('PHP_AUTH_USER', $_SERVER)) {
             $auth['user'] = wfWAFUtils::stripMagicQuotes($_SERVER['PHP_AUTH_USER']);
         }
         if (array_key_exists('PHP_AUTH_PW', $_SERVER)) {
             $auth['password'] = wfWAFUtils::stripMagicQuotes($_SERVER['PHP_AUTH_PW']);
         }
         $request->setAuth($auth);
         if (array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
             $timestamp = $_SERVER['REQUEST_TIME_FLOAT'];
         } else {
             if (array_key_exists('REQUEST_TIME', $_SERVER)) {
                 $timestamp = $_SERVER['REQUEST_TIME'];
             } else {
                 $timestamp = time();
             }
         }
         $request->setTimestamp($timestamp);
         $headers = array();
         foreach ($_SERVER as $key => $value) {
             if (wfWAFUtils::strpos($key, 'HTTP_') === 0) {
                 $header = wfWAFUtils::substr($key, 5);
                 $header = str_replace(array(' ', '_'), array('', ' '), $header);
                 $header = ucwords(wfWAFUtils::strtolower($header));
                 $header = str_replace(' ', '-', $header);
                 $headers[$header] = wfWAFUtils::stripMagicQuotes($value);
             }
         }
         if (array_key_exists('CONTENT_TYPE', $_SERVER)) {
             $headers['Content-Type'] = wfWAFUtils::stripMagicQuotes($_SERVER['CONTENT_TYPE']);
         }
         if (array_key_exists('CONTENT_LENGTH', $_SERVER)) {
             $headers['Content-Length'] = wfWAFUtils::stripMagicQuotes($_SERVER['CONTENT_LENGTH']);
         }
         $request->setHeaders($headers);
         $host = '';
         if (array_key_exists('Host', $headers)) {
             $host = $headers['Host'];
         } else {
             if (array_key_exists('SERVER_NAME', $_SERVER)) {
                 $host = wfWAFUtils::stripMagicQuotes($_SERVER['SERVER_NAME']);
             }
         }
         $request->setHost($host);
         $request->setMethod(array_key_exists('REQUEST_METHOD', $_SERVER) ? wfWAFUtils::stripMagicQuotes($_SERVER['REQUEST_METHOD']) : 'GET');
         $request->setProtocol(array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
         $request->setUri(array_key_exists('REQUEST_URI', $_SERVER) ? wfWAFUtils::stripMagicQuotes($_SERVER['REQUEST_URI']) : '');
         $uri = parse_url($request->getURI());
         if (is_array($uri) && array_key_exists('path', $uri)) {
             $path = $uri['path'];
         } else {
             $path = $request->getURI();
         }
         $request->setPath($path);
     }
     return $request;
 }
开发者ID:ashenkar,项目名称:sanga,代码行数:96,代码来源:request.php

示例9: fromArray

 /**
  * Creates a CronJobDefinition from a Array $job
  * provided by the parser $parser 
  * 
  * @param Array $xml
  * @param CronJobParser $parser
  * 
  * @return CronJobDefinition
  */
 public static function fromArray(array $job, CronJobParser $parser)
 {
     // create and return object
     $obj = new self();
     $obj->setParser($parser);
     $obj->setName($job["name"]);
     $obj->setForkable((bool) $job["forkable"]);
     $obj->setInterval($job["interval"]);
     $obj->setPath($job["path"]);
     $obj->setClass($job["class"]);
     $obj->setStartTime($job["starttime"]);
     $obj->setEndTime($job["endtime"]);
     $obj->setArguments($job["args"]);
     $obj->setWeekDays($job["weekdays"]);
     $obj->setSuspended((bool) $job["suspended"]);
     if (isset($job["lastrun"])) {
         $obj->setLastExec($job["lastrun"]);
     } else {
         $obj->setLastExec(0);
     }
     return $obj;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:31,代码来源:CronJobDefinition.class.php

示例10: createCookieObject

 /**
  * Creates a cookie object from a string
  * 
  * @param   string                      The cookie string
  * @return  Woops_Http_Cookie           The cookie object
  * @throws  Woops_Http_Cookie_Exception If the cookie string cannot be parsed
  */
 public static function createCookieObject($str)
 {
     // Finds the position of the first '=' character
     $equal = strpos($str, '=');
     // Checks for the '=' character
     if (!$equal) {
         // Invalid cookie - No '=' character
         throw new Woops_Http_Cookie_Exception('Invalid cookie: \'' . $str . '\'', Woops_Http_Cookie_Exception::EXCEPTION_BAD_COOKIE);
     }
     // Gets the cookie's name
     $name = trim(substr($str, 0, $equal));
     // Gets the cookie options
     $options = trim(substr($str, $equal + 1));
     // Gets the cookie's options' parts
     $parts = explode(';', $options);
     // Gets the cookie valie
     $value = trim(array_shift($parts));
     // Creates the cookie object
     $cookie = new self($name, $value);
     // Process each part
     foreach ($parts as $part) {
         // Position of the '=' character
         $equal = strpos($part, '=');
         // Checks for the '=' character
         if (!$equal) {
             // Option without a value
             $name = trim($part);
         } else {
             // Gets the name and the value of the option
             $name = trim(substr($part, 0, $equal));
             $value = trim(substr($part, $equal + 1));
         }
         // Checks the option name
         switch ($name) {
             // Expiration date
             case 'expires':
                 // Sets the expiration date (as a timestamp)
                 $cookie->setExpires(strtotime($value));
                 break;
                 // Path
             // Path
             case 'path':
                 // Sets the cookie's path
                 $cookie->setPath($value);
                 break;
                 // Domain
             // Domain
             case 'domain':
                 // Sets the cookie's domain
                 $cookie->setDomain($value);
                 break;
                 // Secure option
             // Secure option
             case 'secure':
                 // The cookie is secure
                 $cookie->setSecure(true);
                 break;
                 // HTTP only option
             // HTTP only option
             case 'HttpOnly':
                 // The cookie is accessible only through the HTTP protocol
                 $cookie->setHttpOnly(true);
                 break;
                 // Unknown option
             // Unknown option
             default:
                 break;
         }
     }
     // Returns the cookie object
     return $cookie;
 }
开发者ID:Sect0R,项目名称:WOOPS,代码行数:79,代码来源:Cookie.class.php

示例11: factory

 /**
  * Factory method to use when creating a new torrent object
  *
  * @param string $type
  * @param array $params
  * @return Zend_BitTorrent_Torrent
  * @throws Zend_BitTorrent_Torrent_Exception
  */
 public static function factory($type, $params = array())
 {
     if ($params !== null && !is_array($params)) {
         /** @see Zend_BitTorrent_Torrent_Exception */
         require_once 'Zend/BitTorrent/Torrent/Exception.php';
         throw new Zend_BitTorrent_Torrent_Exception('$params must either be null or an array.');
     }
     $torrent = new self();
     if ($type === self::CREATE_FROM_FILE) {
         if (!isset($params['file'])) {
             /** @see Zend_BitTorrent_Torrent_Exception */
             require_once 'Zend/BitTorrent/Torrent/Exception.php';
             throw new Zend_BitTorrent_Torrent_Exception('Missing "file" parameter.');
         }
         $torrent->setTorrentFilePath($params['file']);
         $torrent->buildFromTorrent();
     } else {
         if ($type === self::CREATE_FROM_PATH) {
             if (!isset($params['path']) || !isset($params['announce'])) {
                 /** @see Zend_BitTorrent_Torrent_Exception */
                 require_once 'Zend/BitTorrent/Torrent/Exception.php';
                 throw new Zend_BitTorrent_Torrent_Exception('Missing "path" and/or "announce" parameters.');
             }
             $torrent->setPath($params['path'])->setAnnounce($params['announce'])->buildFromPath();
         } else {
             if ($type === self::CREATE_NEW) {
                 /* Do nothing */
             } else {
                 /** @see Zend_BitTorrent_Torrent_Exception */
                 require_once 'Zend/BitTorrent/Torrent/Exception.php';
                 throw new Zend_BitTorrent_Torrent_Exception('Invalid type.');
             }
         }
     }
     return $torrent;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:44,代码来源:Torrent.php

示例12: template

 /**
  * Create a new template instance using path and extension from current instance
  *
  * @param string  $template   Template name
  * @param array   $variables  Template variables
  *
  * @return $this
  */
 public function template($template, $variables = [])
 {
     $instance = new self();
     $instance->setPath($this->path);
     $instance->setExtension($this->extension);
     $instance->setTemplate($template);
     $instance->setVariables($variables);
     return $instance;
 }
开发者ID:mrjulio,项目名称:spartan-php,代码行数:17,代码来源:Php.php

示例13: createFromShopEntity

 /**
  * @param ShopEntity $shop
  * @return Shop
  */
 public static function createFromShopEntity(ShopEntity $shop)
 {
     $struct = new self();
     $struct->setId($shop->getId());
     $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());
     $struct->setIsDefault($shop->getDefault());
     $struct->setName($shop->getName());
     $struct->setHost($shop->getHost());
     $struct->setPath($shop->getBasePath());
     $struct->setUrl($shop->getBaseUrl());
     $struct->setSecure($shop->getSecure());
     $struct->setSecureHost($shop->getSecureHost());
     $struct->setSecurePath($shop->getSecureBasePath());
     if ($shop->getCategory()) {
         $struct->setCategory(Category::createFromCategoryEntity($shop->getCategory()));
     }
     if ($shop->getFallback()) {
         $struct->setFallbackId($shop->getFallback()->getId());
     }
     return $struct;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:25,代码来源:Shop.php

示例14: fromEnvironment

 /**
  * Builds a new URI object from server environment
  *
  * @param array $environment Server environment (e.g. $_SERVER)
  * @return Uri
  */
 public static function fromEnvironment(array $environment)
 {
     $uri = new self();
     $uri->setScheme(isset($environment['HTTPS']) && ($environment['HTTPS'] == 'on' || $environment['HTTPS'] == 1) || isset($environment['HTTP_X_FORWARDED_PROTO']) && $environment['HTTP_X_FORWARDED_PROTO'] == 'https' ? 'https' : 'http');
     $uri->setHostname($environment['HTTP_HOST']);
     $uri->setPort(isset($environment['SERVER_PORT']) ? (int) $environment['SERVER_PORT'] : NULL);
     $uri->setUsername(isset($environment['PHP_AUTH_USER']) ? $environment['PHP_AUTH_USER'] : NULL);
     $uri->setPassword(isset($environment['PHP_AUTH_PW']) ? $environment['PHP_AUTH_PW'] : NULL);
     $requestUriParts = explode('?', $environment['REQUEST_URI'], 2);
     $uri->setPath($requestUriParts[0]);
     if (isset($requestUriParts[1])) {
         $queryParts = explode('#', $requestUriParts[1], 2);
         $uri->setQuery($queryParts[0]);
         $uri->setFragment(isset($queryParts[1]) ? $queryParts[1] : NULL);
     }
     return $uri;
 }
开发者ID:pagemachine,项目名称:cors,代码行数:23,代码来源:Uri.php

示例15: fromString

 /**
  * Generate a new Cookie object from a cookie string
  * (for example the value of the Set-Cookie HTTP header)
  *
  * @static
  * @throws Zend_Http_Header_Exception_InvalidArgumentException
  * @param  $headerLine
  * @param  bool $bypassHeaderFieldName
  * @return array|SetCookie
  */
 public static function fromString($headerLine, $bypassHeaderFieldName = false)
 {
     list($name, $value) = explode(': ', $headerLine, 2);
     // check to ensure proper header type for this factory
     if (strtolower($name) !== 'set-cookie') {
         throw new Zend_Http_Header_Exception_InvalidArgumentException('Invalid header line for Set-Cookie string: "' . $name . '"');
     }
     $multipleHeaders = preg_split('#(?<!Sun|Mon|Tue|Wed|Thu|Fri|Sat),\\s*#', $value);
     $headers = array();
     foreach ($multipleHeaders as $headerLine) {
         $header = new self();
         $keyValuePairs = preg_split('#;\\s*#', $headerLine);
         foreach ($keyValuePairs as $keyValue) {
             if (strpos($keyValue, '=')) {
                 list($headerKey, $headerValue) = preg_split('#=\\s*#', $keyValue, 2);
             } else {
                 $headerKey = $keyValue;
                 $headerValue = null;
             }
             // First K=V pair is always the cookie name and value
             if ($header->getName() === NULL) {
                 $header->setName($headerKey);
                 $header->setValue($headerValue);
                 continue;
             }
             // Process the remanining elements
             switch (str_replace(array('-', '_'), '', strtolower($headerKey))) {
                 case 'expires':
                     $header->setExpires($headerValue);
                     break;
                 case 'domain':
                     $header->setDomain($headerValue);
                     break;
                 case 'path':
                     $header->setPath($headerValue);
                     break;
                 case 'secure':
                     $header->setSecure(true);
                     break;
                 case 'httponly':
                     $header->setHttponly(true);
                     break;
                 case 'version':
                     $header->setVersion((int) $headerValue);
                     break;
                 case 'maxage':
                     $header->setMaxAge((int) $headerValue);
                     break;
                 default:
                     // Intentionally omitted
             }
         }
         $headers[] = $header;
     }
     return count($headers) == 1 ? array_pop($headers) : $headers;
 }
开发者ID:par-orillonsoft,项目名称:Magento,代码行数:66,代码来源:SetCookie.php


注:本文中的self::setPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。