本文整理汇总了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;
}
示例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.");
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
}
示例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();
}
}
}
示例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';
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}