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


PHP Strings::contains方法代码示例

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


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

示例1: macroElement

 /**
  * {element name[:method] [key]}
  */
 public function macroElement(MacroNode $node, PhpWriter $writer)
 {
     $rawName = $node->tokenizer->fetchWord();
     if ($rawName === FALSE) {
         throw new CompileException("Missing element type in {element}");
     }
     $rawName = explode(':', $rawName, 2);
     $name = $writer->formatWord($rawName[0]);
     $method = isset($rawName[1]) ? ucfirst($rawName[1]) : '';
     $method = Strings::match($method, '#^\\w*$#') ? "render{$method}" : "{\"render{$method}\"}";
     $idRaw = $node->tokenizer->fetchWord();
     $param = $writer->formatArray();
     if (!Strings::contains($node->args, '=>')) {
         $param = substr($param, 6, -1);
         // removes array()
     }
     if (!$idRaw) {
         throw new CompileException("Missing element title in {element}");
     }
     if (substr($idRaw, 0, 1) !== '$') {
         $id = Helpers::encodeName($idRaw);
     } else {
         $id = $idRaw;
     }
     return '$_ctrl = $_presenter->getComponent(\\CmsModule\\Content\\ElementManager::ELEMENT_PREFIX . ' . '"' . $id . '"' . ' . \'_\' . ' . $name . '); ' . '$_ctrl->setName("' . trim($idRaw, '"\'') . '");' . 'if ($presenter->isPanelOpened() && (!isset($__element) || !$__element)) { echo "<span id=\\"' . \CmsModule\Content\ElementManager::ELEMENT_PREFIX . (substr($id, 0, 1) === '$' ? '{' . $id . '}' : $id) . '_' . $rawName[0] . '\\" style=\\"display: inline-block; min-width: 50px; min-height: 25px;\\" class=\\"venne-element-container\\" data-venne-element-id=\\"' . trim($id, '"\'') . '\\" data-venne-element-name=\\"' . $rawName[0] . '\\" data-venne-element-route=\\"" . $presenter->route->id . "\\" data-venne-element-language=\\"" . $presenter->language->id . "\\" data-venne-element-buttons=\\"" . (str_replace(\'"\', "\'", json_encode($_ctrl->getViews()))) . "\\">"; }' . 'if ($_ctrl instanceof Nette\\Application\\UI\\IRenderable) $_ctrl->validateControl(); ' . "\$_ctrl->{$method}({$param});" . 'if ($presenter->isPanelOpened()) { echo "</span>"; }';
 }
开发者ID:svobodni,项目名称:web,代码行数:29,代码来源:ElementMacro.php

示例2: checkAliases

 private function checkAliases($column)
 {
     if (Strings::contains($column, ".")) {
         return $column;
     }
     return current($this->data_source->getRootAliases()) . '.' . $column;
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:7,代码来源:DoctrineDataSource.php

示例3: setDefaultDueDate

 public function setDefaultDueDate($dueDate)
 {
     if (!\Nette\Utils\Strings::contains($dueDate, "+")) {
         $dueDate = "+ " . $dueDate;
     }
     $this->dueDate = $dueDate;
 }
开发者ID:fuca,项目名称:sportsclub,代码行数:7,代码来源:PaymentService.php

示例4: getLabelFor

 /**
  * @param IControlConfig $controlConfig
  * @return string
  */
 public function getLabelFor(IControlConfig $controlConfig)
 {
     $label = $this->format;
     $fieldName = $controlConfig->getFieldName();
     $className = $controlConfig->getParentClassName();
     if (Nette\Utils\Strings::contains($fieldName, DotNotation\ClassMetadataWrapper::FIELD_SEPARATOR)) {
         $classMetadata = $this->classMetadataFactory->getMetadataFor($className);
         $parts = explode(DotNotation\ClassMetadataWrapper::FIELD_SEPARATOR, $fieldName);
         $fieldName = array_pop($parts);
         $association = implode(DotNotation\ClassMetadataWrapper::FIELD_SEPARATOR, $parts);
         $className = $classMetadata->getAssociationTargetClass($association);
     }
     $classParts = explode('\\', $className);
     $classParts = array_map(function ($value) {
         return lcfirst($value);
     }, $classParts);
     // Convert \NameSpace1\NameSpace2\ClassName to nameSpace1.nameSpace2.className
     $fullQualifiedClassName = trim(implode('.', $classParts), '.');
     // Convert \NameSpace1\NameSpace2\ClassName to className
     $shortClassName = end($classParts);
     $label = str_replace(self::FIELD_NAME, $fieldName, $label);
     $label = str_replace(self::CLASS_NAME, $shortClassName, $label);
     $label = str_replace(self::FULL_QUALIFIED_CLASS_NAME, $fullQualifiedClassName, $label);
     return $label;
 }
开发者ID:mike227,项目名称:n-forms,代码行数:29,代码来源:LabelGenerator.php

示例5: formatPresenterClass

 /**
  * @param $presenter
  * @return string
  */
 public function formatPresenterClass($presenter)
 {
     $class = str_replace(':', 'Module\\', $presenter) . 'Presenter';
     if (!Nette\Utils\Strings::contains($presenter, 'Kdyby')) {
         return $this->namespace . '\\' . $class;
     }
     return $class;
 }
开发者ID:peterzadori,项目名称:movi,代码行数:12,代码来源:PresenterFactory.php

示例6: getVideoSrc

 /**
  * @param  string                   $pageUrl
  * @throws InvalidVideoUrlException
  * @return string
  */
 public function getVideoSrc($pageUrl)
 {
     $key = 'watch?v=';
     if (!Strings::contains($pageUrl, $key)) {
         throw new InvalidVideoUrlException($this->translator->translate('locale.error.invalid_youtube_video_url'));
     }
     return str_replace($key, 'embed/', $pageUrl);
 }
开发者ID:CSHH,项目名称:website,代码行数:13,代码来源:Youtube.php

示例7: contains

 /**
  * Does $haystack contain $needle?
  *
  * @param string hastack
  * @param string needle
  * @param bool case sensitive?
  *
  * @return bool
  */
 public static function contains($haystack, $needle, $caseSensitive = true)
 {
     if ($caseSensitive) {
         return parent::contains($haystack, $needle);
     } else {
         return parent::contains(self::lower($haystack), self::lower($needle));
     }
 }
开发者ID:vbuilder,项目名称:utils,代码行数:17,代码来源:Strings.php

示例8: getFilter

 /**
  * @param string $type
  * @param string $name
  *
  * @return Filters\IFilter|null
  */
 public function getFilter($type, $name)
 {
     foreach ($this->filters as $serviceName => $filter) {
         if (Utils\Strings::contains($serviceName, $type . '.' . $name)) {
             return $filter;
         }
     }
     return NULL;
 }
开发者ID:ales-zrak,项目名称:assets-loader,代码行数:15,代码来源:LoaderFactory.php

示例9: isAllowed

 /**
  * Check is somethink allowed
  * @param string $role
  * @param string $resource
  * @param string $privilege
  * @return boolean
  */
 public function isAllowed($role, $resource, $privilege)
 {
     if ($resource == 'Admin' && $privilege == 'can') {
         return \Nette\Utils\Strings::contains($role, '1');
     }
     $this->checkParams($resource, $privilege);
     $this->parseRole($role);
     $this->privileges['CommentsUnder'] = $this->privileges['Comments'];
     return $this->privileges[$resource][$privilege];
 }
开发者ID:kivi8,项目名称:ars-poetica,代码行数:17,代码来源:AuthorizatorFactory.php

示例10: checkAliases

 /**
  * @param  string  $column
  * @return string
  */
 private function checkAliases($column)
 {
     if (Strings::contains($column, ".")) {
         return $column;
     }
     if (!isset($this->root_alias)) {
         $this->root_alias = $this->data_source->getRootAliases();
         $this->root_alias = current($this->root_alias);
     }
     return $this->root_alias . '.' . $column;
 }
开发者ID:romanmatyus,项目名称:datagrid,代码行数:15,代码来源:DoctrineDataSource.php

示例11: encodeDbDataType

 /**
  * @param string $dataType
  * @return string
  */
 private static function encodeDbDataType($dataType)
 {
     $dataType = Strings::lower($dataType);
     if (Strings::contains($dataType, 'int(')) {
         return PpAttribute::TYPE_NUMERIC;
     } elseif (Strings::contains($dataType, 'float') || Strings::contains($dataType, 'double') || Strings::contains($dataType, 'real')) {
         return PpAttribute::TYPE_NUMERIC;
     } else {
         return PpAttribute::TYPE_NOMINAL;
     }
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:15,代码来源:MySQLDatabase.php

示例12: check

 /**
  * check if service is running
  * @return boolean
  */
 public function check()
 {
     $result = $this->run($this->config["checkCommand"], false);
     if (empty($result)) {
         return false;
     }
     if (\Nette\Utils\Strings::contains($result, $this->config["name"]) == true) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:16,代码来源:ServiceAdmin.php

示例13: ensureCommonConfigInclude

    /**
     * Adds include of common config if it's missing.
     *
     * @param $wpConfigPath
     * @param $commonConfigName
     */
    public static function ensureCommonConfigInclude($wpConfigPath, $commonConfigName = self::COMMON_CONFIG_NAME)
    {
        $include = <<<DOC
// Configuration common to all environments
include_once __DIR__ . '/{$commonConfigName}';
DOC;
        $configContent = file_get_contents($wpConfigPath);
        if (!Strings::contains($configContent, $include)) {
            $configContent = str_replace('<?php', "<?php\n\n{$include}\n", $configContent);
            file_put_contents($wpConfigPath, $configContent);
        }
    }
开发者ID:versionpress,项目名称:versionpress,代码行数:18,代码来源:WpConfigSplitter.php

示例14: createThumb

 private function createThumb($originalFile, $targetPath, $type)
 {
     $resizeType = false;
     if (!Strings::contains($type, '_')) {
         $sizes = $type;
     } else {
         list($sizes, $resizeType) = explode('_', $type);
     }
     list($width, $height) = explode('x', $sizes);
     $image = Image::fromFile($originalFile);
     $image->resize($width, $height, $this->getResizeType($resizeType));
     $image->save($targetPath, $this->imageQuality, Image::JPEG);
     return $targetPath;
 }
开发者ID:tomaj,项目名称:nette-images,代码行数:14,代码来源:ImageService.php

示例15: __getCondition

 /**
  * @param string $value
  * @return Condition|bool
  * @throws \Exception
  * @internal
  */
 public function __getCondition($value)
 {
     if ($this->where === NULL && is_string($this->condition)) {
         list(, $from, $to) = \Nette\Utils\Strings::match($value, $this->mask);
         $from = \DateTime::createFromFormat($this->dateFormatInput, trim($from));
         $to = \DateTime::createFromFormat($this->dateFormatInput, trim($to));
         if ($to && !Strings::match($this->dateFormatInput, '/G|H/i')) {
             //input format haven't got hour option
             Strings::contains($this->dateFormatOutput[1], 'G') || Strings::contains($this->dateFormatOutput[1], 'H') ? $to->setTime(23, 59, 59) : $to->setTime(11, 59, 59);
         }
         $values = $from && $to ? array($from->format($this->dateFormatOutput[0]), $to->format($this->dateFormatOutput[1])) : NULL;
         return $values ? Condition::setup($this->getColumn(), $this->condition, $values) : Condition::setupEmpty();
     }
     return parent::__getCondition($value);
 }
开发者ID:novotnej,项目名称:grido,代码行数:21,代码来源:DateRange.php


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