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


PHP Strings::endsWith方法代码示例

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


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

示例1: 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

示例2: parse

 public function parse($name)
 {
     $args = array_slice(func_get_args(), 1);
     if (Strings::endsWith($name, '.css')) {
         return $this->getCss($name);
     } else {
         if (Strings::endsWith($name, '.js')) {
             foreach ($args as $i => $option) {
                 if (!isset(self::$allowedOptions[$option])) {
                     throw new AssetsException("Option '{$option}' is not allowed.");
                 }
                 if ($option === 'ifMinified') {
                     if (!$this->minify) {
                         return;
                     }
                     unset($args[$i]);
                 } else {
                     if ($option === 'ifNotMinified') {
                         if ($this->minify) {
                             return;
                         }
                         unset($args[$i]);
                     }
                 }
             }
             return $this->getJs($name, $args);
         } else {
             throw new AssetsException("Assets must ends with .js or .css, '{$name}' given.");
         }
     }
 }
开发者ID:webchemistry,项目名称:assets,代码行数:31,代码来源:AssetsManager.php

示例3: __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

示例4: getAssets

 /**
  * @param array $resources
  * @param bool $minify
  * @param string $baseDir
  * @throws AssetsException
  * @return array
  */
 public function getAssets(array $resources, $minify, $baseDir)
 {
     $config = [];
     $return = [];
     foreach ($resources as $resource) {
         $contents = file_get_contents($resource);
         $decompiled = Strings::endsWith($resource, '.json') ? json_decode($contents, TRUE) : Neon::decode($contents);
         $config = \Nette\DI\Config\Helpers::merge($config, $decompiled);
     }
     foreach ($config as $moduleArray) {
         foreach ($moduleArray as $type => $typeArray) {
             if (!isset(self::$supportTypes[$type])) {
                 throw new AssetsException("Found section '{$type}', but expected one of " . implode(', ', array_keys(self::$supportTypes)));
             }
             foreach ($typeArray as $minified => $assets) {
                 if ($minify) {
                     $return[$type][$minified] = TRUE;
                     continue;
                 }
                 foreach ((array) $assets as $row) {
                     if (strpos($row, '*') !== FALSE) {
                         /** @var \SplFileInfo $file */
                         foreach (Finder::findFiles(basename($row))->in($baseDir . '/' . dirname($row)) as $file) {
                             $return[$type][$minified][] = dirname($row) . '/' . $file->getBasename();
                         }
                     } else {
                         $return[$type][$minified][] = $row;
                     }
                 }
             }
         }
     }
     return $return;
 }
开发者ID:webchemistry,项目名称:assets,代码行数:41,代码来源:AssetsExtension.php

示例5: findRepositories

 private function findRepositories($config)
 {
     $classes = [];
     if ($config['scanDirs']) {
         $robot = new RobotLoader();
         $robot->setCacheStorage(new Nette\Caching\Storages\DevNullStorage());
         $robot->addDirectory($config['scanDirs']);
         $robot->acceptFiles = '*.php';
         $robot->rebuild();
         $classes = array_keys($robot->getIndexedClasses());
     }
     $repositories = [];
     foreach (array_unique($classes) as $class) {
         if (class_exists($class) && ($rc = new \ReflectionClass($class)) && $rc->isSubclassOf('Joseki\\LeanMapper\\Repository') && !$rc->isAbstract()) {
             $repositoryClass = $rc->getName();
             $entityClass = Strings::endsWith($repositoryClass, 'Repository') ? substr($repositoryClass, 0, strlen($repositoryClass) - 10) : $repositoryClass;
             $table = Utils::camelToUnderscore(Utils::trimNamespace($entityClass));
             if (array_key_exists($table, $repositories)) {
                 throw new \Exception(sprintf('Multiple repositories for table %s found.', $table));
             }
             $repositories[$table] = $repositoryClass;
         }
     }
     return $repositories;
 }
开发者ID:joseki,项目名称:leanmapper-extension,代码行数:25,代码来源:Extension.php

示例6: getTemplatePath

 /**
  * Vrátí cestu k šabloně
  * @param string $templateName
  * @return string
  */
 protected function getTemplatePath($templateName)
 {
     if (Strings::endsWith($templateName, self::LATTE_EXTENSION) == FALSE) {
         $templateName = $templateName . self::LATTE_EXTENSION;
     }
     return $this->templatePath . $templateName;
 }
开发者ID:illagrenan,项目名称:nette-base-control,代码行数:12,代码来源:BaseControl.php

示例7: prepareFilter

 /**
  * @static
  * @param string $value
  * @param string $type
  * @return array
  */
 public static function prepareFilter($value, $type)
 {
     /* select nebo boolean muze byt pouze equal */
     if ($type == self::SELECT || $type == self::BOOLEAN) {
         return array("condition" => self::EQUAL, "value" => $value);
     } elseif ($type == self::TEXT) {
         foreach (self::getConditionsByType(self::TEXT) as $name => $condition) {
             if (Strings::endsWith($value, $condition) && !Strings::startsWith($value, $condition) && $name == self::STARTSWITH) {
                 return array("condition" => $name, "value" => Strings::substring($value, 0, "-" . Strings::length($condition)));
             } elseif (Strings::startsWith($value, $condition) && !Strings::endsWith($value, $condition) && $name == self::ENDSWITH) {
                 return array("condition" => $name, "value" => Strings::substring($value, Strings::length($condition)));
             }
         }
         return array("condition" => self::CONTAINS, "value" => $value);
     } elseif ($type == self::DATE) {
         foreach (self::getConditionsByType(self::DATE) as $name => $condition) {
             if (Strings::startsWith($value, $condition)) {
                 return array("condition" => $name, "value" => Strings::substring($value, Strings::length($condition)));
             }
         }
         return array("condition" => self::DATE_EQUAL, "value" => $value);
     } elseif ($type == self::NUMERIC) {
         foreach (self::getConditionsByType(self::NUMERIC) as $name => $condition) {
             if (Strings::startsWith($value, $condition)) {
                 return array("condition" => $name, "value" => (int) Strings::substring($value, Strings::length($condition)));
             }
         }
         return array("condition" => self::EQUAL, "value" => (int) $value);
     }
 }
开发者ID:petak23,项目名称:echo-msz,代码行数:36,代码来源:FilterCondition.php

示例8: loadClassMetadata

 /**
  * @param LoadClassMetadataEventArgs $args
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $meta = $args->getClassMetadata();
     if ($this->_l) {
         if (Strings::endsWith($meta->associationMappings[$this->_lName]['targetEntity'], '::dynamic')) {
             $meta->associationMappings[$this->_lName]['targetEntity'] = $this->getTargetEntity($meta->name, $this->_l);
         }
         return;
     }
     foreach ($meta->getAssociationNames() as $name) {
         if (!Strings::endsWith($meta->associationMappings[$name]['targetEntity'], '::dynamic')) {
             continue;
         }
         $em = $args->getEntityManager();
         $target = $this->getTargetEntity($meta, $name);
         $this->_l = $meta->name;
         $this->_lName = $meta->associationMappings[$name]['inversedBy'];
         if (!$this->_lName) {
             $this->_lName = $meta->associationMappings[$name]['mappedBy'];
         }
         if ($this->_lName) {
             $targetMeta = $em->getClassMetadata($target);
         }
         $this->_l = FALSE;
         $meta->associationMappings[$name]['targetEntity'] = $target;
         if ($this->_lName) {
             $targetMeta->associationMappings[$this->_lName]['targetEntity'] = $meta->name;
         }
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:33,代码来源:DynamicMapper.php

示例9: handleException

 /**
  * @param  \Exception $e
  * @return void
  */
 protected function handleException(\Exception $e)
 {
     if ($e instanceof \Nette\Database\UniqueConstraintViolationException) {
         if (NStrings::endsWith($e->getMessage(), ' for key \'username\'')) {
             throw new DuplicateNameException();
         }
     }
 }
开发者ID:uestla,项目名称:easyblog,代码行数:12,代码来源:UserRepository.php

示例10: getTable

 /**
  * Model\Entity\SomeEntity -> some_entity
  * @param string $entityClass
  * @return string
  */
 public function getTable($entityClass)
 {
     if (Strings::endsWith($entityClass, 'y')) {
         return $this->camelToUnderdash(Strings::substring($this->trimNamespace($entityClass), 0, Strings::length($entityClass))) . 'ies';
     } else {
         return $this->camelToUnderdash($this->trimNamespace($entityClass)) . 's';
     }
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:13,代码来源:StandardMapper.php

示例11: isTaxonomyChildren

 private function isTaxonomyChildren($id)
 {
     $childrenSuffix = '_children';
     if (!Strings::endsWith($id, $childrenSuffix)) {
         return false;
     }
     $maybeTaxonomyName = Strings::substring($id, 0, Strings::length($id) - Strings::length($childrenSuffix));
     return in_array($maybeTaxonomyName, $this->taxonomies);
 }
开发者ID:wp-cpm,项目名称:versionpress,代码行数:9,代码来源:OptionStorage.php

示例12: getMinerUrl

 /**
  * Funkce vracející URL pro přístup ke zvolenému mineru
  * @param string $minerType
  * @return string
  */
 public function getMinerUrl($minerType)
 {
     $url = @$this->params['driver_' . $minerType]['server'];
     if (!empty($url) && !empty($this->params['driver_' . $minerType]['minerUrl'])) {
         if (!Strings::endsWith($this->params['driver_' . $minerType]['server'], '/')) {
             $url .= ltrim($this->params['driver_' . $minerType]['minerUrl'], '/');
         }
     }
     return $url;
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:15,代码来源:MiningDriverFactory.php

示例13: joinTableName

 public function joinTableName($sourceEntity, $targetEntity, $propertyName = null)
 {
     if (Strings::endsWith($targetEntity, '::dynamic')) {
         $targetEntity = $this->detectTargetEntity($sourceEntity, $propertyName);
     }
     if (Strings::endsWith($sourceEntity, '::dynamic')) {
         $sourceEntity = $this->detectTargetEntity($targetEntity, $propertyName);
     }
     return strtolower($this->classToNamespace($sourceEntity)) . '_' . parent::joinTableName($sourceEntity, $targetEntity, $propertyName);
 }
开发者ID:svobodni,项目名称:web,代码行数:10,代码来源:VenneNamingStrategy.php

示例14: getName

 /**
  * Returns target service name<br>
  * As default it convert name of class 'MyExtraService' to 'myExtra'
  * @return string
  */
 public function getName()
 {
     $class = get_called_class();
     $slashPos = strrpos($class, "\\");
     $className = trim(substr($class, $slashPos), "\\");
     if (Strings::endsWith($className, self::NAME_SUFFIX)) {
         $className = substr($className, 0, strlen($className) - strlen(self::NAME_SUFFIX));
     }
     return lcfirst($className);
 }
开发者ID:pipaslot,项目名称:rest,代码行数:15,代码来源:AServiceBase.php

示例15: FileNotFoundException

 function __construct($root)
 {
     if (!Strings::endsWith($root, '/')) {
         $root .= '/';
     }
     if (!is_dir($root)) {
         throw new FileNotFoundException("Root directory '{$root}' not found.");
     }
     $this->root = $root;
 }
开发者ID:joseki,项目名称:sandbox,代码行数:10,代码来源:FileStorage.php


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