• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Utils\Arrays类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

 /**
  * @param array $args
  * @return int
  */
 public function run(array $args = [])
 {
     /** @var ICollection|Addon[] $addons */
     $addons = $this->addonRepository->findBowers();
     // DO YOUR JOB ===============================================
     $counter = 0;
     foreach ($addons as $addon) {
         // Skip addon with bad data
         if ($extra = $addon->github->extra) {
             if ($bower = $extra->get('bower', FALSE)) {
                 // Create bower entity if not exist
                 if (!$addon->bower) {
                     $addon->bower = new Bower();
                 }
                 // Downloads
                 if ($stats = $this->bower->repo($bower['name'])) {
                     $addon->bower->downloads = Arrays::get($stats, ['hits'], 0);
                 }
                 // Keywords
                 $keywords = Arrays::get($bower, 'keywords', []);
                 $addon->bower->keywords = $keywords ? implode(',', $keywords) : NULL;
                 // Persist
                 $this->addonRepository->persistAndFlush($addon);
                 // Increase counting
                 $counter++;
             } else {
                 $this->log('Skip (bower) [no bower data]: ' . $addon->fullname);
             }
         } else {
             $this->log('Skip (bower) [no extra data]: ' . $addon->fullname);
         }
     }
     return $counter;
 }
开发者ID:milo,项目名称:componette.com,代码行数:38,代码来源:UpdateBowerTask.php


示例2: loadHttpData

 /**
  * Loads HTTP data.
  *
  * @return void
  */
 public function loadHttpData()
 {
     $path = $this->getHtmlName();
     // img_x or img['x']
     $path = explode('[', strtr(str_replace(']', '', strpos($path, '[') === false ? $path . '.x' : substr($path, 0, -2)), '.', '_'));
     $this->setValue(Nette\Utils\Arrays::get($this->getForm()->getHttpData(), $path, null));
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:12,代码来源:ImageButton.php


示例3: loadConfiguration

 public function loadConfiguration()
 {
     $container = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $entities = $collections = array();
     foreach ($config['entity'] as $domain => $entity) {
         $service = $container->addDefinition($entities[$domain] = $this->prefix($domain . '.entity'));
         Compiler::parseService($service, $entity);
         $service->setClass('NiceORM\\Entity')->setParameters(array('data' => NULL))->setShared(FALSE);
         $container->addDefinition($collections[$domain] = $this->prefix($domain . '.collection'))->setClass('NiceORM\\ICollection')->setFactory('NiceORM\\TableCollection', array($domain, '%data%'))->setParameters(array('data'))->setShared(FALSE);
     }
     $fields = $refs = $related = array();
     foreach ($config['tables'] as $domain => $table) {
         $fields[$domain] = $refs[$domain] = $related[$domain] = array();
         foreach (Arrays::get($config['fields'], $domain, array()) as $name => $column) {
             $fields[$domain][is_int($name) ? $column : $name] = $column;
         }
         foreach (Arrays::get($config['relations'], $domain, array()) as $name => $column) {
             if (is_int($name)) {
                 $refs[$domain][$column] = array($column, NULL, $column);
             } else {
                 $column = array_values((array) $column);
                 switch (count($column)) {
                     case 0:
                         $refs[$domain][$name] = array($name, NULL, $name);
                         break;
                     case 1:
                         $refs[$domain][$name] = array($name, $column[0], $name);
                         break;
                     case 2:
                         $refs[$domain][$name] = array($column[0], $column[1], $name);
                         break;
                     default:
                         $refs[$domain][$name] = array($column[0], $column[1], $column[2]);
                 }
             }
         }
     }
     foreach ($refs as $domain => $tableRefs) {
         foreach ($tableRefs as $name => $ref) {
             list($table, $column, $type) = $ref;
             if ($type === $name || empty($related[$type][$domain . 's'])) {
                 $related[$type][$domain . 's'] = array($config['tables'][$domain], $column, $domain);
             } elseif (!isset($refs[$domain][$type])) {
                 unset($related[$type][$domain . 's']);
             }
             $related[$type][$domain . 's:' . $name] = array($config['tables'][$domain], $column, $domain);
         }
     }
     $mappers = $accessors = array();
     foreach ($config['tables'] as $domain => $table) {
         $mapper = $container->addDefinition($mappers[$domain] = $this->prefix($domain . '.mapper'))->setClass('NiceORM\\ActiveRowMapper', array($domain, $table, $fields[$domain], $refs[$domain], $related[$domain]));
         $container->addDefinition($accessors[$domain] = $this->prefix($domain . '.accessor'))->setClass('NiceORM\\ActiveRowAccessor', array('%data%', $mapper))->setParameters(array('data'))->setShared(FALSE);
     }
     $entityFactory = $container->addDefinition($this->prefix('entityFactory'))->setClass('NiceORM\\DIEntityFactory', array($entities));
     $collectionFactory = $container->addDefinition($this->prefix('collectionFactory'))->setClass('NiceORM\\DICollectionFactory', array($collections));
     $accessorFactory = $container->addDefinition($this->prefix('accessorFactory'))->setClass('NiceORM\\DIAccessorFactory', array($accessors));
     $mapperAccessor = $container->addDefinition($this->prefix('mapperAccessor'))->setClass('NiceORM\\DIMapperAccessor', array($mappers));
     $container->addDefinition($this->prefix('manager'))->setClass('NiceORM\\Manager')->setFactory('NiceORM\\Manager', array($entityFactory, $collectionFactory, $accessorFactory, $mapperAccessor));
 }
开发者ID:redwormik,项目名称:niceorm,代码行数:60,代码来源:NiceORMExtension.php


示例4: loadConfigFiles

 /**
  * @param Configurator $configurator
  */
 protected function loadConfigFiles(Configurator $configurator)
 {
     if ($this->autoloadConfig === TRUE || is_array($this->autoloadConfig)) {
         $scanDirs = $this->autoloadConfig === TRUE ? [$this->appDir] : $this->autoloadConfig;
         $cache = $this->createCache();
         $files = $cache->load(self::CACHE_NAMESPACE);
         if ($files === NULL) {
             $files = [0 => []];
             foreach (Finder::findFiles('*.neon')->from($scanDirs) as $path => $file) {
                 $content = Neon::decode(file_get_contents($path));
                 if (!is_array($content) || !array_key_exists('autoload', $content)) {
                     continue;
                 }
                 $autoload = Arrays::get($content, ['autoload', 0], FALSE);
                 if ($autoload === FALSE) {
                     continue;
                 }
                 $autoload = is_int($autoload) ? $autoload : 0;
                 if (!isset($files[$autoload])) {
                     $files[$autoload] = [];
                 }
                 $files[$autoload][] = $path;
             }
             $cache->save(self::CACHE_NAMESPACE, $files);
         }
         foreach ($files as $priorityFiles) {
             foreach ($priorityFiles as $config) {
                 $configurator->addConfig($config);
             }
         }
     }
     foreach ($this->configs as $config) {
         $configurator->addConfig($config);
     }
 }
开发者ID:zaxcms,项目名称:framework,代码行数:38,代码来源:ZaxBootstrap.php


示例5: load

 /**
  * Reads configuration from NEON file.
  * @param  string  file name
  * @return array
  * @throws Nette\InvalidStateException
  */
 public static function load($file)
 {
     if (!is_file($file) || !is_readable($file)) {
         throw new Nette\FileNotFoundException("File '{$file}' is missing or is not readable.");
     }
     $neon = Neon::decode(file_get_contents($file));
     $separator = trim(self::$sectionSeparator);
     $data = array();
     foreach ($neon as $secName => $secData) {
         if ($secData === NULL) {
             // empty section
             $secData = array();
         }
         if (is_array($secData)) {
             // process extends sections like [staging < production]
             $parts = $separator ? explode($separator, $secName) : array($secName);
             if (count($parts) > 1) {
                 $parent = trim($parts[1]);
                 if (!isset($data[$parent]) || !is_array($data[$parent])) {
                     throw new Nette\InvalidStateException("Missing parent section '{$parent}' in file '{$file}'.");
                 }
                 $secData = array_reverse(Nette\Utils\Arrays::mergeTree(array_reverse($secData, TRUE), array_reverse($data[$parent], TRUE)), TRUE);
                 $secName = trim($parts[0]);
                 if ($secName === '') {
                     throw new Nette\InvalidStateException("Invalid empty section name in file '{$file}'.");
                 }
             }
         }
         $data[$secName] = $secData;
     }
     return $data;
 }
开发者ID:kovkus,项目名称:r-cms,代码行数:38,代码来源:NeonAdapter.php


示例6: processFiles

 /**
  *
  * @param array $files
  * @param array $names Array of indexes of $files array representing current nesting level. E.g. if we are iterating over $files[k1][k2] then $names=[k1,k2]
  */
 private function processFiles(array $files, array $names = [])
 {
     foreach ($files as $name => $controlValue) {
         $names[] = $name;
         // MFU sends data in this format:
         //
         // array(
         //	"token" => "blablabla",
         //	"files" => array(
         //		0 => FileUpload(...),
         //		...
         //	)
         // )
         // expanded POST array with $names indexes
         $postFromHttpRequest = $this->httpRequest->getPost();
         $postArr = Arrays::getRef($postFromHttpRequest, $names);
         $isFormMFU = (is_array($controlValue) and isset($controlValue["files"]) and isset($postArr['token']));
         if ($isFormMFU) {
             $token = $postArr["token"];
             foreach ($controlValue["files"] as $file) {
                 self::processFile($token, $file);
             }
             // support for nested Nette\Forms\Container
         } elseif (is_array($controlValue)) {
             $this->processFiles($controlValue, $names);
         }
         // skip files not processed by MFU
         // they will be processed by Nette Forms
     }
 }
开发者ID:jkuchar,项目名称:multiplefileupload,代码行数:35,代码来源:Controller.php


示例7: addTags

 public function addTags($type, array $tags)
 {
     $tags = Nette\Utils\Arrays::normalize($tags, TRUE);
     foreach ($this->findByType($type) as $def) {
         $def->setTags($def->getTags() + $tags);
     }
 }
开发者ID:sallyx,项目名称:di,代码行数:7,代码来源:DecoratorExtension.php


示例8: getHttpData

 /**
  * @return mixed|NULL
  */
 private function getHttpData()
 {
     if ($this->http_post === NULL) {
         $path = explode(self::NAME_SEPARATOR, $this->lookupPath('Nette\\Forms\\Form'));
         $this->http_post = Nette\Utils\Arrays::get($this->getForm()->getHttpData(), $path, NULL);
     }
     return $this->http_post;
 }
开发者ID:ublaboo,项目名称:datagrid,代码行数:11,代码来源:ItemDetailForm.php


示例9: translate

 /**
  * @param string $message
  * @param int $count
  * @return string
  */
 function translate($message, $count = 0)
 {
     if (substr($message, 0, 5) != "book.") {
         return "";
     }
     $this->loadTexts();
     return Arrays::get($this->texts, substr($message, 5), "");
 }
开发者ID:konecnyjakub,项目名称:book-component,代码行数:13,代码来源:Translator.php


示例10: changeEmptyStringsToNull

 /**
  * @param array $values
  * @param array $entityProperties
  */
 protected function changeEmptyStringsToNull(array &$values, array $entityProperties = [])
 {
     foreach ($entityProperties as $property) {
         if ($property->getType() == 'string' and $property->isNullable()) {
             Arrays::renameKey($values, $property->getName(), $property->getName() . '%sN');
         }
     }
 }
开发者ID:blitzik,项目名称:vycetky,代码行数:12,代码来源:BaseRepository.php


示例11: get

 /**
  * @param string $name
  * @param mixed $default
  * @return mixed
  */
 public function get($name, $default = NULL)
 {
     if (func_num_args() > 1) {
         return Arrays::get($this->parameters, $name, $default);
     } else {
         return Arrays::get($this->parameters, $name);
     }
 }
开发者ID:minetro,项目名称:micro-core,代码行数:13,代码来源:Parameters.php


示例12: loadHttpData

 /**
  * Loads HTTP data.
  * @return void
  */
 public function loadHttpData()
 {
     $path = \explode('[', \strtr(\str_replace(array('[]', ']'), '', $this->getHtmlName()), '.', '_'));
     $origValue = Arrays::get($this->getForm()->getHttpData(), $path);
     $from = isset($origValue['from']) ? $origValue['from'] : '';
     $to = isset($origValue['to']) ? $origValue['to'] : '';
     $value = array('from' => $from, 'to' => $to);
     $this->setValue($value);
 }
开发者ID:bazo,项目名称:translation-ui,代码行数:13,代码来源:multipleDateField.php


示例13: beforeCompile

 public function beforeCompile()
 {
     $builder = $this->getContainerBuilder();
     $connection = $builder->getDefinition('movi.connection');
     foreach (array_keys($builder->findByTag(self::FILTER_TAG)) as $filter) {
         $def = $builder->getDefinition($filter);
         $tags = Arrays::mergeTree($def->tags, $this->defaults);
         $connection->addSetup('registerFilter', [$tags['name'], ['@' . $filter, $tags['callback']], !empty($tags['wire']) ? $tags['wire'] : NULL]);
     }
 }
开发者ID:peterzadori,项目名称:movi,代码行数:10,代码来源:FiltersExtension.php


示例14: getCsrfToken

 /**
  * Returns unique token for method and params
  * @param  string $control
  * @param  string $method
  * @param  array $params
  * @return string
  */
 public function getCsrfToken($control, $method, $params)
 {
     $session = $this->getSession('Nextras.Application.UI.SecuredLinksPresenterTrait');
     if (!isset($session->token)) {
         $session->token = Nette\Utils\Random::generate();
     }
     $params = Nette\Utils\Arrays::flatten($params);
     $params = implode('|', array_keys($params)) . '|' . implode('|', array_values($params));
     return substr(md5($control . $method . $params . $session->token . $this->getSession()->getId()), 0, 8);
 }
开发者ID:adambisek,项目名称:secured-links,代码行数:17,代码来源:SecuredLinksPresenterTrait.php


示例15: getData

 /**
  * @param \SplFileInfo $package
  * @return array
  * @throws \movi\FileNotFoundException
  */
 private function getData(\SplFileInfo $package)
 {
     $file = $package->getPathname() . '/' . self::PACKAGE_FILE;
     if (!file_exists($file) || !is_readable($file)) {
         throw new FileNotFoundException("JSON file for package '" . $package->getFilename() . "' was not found or is not readable.");
     }
     $data = Json::decode(file_get_contents($file), Json::FORCE_ARRAY);
     $data['dir'] = $package->getPathname();
     return Arrays::mergeTree($data, $this->defaults);
 }
开发者ID:peterzadori,项目名称:movi,代码行数:15,代码来源:Loader.php


示例16: expand

	/**
	 * Expands %placeholders%.
	 * @param  mixed
	 * @param  array
	 * @param  bool
	 * @return mixed
	 * @throws Nette\InvalidArgumentException
	 */
	public static function expand($var, array $params, $recursive = FALSE)
	{
		if (is_array($var)) {
			$res = array();
			foreach ($var as $key => $val) {
				$res[$key] = self::expand($val, $params, $recursive);
			}
			return $res;

		} elseif ($var instanceof \stdClass || $var instanceof Statement) {
			$res = clone $var;
			foreach ($var as $key => $val) {
				$res->$key = self::expand($val, $params, $recursive);
			}
			return $res;

		} elseif (!is_string($var)) {
			return $var;
		}

		$parts = preg_split('#%([\w.-]*)%#i', $var, -1, PREG_SPLIT_DELIM_CAPTURE);
		$res = '';
		foreach ($parts as $n => $part) {
			if ($n % 2 === 0) {
				$res .= $part;

			} elseif ($part === '') {
				$res .= '%';

			} elseif (isset($recursive[$part])) {
				throw new Nette\InvalidArgumentException(sprintf('Circular reference detected for variables: %s.', implode(', ', array_keys($recursive))));

			} else {
				try {
					$val = Nette\Utils\Arrays::get($params, explode('.', $part));
				} catch (Nette\InvalidArgumentException $e) {
					throw new Nette\InvalidArgumentException("Missing parameter '$part'.", 0, $e);
				}
				if ($recursive) {
					$val = self::expand($val, $params, (is_array($recursive) ? $recursive : array()) + array($part => 1));
				}
				if (strlen($part) + 2 === strlen($var)) {
					return $val;
				}
				if (!is_scalar($val)) {
					throw new Nette\InvalidArgumentException("Unable to concatenate non-scalar parameter '$part' into '$var'.");
				}
				$res .= $val;
			}
		}
		return $res;
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:60,代码来源:Helpers.php


示例17: checkType

 /**
  * Ověří mimetype předaného souboru.
  * @param \Nette\Http\FileUpload $file Nahraný soubor k ověření.
  * @return bool Má soubor správný mimetype?
  */
 public function checkType(\Nette\Http\FileUpload $file)
 {
     if (\Nette\Utils\Arrays::searchKey($this->getMimeTypes(), $file->getContentType()) !== FALSE) {
         return TRUE;
     } else {
         // Pokud se nepodaří ověřit mimetype, ověříme alespoň koncovku.
         if (array_search($this->getExtension($file->getName()), array_unique($this->getMimeTypes())) !== FALSE) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
 }
开发者ID:jzechy,项目名称:jquery-fileupload,代码行数:18,代码来源:BaseFilter.php


示例18: prepareRecipients

 /**
  * @param User $sender
  * @param array $usersByRestrictions
  * @return array
  */
 private function prepareRecipients(User $sender, array $usersByRestrictions)
 {
     if (empty($usersByRestrictions)) {
         return [];
     }
     unset($usersByRestrictions['suspendedUsers'][$sender->getId()], $usersByRestrictions['activeUsers'][$sender->getId()]);
     if (!$this->authorizator->isAllowed($sender, 'message', 'send_to_restricted_recipients')) {
         $recipients = array_diff_key($usersByRestrictions['activeUsers'], $usersByRestrictions['suspendedUsers'], $usersByRestrictions['usersBlockedByMe'], $usersByRestrictions['usersBlockingMe']);
     } else {
         $recipients = $usersByRestrictions['activeUsers'] + $usersByRestrictions['usersBlockedByMe'] + $usersByRestrictions['usersBlockingMe'];
     }
     return Arrays::associate($recipients, 'id=username');
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:18,代码来源:RecipientsSelectBoxFactory.php


示例19: formatTemplateFiles

 public function formatTemplateFiles(Presenter $presenter)
 {
     $name = $presenter->getName();
     $view = $presenter->view;
     $_presenter = substr($name, strrpos(':' . $name, ':'));
     $directories = $this->getAdjustedDirectories($presenter);
     $list = array();
     foreach ($directories as $dir) {
         $list[] = $this->getTemplateFiles("{$dir}/presenters", $_presenter, $view);
         $list[] = $this->getTemplateFiles($dir, $_presenter, $view);
     }
     return Arrays::flatten($list);
 }
开发者ID:rixxi,项目名称:template-locator,代码行数:13,代码来源:PriorityTemplateLocator.php


示例20: send

 /**
  * @return array
  */
 public function send(IMessage $message)
 {
     try {
         $response = $this->client->send(sprintf('%s/%s.%s', $this->config->getEndpointUrl(), $message->getEndpointName(), $this->config->getFormat()), $this->config->getApiKey(), $message->getParams());
     } catch (\Exception $e) {
         throw new ClientException('There was an error while contacting the Mandrill API.', NULL, $e);
     }
     $answer = $this->getAdapter($this->config->getFormat())->process($response);
     if ($response->getStatusCode() !== 200 || !Arrays::isList($answer)) {
         throw new MandrillException(sprintf('%s: %s', isset($answer['name']) ? $answer['name'] : self::UNKNOWN_ERROR_NAME, isset($answer['message']) ? $answer['message'] : self::UNKNOWN_ERROR_MESSAGE), isset($answer['code']) ? $answer['code'] : self::UNKNOWN_ERROR_CODE);
     }
     return $answer;
 }
开发者ID:lookyman,项目名称:mandrill,代码行数:16,代码来源:Mandrill.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Utils\Callback类代码示例发布时间:2022-05-23
下一篇:
PHP Security\User类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap