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


PHP Strings::startsWith方法代码示例

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


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

示例1: maybeReplacePlaceholderWithPrefix

 private function maybeReplacePlaceholderWithPrefix($key)
 {
     if (Strings::startsWith($key, self::PREFIX_PLACEHOLDER)) {
         return $this->dbPrefix . Strings::substring($key, Strings::length(self::PREFIX_PLACEHOLDER));
     }
     return $key;
 }
开发者ID:wp-cpm,项目名称:versionpress,代码行数:7,代码来源:UserMetaStorage.php

示例2: add

 public function add($id, $line)
 {
     if (\Nette\Utils\Strings::startsWith($id, '$')) {
         return;
     }
     $this->messages[$id] = ['line' => $line, 'msgid' => $id];
 }
开发者ID:bazo,项目名称:nette-translation,代码行数:7,代码来源:KdybyLatte.php

示例3: prepareMacro

 private static function prepareMacro(MacroNode $node, PhpWriter $writer)
 {
     $media = null;
     $module = null;
     while ($node->tokenizer->hasNext()) {
         $words[] = $node->tokenizer->fetchWord();
     }
     foreach ($words as $index => $word) {
         if (Strings::startsWith($word, "module:")) {
             $module = self::parseModule($word);
             unset($words[$index]);
         }
         if (Strings::startsWith($word, "media:")) {
             $media = self::parseMedia($word);
             unset($words[$index]);
         }
         if (Strings::startsWith($word, "alt=")) {
             unset($words[$index]);
         }
     }
     $param = implode(', ', $words);
     $result = $writer->write("\$assetsLoader = \$control->getWidget('assetsLoader');");
     if (isset($module)) {
         $result .= $writer->write("\$assetsLoader->setModule('{$module}');");
     } else {
         $result .= $writer->write("\$assetsLoader->setModule(null);");
     }
     $result .= $writer->write("\$assetsLoader->setMedia('{$media}');");
     $result .= 'if ($assetsLoader instanceof Nette\\Application\\UI\\IPartiallyRenderable) $assetsLoader->validateControl();';
     return array('php' => $result, 'param' => $param);
 }
开发者ID:bazo,项目名称:Tatami,代码行数:31,代码来源:Macro.php

示例4: createComponent

 public function createComponent($name)
 {
     if (Strings::startsWith($name, 'vysledkovka')) {
         return $this->createComponentVysledkovka($name);
     }
     return parent::createComponent($name);
 }
开发者ID:hleumas,项目名称:databaza,代码行数:7,代码来源:VysledkovkaPresenter.php

示例5: injectComponentFactories

 /**
  * @param \Nette\DI\Container $dic
  * @throws MemberAccessException
  * @internal
  */
 public function injectComponentFactories(Nette\DI\Container $dic)
 {
     if (!$this instanceof Nette\Application\UI\PresenterComponent && !$this instanceof Nette\Application\UI\Component) {
         throw new MemberAccessException('Trait ' . __TRAIT__ . ' can be used only in descendants of PresenterComponent.');
     }
     $this->autowireComponentFactoriesLocator = $dic;
     $storage = $dic->hasService('autowired.cacheStorage') ? $dic->getService('autowired.cacheStorage') : $dic->getByType('Nette\\Caching\\IStorage');
     $cache = new Nette\Caching\Cache($storage, 'Kdyby.Autowired.AutowireComponentFactories');
     if ($cache->load($presenterClass = get_class($this)) !== NULL) {
         return;
     }
     $ignore = class_parents('Nette\\Application\\UI\\Presenter') + ['ui' => 'Nette\\Application\\UI\\Presenter'];
     $rc = new ClassType($this);
     foreach ($rc->getMethods() as $method) {
         if (in_array($method->getDeclaringClass()->getName(), $ignore, TRUE) || !Strings::startsWith($method->getName(), 'createComponent')) {
             continue;
         }
         foreach ($method->getParameters() as $parameter) {
             if (!($class = $parameter->getClassName())) {
                 // has object type hint
                 continue;
             }
             if (!$this->findByTypeForFactory($class) && !$parameter->allowsNull()) {
                 throw new MissingServiceException("No service of type {$class} found. Make sure the type hint in {$method} is written correctly and service of this type is registered.");
             }
         }
     }
     $files = array_map(function ($class) {
         return ClassType::from($class)->getFileName();
     }, array_diff(array_values(class_parents($presenterClass) + ['me' => $presenterClass]), $ignore));
     $files[] = ClassType::from($this->autowireComponentFactoriesLocator)->getFileName();
     $cache->save($presenterClass, TRUE, [$cache::FILES => $files]);
 }
开发者ID:kdyby,项目名称:autowired,代码行数:38,代码来源:AutowireComponentFactories.php

示例6: from

 /**
  * @return self
  */
 public static function from(\ReflectionParameter $from)
 {
     $param = new static();
     $param->name = $from->getName();
     $param->reference = $from->isPassedByReference();
     if ($from->isArray()) {
         $param->typeHint = 'array';
     } elseif (PHP_VERSION_ID >= 50400 && $from->isCallable()) {
         $param->typeHint = 'callable';
     } else {
         try {
             $param->typeHint = $from->getClass() ? '\\' . $from->getClass()->getName() : NULL;
         } catch (\ReflectionException $e) {
             if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
                 $param->typeHint = '\\' . $m[1];
             } else {
                 throw $e;
             }
         }
     }
     $param->optional = PHP_VERSION_ID < 50407 ? $from->isOptional() || $param->typeHint && $from->allowsNull() : $from->isDefaultValueAvailable();
     $param->defaultValue = PHP_VERSION_ID === 50316 ? $from->isOptional() : $from->isDefaultValueAvailable() ? $from->getDefaultValue() : NULL;
     $namespace = $from->getDeclaringClass() ? $from->getDeclaringClass()->getNamespaceName() : NULL;
     $namespace = $namespace ? "\\{$namespace}\\" : '\\';
     if (Nette\Utils\Strings::startsWith($param->typeHint, $namespace)) {
         $param->typeHint = substr($param->typeHint, strlen($namespace));
     }
     return $param;
 }
开发者ID:NetteCamp,项目名称:2015-nextras-orm-twitter,代码行数:32,代码来源:Parameter.php

示例7: constructUrl

 public function constructUrl(Request $appRequest, Url $refUrl)
 {
     // Module prefix not match.
     if ($this->module && !Strings::startsWith($appRequest->getPresenterName(), $this->module)) {
         return null;
     }
     $params = $appRequest->getParameters();
     $urlStack = [];
     // Module prefix
     $moduleFrags = explode(":", Strings::lower($appRequest->getPresenterName()));
     $resourceName = array_pop($moduleFrags);
     $urlStack += $moduleFrags;
     // Resource
     $urlStack[] = Strings::lower($resourceName);
     // Id
     if (isset($params['id']) && is_scalar($params['id'])) {
         $urlStack[] = $params['id'];
         unset($params['id']);
     }
     // Set custom action
     if (isset($params['action']) && $this->_isApiAction($params['action'])) {
         unset($params['action']);
     }
     $url = $refUrl->getBaseUrl() . implode('/', $urlStack);
     // Add query parameters
     if (!empty($params)) {
         $url .= "?" . http_build_query($params);
     }
     return $url;
 }
开发者ID:bauer01,项目名称:unimapper-nette,代码行数:30,代码来源:Route.php

示例8: send

 /**
  * @param string $user
  * @param string $name
  * @param string $type
  * @param string $action
  * @param mixed[] $templateArgs
  */
 public function send($user, $name, $type, $action, array $templateArgs = array())
 {
     $presenter = $this->createPresenter();
     $request = $this->getRequest($type, $action);
     $response = $presenter->run($request);
     $presenter->template->user = $user;
     $presenter->template->name = $name;
     foreach ($templateArgs as $key => $val) {
         $presenter->template->{$key} = $val;
     }
     if (!$response instanceof TextResponse) {
         throw new InvalidArgumentException(sprintf('Type \'%s\' does not exist.', $type));
     }
     try {
         $data = (string) $response->getSource();
     } catch (\Nette\Application\BadRequestException $e) {
         if (Strings::startsWith($e->getMessage(), 'Page not found. Missing template')) {
             throw new InvalidArgumentException(sprintf('Type \'%s\' does not exist.', $type));
         }
     }
     $message = new Message();
     $message->setHtmlBody($data);
     $message->setSubject(ucfirst($action));
     $message->setFrom($this->senderEmail, $this->senderName ?: null);
     $message->addTo($user, $name);
     $this->mailer->send($message);
 }
开发者ID:venne,项目名称:venne,代码行数:34,代码来源:EmailManager.php

示例9: actionFiles

 /**
  * Akce pro kontrolu přístupů ke složkám a souborům
  */
 public function actionFiles()
 {
     $filesManager = $this->createFilesManager();
     $writableDirectories = $filesManager->checkWritableDirectories();
     $writableFiles = $filesManager->checkWritableFiles();
     $stateError = false;
     $statesArr = [];
     if (!empty($writableDirectories)) {
         foreach ($writableDirectories as $directory => $state) {
             $statesArr['Directory: ' . (Strings::startsWith($directory, '/') ? '.' : '') . $directory] = $state;
             if (!$state) {
                 $stateError = true;
             }
         }
     }
     if (!empty($writableFiles)) {
         foreach ($writableFiles as $file => $state) {
             $statesArr['File: ' . (Strings::startsWith($file, '/') ? '.' : '') . $file] = $state;
             if (!$state) {
                 $stateError = true;
             }
         }
     }
     if ($stateError) {
         //vyskytla se chyba
         $this->template->states = $statesArr;
     } else {
         $this->redirect($this->getNextStep('files'));
     }
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:33,代码来源:WizardPresenter.php

示例10: from

 /** @return ClassType */
 public static function from($from)
 {
     $from = $from instanceof \ReflectionClass ? $from : new \ReflectionClass($from);
     $class = new static($from->getShortName());
     $class->type = $from->isInterface() ? 'interface' : (PHP_VERSION_ID >= 50400 && $from->isTrait() ? 'trait' : 'class');
     $class->final = $from->isFinal();
     $class->abstract = $from->isAbstract() && $class->type === 'class';
     $class->implements = $from->getInterfaceNames();
     $class->documents = preg_replace('#^\\s*\\* ?#m', '', trim($from->getDocComment(), "/* \r\n"));
     $namespace = $from->getNamespaceName();
     if ($from->getParentClass()) {
         $class->extends = $from->getParentClass()->getName();
         if ($namespace) {
             $class->extends = Strings::startsWith($class->extends, "{$namespace}\\") ? substr($class->extends, strlen($namespace) + 1) : '\\' . $class->extends;
         }
         $class->implements = array_diff($class->implements, $from->getParentClass()->getInterfaceNames());
     }
     if ($namespace) {
         foreach ($class->implements as &$interface) {
             $interface = Strings::startsWith($interface, "{$namespace}\\") ? substr($interface, strlen($namespace) + 1) : '\\' . $interface;
         }
     }
     foreach ($from->getProperties() as $prop) {
         $class->properties[$prop->getName()] = Property::from($prop);
     }
     foreach ($from->getMethods() as $method) {
         if ($method->getDeclaringClass() == $from) {
             // intentionally ==
             $class->methods[$method->getName()] = Method::from($method);
         }
     }
     return $class;
 }
开发者ID:prcharom,项目名称:w-pps-reality,代码行数:34,代码来源:ClassType.php

示例11: __invoke

 /**
  * @param \Nette\Application\Application $application
  * @param \Nette\Application\Request $request
  */
 public function __invoke(Application $application, Request $request)
 {
     if (PHP_SAPI === 'cli') {
         newrelic_background_job(TRUE);
     }
     $params = $request->getParameters();
     $action = $request->getPresenterName();
     if (isset($params[$this->actionKey])) {
         $action = sprintf('%s:%s', $action, $params[$this->actionKey]);
     }
     if (!empty($this->map)) {
         foreach ($this->map as $pattern => $appName) {
             if ($pattern === '*') {
                 continue;
             }
             if (Strings::endsWith($pattern, '*')) {
                 $pattern = Strings::substring($pattern, 0, -1);
             }
             if (Strings::startsWith($pattern, ':')) {
                 $pattern = Strings::substring($pattern, 1);
             }
             if (Strings::startsWith($action, $pattern)) {
                 \VrtakCZ\NewRelic\Tracy\Bootstrap::setup($appName, $this->license);
                 break;
             }
         }
     }
     newrelic_name_transaction($action);
     newrelic_disable_autorum();
 }
开发者ID:vrtak-cz,项目名称:newrelic-nette,代码行数:34,代码来源:OnRequestCallback.php

示例12: isModuleCurrent

 /**
  * @param  string
  * @param  string
  * @return bool
  */
 public function isModuleCurrent($module, $presenter = NULL)
 {
     if (Strings::startsWith($name = $this->getName(), trim($module, ':') . ':')) {
         return $presenter === NULL ? TRUE : Strings::endsWith($name, ':' . $presenter);
     }
     return FALSE;
 }
开发者ID:milo,项目名称:web-project,代码行数:12,代码来源:BasePresenter.php

示例13: __call

 public function __call($name, $args)
 {
     if (Strings::startsWith($name, 'render')) {
         $this->doRenderView($this->getViewByRenderMethod($name), $args);
     } else {
         return parent::__call($name, $args);
     }
 }
开发者ID:instante,项目名称:ui,代码行数:8,代码来源:Control.php

示例14: __get

 /**
  * @param string $name
  * @return string|null
  */
 public function __get($name)
 {
     $value = @$this->params[$name];
     if (Strings::startsWith($value, '/')) {
         //pokud začínáme lomítkem, doplníme cestu na absolutní
         return __DIR__ . '/../..' . $value;
     }
     return $value;
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:13,代码来源:IZIConfig.php

示例15: getDirectory

 /**
  * @param  string $type
  * @return string
  */
 private function getDirectory($type)
 {
     foreach ($this->getGroups(TRUE) as $group) {
         if (Strings::startsWith($group->name, $type)) {
             return $group->directory;
         }
     }
     throw new Nextras\Migrations\LogicException("Unknown type '{$type}' given, expected on of 's', 'b' or 'd'.");
 }
开发者ID:NetteCamp,项目名称:2015-nextras-orm-twitter,代码行数:13,代码来源:CreateCommand.php


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