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


PHP Arrays::mergeTree方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: saveConfig

 public function saveConfig()
 {
     $values = $this->data;
     $this->loadConfig();
     $data =& $this->data;
     foreach ($this->root as $item) {
         $data =& $data[$item];
     }
     $data = $data ?: array();
     $data = Arrays::mergeTree($values, $data);
     file_put_contents($this->fileName, $this->adapter->dump($this->data));
     if (function_exists('opcache_reset')) {
         opcache_reset();
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:15,代码来源:ConfigMapper.php

示例5: loadLabelExtentsionProperties

 public function loadLabelExtentsionProperties()
 {
     $params = $this->context->getParameters();
     $loader = new Nette\Config\Loader();
     $commonConfigFile = CONFIG_DIR . '/labels/labelExtensions.neon';
     $projectConfigFile = $params['projectDir'] . '/config/labels/labelExtensions.neon';
     $config = $loader->load($commonConfigFile);
     //        dump($config);
     if (is_file($projectConfigFile)) {
         $projectConfig = $loader->load($projectConfigFile);
         $config = \Nette\Utils\Arrays::mergeTree($projectConfig, $config);
     }
     //        dump($config);
     return $config;
 }
开发者ID:jurasm2,项目名称:bubo,代码行数:15,代码来源:ConfigLoader.php

示例6: __construct

	/**
	 * @param \Nette\DI\Container
	 * @param array
	 */
	public function __construct(DI\Container $context, array $configuration = array())
	{
		$this->context = $context;
		$this->configuration = \Nette\Utils\Arrays::mergeTree(array(
			'productionMode' => $context->params['productionMode'],
			'proxyDir' => $context->expand("%appDir%/proxies"),
			'proxyNamespace' => 'App\Models\Proxies',
			'entityDirs' => array($context->params['appDir'], NELLA_FRAMEWORK_DIR),
			'migrations' => array(
				'name' => \Nella\Framework::NAME . " DB Migrations",
				'table' => "db_version",
				'directory' => $context->expand("%appDir%/migrations"),
				'namespace' => 'App\Models\Migrations',
			)
		), $configuration);
	}
开发者ID:norbe,项目名称:framework,代码行数:20,代码来源:Container.php

示例7: startup

 /**
  * Startup
  */
 public function startup()
 {
     parent::startup();
     $this->basePath = $this->getBasePath();
     if ($this->name != 'Admin:Auth') {
         if (!$this->user->isLoggedIn()) {
             if ($this->user->getLogoutReason() === User::INACTIVITY) {
                 $this->flashMessage('Session timeout, you have been logged out');
             }
             $this->redirect('Auth:login', array('backlink' => $this->storeRequest()));
         } else {
             if (!$this->user->isAllowed($this->name, $this->action)) {
                 $this->flashMessage('Access denied');
                 $this->redirect('Default:');
             }
         }
     }
     // configure native components
     $adminModuleControlMap = array('~^pageMultiForm$~' => 'Components\\MultiForms', '~^[[:alnum:]]+Form$~' => 'AdminModule\\Forms', '~^[[:alnum:]]+DataGrid$~' => 'AdminModule\\DataGrids', '~^[[:alnum:]]+ConfirmDialog$~' => 'AdminModule\\Dialogs', '~^[[:alnum:]]+Sorter$~' => 'AdminModule\\Sorters');
     $this->nativeControlMap = Arrays::mergeTree($this->nativeControlMap, $adminModuleControlMap);
     $this->setupUiComponents();
 }
开发者ID:jurasm2,项目名称:bubo-sandbox,代码行数:25,代码来源:BasePresenter.php

示例8: getSummary

 /**
  * Returns count statistics of playlist
  * @return array
  */
 public function getSummary()
 {
     $summary = array("all" => 0, "approved" => 0, "waiting" => 0, "rejected" => 0);
     //Inital
     $summary = Arrays::mergeTree($this->getTable()->select("status, COUNT(status) AS score")->group("status")->fetchPairs("status", "score"), $summary);
     $summary["all"] = $this->findAll()->count();
     //All
     return $summary;
 }
开发者ID:sg3tester,项目名称:songator,代码行数:13,代码来源:SongRepository.php

示例9: __construct

 public function __construct(\Nette\Mail\IMailer $mailer, $config = [])
 {
     $this->mailer = $mailer;
     $this->config = \Nette\Utils\Arrays::mergeTree($this->config, $config);
 }
开发者ID:sg3tester,项目名称:songator,代码行数:5,代码来源:SgMailer.php

示例10: processConfig

 /**
  * Processes data from configuration file
  * @param  array $data
  * @param  bool $main
  * @return array
  * @throws FileNotFoundException
  * @throws InvalidConfigurationException
  */
 protected function processConfig(array $data, $main = TRUE)
 {
     $config = [];
     $include = [];
     if (isset($data['include'])) {
         if (is_array($data['include'])) {
             foreach ($data['include'] as $another) {
                 $include[] = $another;
             }
         } else {
             if (is_scalar($data['include'])) {
                 $include[] = $data['include'];
             }
         }
     }
     unset($data['include']);
     if ($main) {
         foreach (['vendor', 'name', 'description', 'licence', 'version'] as $key) {
             if (isset($data[$key])) {
                 $config[$key] = (string) $data[$key];
                 unset($data[$key]);
             } else {
                 throw new InvalidConfigurationException("Missing configuration {$key} in configuration.");
             }
         }
     }
     foreach ($data as $key => $value) {
         $config[$key] = $value;
     }
     foreach ($include as $another) {
         if (!file_exists($another)) {
             throw new FileNotFoundException("Config file {$another} not found.");
         }
         $config = Arrays::mergeTree($config, $this->processConfig(Neon::decode(file_get_contents($another)), FALSE));
     }
     return $config;
 }
开发者ID:phoenixcms,项目名称:core,代码行数:45,代码来源:Module.php

示例11: fetchIterator

 /**
  * @param \Venne\DataTransfer\DataTransferQuery $query
  * @return \Venne\DataTransfer\DataTransferObject[]
  */
 public function fetchIterator(DataTransferQuery $query)
 {
     $class = '\\' . trim($query->getClass(), '\\');
     $rows = $query->getValues();
     if (!class_exists($class)) {
         throw new InvalidArgumentException(sprintf('Class \'%n\' does not exist.', $class));
     }
     if (!is_subclass_of($class, 'Venne\\DataTransfer\\DataTransferObject')) {
         throw new InvalidArgumentException(sprintf('Class \'%s\' must inherit from \'Venne\\DataTransfer\\DataTransferObject\'.', $class));
     }
     if (!$query->isCacheEnabled()) {
         return new DataTransferObjectIterator($class, function () use(&$rows, $class) {
             $rows = is_callable($rows) ? Callback::invoke($rows) : $rows;
             $rowsData = array();
             foreach ($rows as $row) {
                 $rowsData[] = $this->driver->getValuesByObject($row, $class::getKeys());
             }
             return $rowsData;
         });
     }
     $cacheDependencies = $query->getCacheDependencies();
     $primaryKeysCacheKey = $this->formatPrimaryKeysCacheKey(sprintf('%s[]', $class), $query->getCacheKey());
     $primaryKeys = $this->cache->load($primaryKeysCacheKey, function (&$dependencies) use(&$rows, &$cacheDependencies, $class) {
         $rows = is_callable($rows) ? Callback::invoke($rows) : $rows;
         $primaryKeys = array();
         foreach ($rows as $row) {
             $primaryKeys[] = $this->driver->getPrimaryKeyByObject($row);
             $dependencies = Arrays::mergeTree((array) $dependencies, $this->driver->getCacheDependenciesByObject($row));
         }
         return $primaryKeys;
     });
     $loadedValues = array();
     foreach ($primaryKeys as $index => $primaryKey) {
         $loadedValues[] = $this->cache->load(array($this->formatValuesCacheKey($class, $primaryKey), $primaryKeysCacheKey), function (&$dependencies) use(&$rows, &$cacheDependencies, $class, $index) {
             $rows = is_callable($rows) ? Callback::invoke($rows) : $rows;
             $dependencies = Arrays::mergeTree((array) $dependencies, $this->driver->getCacheDependenciesByObject($rows[$index]));
             $row = $rows[$index];
             $row = is_callable($row) ? Callback::invoke($row) : $row;
             /** @var DataTransferObject $dto */
             $dto = new $class($this->driver->getValuesByObject($row, $class::getKeys()));
             return $dto->toArray();
         });
     }
     return new DataTransferObjectIterator($class, $loadedValues);
 }
开发者ID:venne,项目名称:data-transfer,代码行数:49,代码来源:DataTransferManager.php

示例12: createComponentSongList

 protected function createComponentSongList($name)
 {
     $grid = new Grid($this, $name);
     $grid->setModel($this->songy->findAll());
     $grid->addColumnDate("datum", "Datum", "d.m.y")->setSortable()->setFilterDateRange();
     $grid->addColumnText("interpret_name", "Interpret")->setCustomRender(function ($item) {
         return $item->interpret_name . ($item->interpret ? " " . Html::el('i')->addAttributes(['class' => 'fa fa-ticket', 'title' => 'Asociován s ' . $item->interpret->nazev]) : null);
     })->setSortable()->setFilterText()->setSuggestion();
     $grid->addColumnText("name", "Song")->setSortable()->setFilterText()->setSuggestion();
     $filter = array('' => 'Všechny');
     $filter = \Nette\Utils\Arrays::mergeTree($filter, $this->zanry->getList());
     $grid->addColumnText("zanr_id", "Žánr")->setCustomRender(function ($item) {
         return $item->zanr ? $item->zanr->name : null;
     })->setFilterSelect($filter);
     $grid->addColumnText("zadatel", "Přidal(a)")->setSortable()->setFilterText()->setSuggestion();
     $statuses = array('' => 'Všechny', 'approved' => 'Zařazené', 'rejected' => 'Vyřazené', 'waiting' => 'Čekající');
     $grid->addColumnText("status", "Status")->setCustomRender(function ($item) {
         $status = $item->status;
         $revizor = $item->revisor ? $item->ref("user", "revisor")->username : "neznámý";
         switch ($status) {
             case "approved":
                 return Html::el("span", array("class" => "label label-success", "title" => "Schválil(a) " . $revizor))->setText("Zařazen");
             case "waiting":
                 return Html::el("span", array("class" => "label label-warning", "title" => "Čeká ve frontě ke schválení"))->setText("Čeká");
             case "rejected":
                 return Html::el("span", array("class" => "label label-danger", "title" => "Zamítl(a) " . $revizor))->setText("Vyřazen");
             default:
                 return Html::el("i")->setText("Neznámý");
         }
     })->setSortable()->setFilterSelect($statuses);
     $grid->addColumnText("pecka", "Pecka")->setReplacement(array(0 => '', 1 => Html::el('i')->addAttributes(['class' => 'fa fa-check'])))->setFilterCheck()->setCondition(" = 1");
     $grid->addColumnText("instro", "Instro")->setReplacement(array(0 => '', 1 => Html::el('i')->addAttributes(['class' => 'fa fa-check'])))->setFilterCheck()->setCondition(" = 1");
     $grid->addColumnText("remix", "Remix")->setReplacement(array(0 => '', 1 => Html::el('i')->addAttributes(['class' => 'fa fa-check'])))->setFilterCheck()->setCondition(" = 1");
     $grid->addColumnNumber("likes", Html::el('i')->addAttributes(['class' => 'fa fa-heart']))->setCustomRender(function ($item) {
         return $item->related("song_likes")->count();
     });
     $grid->addActionHref("editor", "Editovat")->setIcon("pencil");
     $grid->addActionHref('delete', 'Smazat', 'deleteSong!')->setIcon('trash')->setConfirm('Opravdu chcete smazat tento song?');
     $grid->setFilterRenderType(Filter::RENDER_OUTER);
     $grid->setDefaultSort(array("datum" => "DESC"));
     //Set face for grid
     $gridTemplate = __DIR__ . "/../templates/components/Grid.latte";
     if (file_exists($gridTemplate)) {
         $grid->setTemplateFile($gridTemplate);
     }
     return $grid;
 }
开发者ID:sg3tester,项目名称:songator,代码行数:47,代码来源:SongPresenter.php

示例13: getGlobalMetadata

 /**
  * @param \Venne\Packages\IPackage $package
  * @return mixed
  */
 private function getGlobalMetadata(IPackage $package)
 {
     if ($this->globalMetadata === null) {
         $this->globalMetadata = array();
         foreach ($this->metadataSources as $source) {
             if (substr($source, 0, 7) == 'http://' || substr($source, 0, 8) == 'https://') {
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                 curl_setopt($ch, CURLOPT_URL, $source);
                 $data = curl_exec($ch);
             } else {
                 $data = file_get_contents($source);
             }
             if (!$data) {
                 throw new InvalidStateException(sprintf('Source \'$source\' is empty.', $source));
             }
             if ($data) {
                 $this->globalMetadata = Arrays::mergeTree($this->globalMetadata, Json::decode($data, Json::FORCE_ARRAY));
             }
         }
     }
     if (!isset($this->globalMetadata[$package->getName()])) {
         return null;
     }
     $versionProvide = new VersionConstraint('==', $this->getVersion($package));
     foreach ($this->globalMetadata[$package->getName()] as $data) {
         $versionRequire = $this->versionParser->parseConstraints($data['version']);
         if ($versionRequire->matches($versionProvide)) {
             return $data['metadata'];
         }
     }
 }
开发者ID:venne,项目名称:packages,代码行数:38,代码来源:PackageManager.php

示例14: __construct

 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     /* PREPARE DATA */
     //$pageId = $this->getPresenter()->getParam('id');
     //dump($labelId);
     $st = new \BuboApp\AdminModule\Components\SelectTraverser($this->presenter);
     $cm = $this->presenter->pageManagerService->getCurrentModule();
     $moduleConfig = $this->presenter->configLoaderService->loadModulesConfig($cm);
     $linkSelectData = array();
     if (isset($moduleConfig['modules'])) {
         foreach ($moduleConfig['modules'] as $moduleName => $module) {
             $linkSelectData[$module['title']] = $st->getSelectMenu($this->presenter['structureManager']->getLanguage(), TRUE, $moduleName);
         }
     }
     $selectData = $st->getSelectMenu($this->presenter['structureManager']->getLanguage());
     //        dump($selectData);
     //        dump($linkSelectData);
     //$this->addGroup('Obraz');
     $this->addSelect('parent', "Rodič", $selectData)->setPrompt(':: Vyberte předka ::')->setRequired('Musíte vybrat předka');
     $this['parent']->getControlPrototype()->style = 'font-family:monospace;z-index:250;font-size:12px;';
     //$this->addGroup('Vzor');
     $this->addSelect('pattern', "Vzorová stránka", $linkSelectData)->setPrompt(':: Vyberte vzorovou stránku ::')->setRequired('Musíte vybrat vzorovou stránku');
     $this['pattern']->getControlPrototype()->style = 'font-family:monospace;z-index:250;font-size:12px;';
     $moduleData = array('default' => 'Výchozí modul');
     //        if (count($moduleData) > 1) {
     //
     //            $this->addSelect('pattern_module', "Modul", $moduleData)
     //                                ->setPrompt(':: Vyberte vzorový modul ::')
     //                                ->setRequired('Musíte vybrat modul');
     //
     //        } else {
     //
     //            $this->addHidden('pattern_module', $this->presenter->pageManagerService->getCurrentModule());
     //        }
     $this->addHidden('image_module', $this->presenter->pageManagerService->getCurrentModule());
     // load templates -> get only existing and with nice names (if possible)
     $_templates = $this->presenter->projectManagerService->getListOfTemplates();
     $templateConfig = $this->presenter->configLoaderService->loadLayoutConfig();
     $res = \Nette\Utils\Arrays::mergeTree($templateConfig['layouts'], $_templates);
     $templates = array_intersect_key($res, $_templates);
     $this->addSelect('layout', 'Šablona', $templates);
     //$this->addCheckbox('create_subtree', 'Vytvořit celý podstrom');
     switch ($this->getPresenter()->getAction()) {
         case 'addLink':
             //$this->setCurrentGroup(NULL);
             $this->addSubmit('send', 'Vytvořit');
             $this->onSuccess[] = array($this, 'addformSubmited');
             break;
         case 'editLink':
             // edit
             $this->addSubmit('send', 'Uložit');
             $this->addSubmit('delete', 'Smazat')->setValidationScope(NULL);
             $image = $this->presenter->getParam('id');
             $this->addHidden('image', $image);
             $defaults = $this->presenter->pageModel->getLink($image);
             $this->setDefaults($defaults);
             $this->onSuccess[] = array($this, 'editFormSubmited');
             break;
     }
 }
开发者ID:jurasm2,项目名称:bubo-sandbox,代码行数:61,代码来源:LinkForm.php

示例15: receiveHttpData

 /**
  * Internal: receives submitted HTTP data.
  * @return array
  */
 protected function receiveHttpData()
 {
     $presenter = $this->getPresenter();
     if (!$presenter->isSignalReceiver($this, 'submit')) {
         return;
     }
     $isPost = $this->getMethod() === self::POST;
     $request = $presenter->getRequest();
     if ($request->isMethod('forward') || $request->isMethod('post') !== $isPost) {
         return;
     }
     if ($isPost) {
         return Nette\Utils\Arrays::mergeTree($request->getPost(), $request->getFiles());
     } else {
         return $request->getParameters();
     }
 }
开发者ID:cujan,项目名称:atlas-mineralov-a-hornin,代码行数:21,代码来源:Form.php


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