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


PHP Utils\Arrays类代码示例

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


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


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