本文整理汇总了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>"; }';
}
示例2: checkAliases
private function checkAliases($column)
{
if (Strings::contains($column, ".")) {
return $column;
}
return current($this->data_source->getRootAliases()) . '.' . $column;
}
示例3: setDefaultDueDate
public function setDefaultDueDate($dueDate)
{
if (!\Nette\Utils\Strings::contains($dueDate, "+")) {
$dueDate = "+ " . $dueDate;
}
$this->dueDate = $dueDate;
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
}
示例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;
}
示例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];
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}