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


PHP Arrays::flatten方法代码示例

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


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

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

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

示例3: setItems

 /**
  * Sets options and option groups from which to choose.
  * @return self
  */
 public function setItems(array $items, $useKeys = TRUE)
 {
     if (!$useKeys) {
         foreach ($items as $key => $value) {
             unset($items[$key]);
             if (is_array($value)) {
                 foreach ($value as $val) {
                     $items[$key][(string) $val] = $val;
                 }
             } else {
                 $items[(string) $value] = $value;
             }
         }
     }
     $this->options = $items;
     return parent::setItems(Nette\Utils\Arrays::flatten($items, TRUE));
 }
开发者ID:cujan,项目名称:atlashornin,代码行数:21,代码来源:MultiSelectBox.php

示例4: backup

 /**
  * @param string $fileNamePrefix
  * @param bool $removeBackupFileAtTheEnd
  * @throws \Exception
  * @throws IOException
  * @return ResultObject[]
  */
 public function backup($fileNamePrefix = null, $removeBackupFileAtTheEnd = false)
 {
     $storagePath = $this->prepareStoragePath($this->backupTempPath);
     $file = new DatabaseBackupFile($storagePath);
     if (!empty($fileNamePrefix)) {
         $file->setNamePrefix($fileNamePrefix);
     }
     $this->mysqlDump->save($file->getFilePath());
     $resultObjects = [];
     /** @var IDatabaseBackupHandler $handler */
     foreach ($this->backupHandlers as $handler) {
         $results = $handler->process($file);
         $resultObjects = array_merge($resultObjects, $results);
     }
     if ($removeBackupFileAtTheEnd === true) {
         $this->removeBackupFile($file);
     }
     return Arrays::flatten($resultObjects);
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:26,代码来源:DatabaseBackup.php

示例5: setItems

 /**
  * Sets options and option groups from which to choose.
  *
  * @return self
  */
 public function setItems(array $items, $useKeys = TRUE)
 {
     if (!$useKeys) {
         $res = array();
         foreach ($items as $key => $value) {
             unset($items[$key]);
             if (is_array($value)) {
                 foreach ($value as $val) {
                     $res[$key][(string) $val] = $val;
                 }
             } else {
                 $res[(string) $value] = $value;
             }
         }
         $items = $res;
     }
     $this->options = $items;
     return ChoiceControl::setItems(Arrays::flatten($items, TRUE));
 }
开发者ID:webchemistry,项目名称:forms-controls,代码行数:24,代码来源:SelectBox.php

示例6: addWhereComposition

 protected function addWhereComposition(array $columns, array $parameters)
 {
     if ($this->driver->isSupported(ISupplementalDriver::SUPPORT_MULTI_COLUMN_AS_OR_COND)) {
         $conditionFragment = '(' . implode(' = ? AND ', $columns) . ' = ?) OR ';
         $condition = substr(str_repeat($conditionFragment, count($parameters)), 0, -4);
         return $this->addWhere($condition, Nette\Utils\Arrays::flatten($parameters));
     } else {
         return $this->addWhere('(' . implode(', ', $columns) . ') IN', $parameters);
     }
 }
开发者ID:ricco24,项目名称:database,代码行数:10,代码来源:SqlBuilder.php

示例7: getPanel

    /**
     * Renders HTML code for custom panel.
     *
     * @return string
     */
    public function getPanel()
    {
        $h = 'htmlSpecialChars';
        $panel = array();
        if (!empty($this->untranslated)) {
            $panel[] = $this->renderUntranslated();
        }
        if (!empty($this->onRequestLocaleSnapshot)) {
            if (!empty($panel)) {
                $panel[] = '<br><br>';
            }
            $panel[] = '<h2>Locale resolution</h2>';
            $panel[] = '<p>Order of locale resolvers and final locale for each request</p>';
            foreach ($this->onRequestLocaleSnapshot as $i => $snapshot) {
                $s = $i > 0 ? '<br>' : '';
                /** @var Request[] $snapshot */
                $params = $snapshot['request']->getParameters();
                $s .= '<tr><th width="10px">&nbsp;</th>' . '<th>' . $h($snapshot['request']->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : '')) . '</th>' . '<th>' . $h($snapshot['locale']) . '</th></tr>';
                $l = 1;
                foreach ($snapshot['resolvers'] as $name => $resolvedLocale) {
                    $s .= '<tr><td>' . $l++ . '.</td><td>' . $h($name) . '</td><td>' . $h($resolvedLocale) . '</td></tr>';
                }
                $panel[] = '<table style="width:100%">' . $s . '</table>';
            }
        }
        if (!empty($this->resources)) {
            if (!empty($panel)) {
                $panel[] = '<br><br>';
            }
            $panel[] = '<h2>Loaded resources</h2>';
            $panel[] = $this->renderResources($this->resources);
        }
        if (!empty($this->ignoredResources)) {
            if (!empty($panel)) {
                $panel[] = '<br><br>';
            }
            $panel[] = '<h2>Ignored resources</h2>';
            $panel[] = '<p>Whitelist config: ' . implode(', ', array_map($h, $this->localeWhitelist)) . '</p>';
            $panel[] = $this->renderResources($this->ignoredResources);
        }
        return empty($panel) ? '' : '<h1>Missing translations: ' . count(array_unique($this->untranslated)) . ', Resources: ' . count(Nette\Utils\Arrays::flatten($this->resources)) . '</h1>' . '<div class="nette-inner tracy-inner kdyby-TranslationPanel" style="min-width:500px">' . implode($panel) . '</div>' . '<style>
				#nette-debug .kdyby-TranslationPanel h2,
				#tracy-debug .kdyby-TranslationPanel h2 {font-size: 23px;}
			</style>';
    }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:50,代码来源:Panel.php

示例8: SongProvider

file_put_contents($sessionFile, Json::encode($storedData));
//end of security check
$songProvider = new SongProvider($host, $dbName, $username, $password, $songsDirectory, $webSongsDir, $port);
$msg = $_GET['request'];
if ($msg == 'getSongs') {
    $songData['songs'] = $songProvider->readNonProcessedSongs();
} else {
    if ($msg == 'emptyQueue') {
        $currentGenreId = file_get_contents($currentGenreFile);
        $songData['songs'] = [$songProvider->getRandomSong($currentGenreId)];
        //abych měl jednoprvkové pole
    }
}
$songData['request'] = $msg;
$data = null;
try {
    $data = Json::encode($songData);
} catch (JsonException $e) {
    //	$songs = $songData['songs'];
    //	$songsString = '';
    //	/** @var Song $song */
    //	foreach ($songs as $song) {
    //		$songData
    //	}
    $logger = new Logger();
    $fileWriter = new Stream("log.txt");
    $logger->addWriter($fileWriter);
    $logger->err("Json encoding failed: reason:" . $e->getMessage());
    $logger->err('data: ' . implode(', ', Arrays::flatten($songData)));
}
echo $data;
开发者ID:ParalelniPolis,项目名称:bitcoinJukebox,代码行数:31,代码来源:ajax.php

示例9: processMetadataDriver

 /**
  * @param \Nette\DI\ServiceDefinition $metadataDriver
  * @param string $namespace
  * @param string|object $driver
  * @param string $prefix
  * @throws \Nette\Utils\AssertionException
  * @return string
  */
 protected function processMetadataDriver(Nette\DI\ServiceDefinition $metadataDriver, $namespace, $driver, $prefix)
 {
     if (!is_string($namespace) || !Strings::match($namespace, '#^' . self::PHP_NAMESPACE . '\\z#')) {
         throw new Nette\Utils\AssertionException("The metadata namespace expects to be valid namespace, {$namespace} given.");
     }
     $namespace = ltrim($namespace, '\\');
     if (is_string($driver) || is_array($driver)) {
         $paths = is_array($driver) ? $driver : array($driver);
         foreach ($paths as $path) {
             if (($pos = strrpos($path, '*')) !== FALSE) {
                 $path = substr($path, 0, $pos);
             }
             if (!file_exists($path)) {
                 throw new Nette\Utils\AssertionException("The metadata path expects to be an existing directory, {$path} given.");
             }
         }
         $driver = new Statement(self::ANNOTATION_DRIVER, is_array($paths) ? $paths : array($paths));
     }
     $impl = $driver instanceof \stdClass ? $driver->value : ($driver instanceof Statement ? $driver->entity : (string) $driver);
     list($driver) = CacheHelpers::filterArgs($driver);
     /** @var Statement $driver */
     if (isset($this->metadataDriverClasses[$impl])) {
         $driver->entity = $this->metadataDriverClasses[$impl];
     }
     if (is_string($driver->entity) && substr($driver->entity, 0, 1) === '@') {
         $metadataDriver->addSetup('addDriver', array($driver->entity, $namespace));
         return $driver->entity;
     }
     if ($impl === self::ANNOTATION_DRIVER) {
         $driver->arguments = array(Nette\Utils\Arrays::flatten($driver->arguments), 2 => $this->prefix('@cache.' . $prefix . '.metadata'));
     }
     $serviceName = $this->prefix($prefix . '.driver.' . str_replace('\\', '_', $namespace) . '.' . str_replace('\\', '_', $impl) . 'Impl');
     $this->getContainerBuilder()->addDefinition($serviceName)->setClass('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver')->setFactory($driver->entity, $driver->arguments)->setAutowired(FALSE)->setInject(FALSE);
     $metadataDriver->addSetup('addDriver', array('@' . $serviceName, $namespace));
     return '@' . $serviceName;
 }
开发者ID:psyrny,项目名称:Doctrine,代码行数:44,代码来源:OrmExtension.php

示例10: setItems

 /**
  * Sets options
  *
  * @return self
  */
 public function setItems(array $items, $useKeys = TRUE)
 {
     $imageItems = $this->getImageItems($items);
     return parent::setItems(Arrays::flatten($imageItems, TRUE));
 }
开发者ID:radekdostal,项目名称:nette-imageselectbox,代码行数:10,代码来源:ImageSelectBox.php

示例11: getPanel

 /**
  * Renders HTML code for custom panel.
  *
  * @return string
  */
 public function getPanel()
 {
     if (!$this->renderPanel) {
         return '';
     }
     if (empty($this->events)) {
         return NULL;
     }
     $visited = array();
     $h = 'htmlspecialchars';
     $s = '';
     $s .= $this->renderPanelDispatchLog($visited);
     $s .= $this->renderPanelEvents($visited);
     $s .= $this->renderPanelListeners($visited);
     if ($s) {
         $s .= '<tr class="blank"><td colspan=2>&nbsp;</td></tr>';
     }
     $s .= $this->renderPanelDispatchTree();
     $totalEvents = count($this->listenerIds);
     $totalListeners = count(array_unique(Arrays::flatten($this->listenerIds)));
     return '<style>' . $this->renderStyles() . '</style>' . '<h1>' . $h($totalEvents) . ' registered events, ' . $h($totalListeners) . ' registered listeners</h1>' . '<div class="nette-inner tracy-inner nette-KdybyEventsPanel"><table>' . $s . '</table></div>';
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:27,代码来源:Panel.php

示例12: getLoadedEntities

 /**
  * @return object[]
  */
 private function getLoadedEntities()
 {
     $em = $this->getEntityManager();
     $UoW = $em->getUnitOfWork();
     $im = $UoW->getIdentityMap();
     return array_merge($UoW->getScheduledEntityDeletions(), $UoW->getScheduledEntityInsertions(), !empty($im[$this->_entityName]) ? Arrays::flatten($im[$this->_entityName]) : array());
 }
开发者ID:Richmond77,项目名称:learning-nette,代码行数:10,代码来源:EntityDao.php

示例13: indexAction

 public function indexAction()
 {
     $upload_id = (int) $this->getParam('id');
     // Grab the submission information (Which includes the uploader's info and comments)
     $upload = Upload::find($upload_id);
     if (!$upload instanceof Upload) {
         throw new \FA\Exception('Upload not found!');
     }
     $view = $this->view;
     $view->upload = $upload;
     $view->is_favorited = false ? '+Favorite' : '-Favorite';
     $view->comment_csrf_str = $this->csrf->generate('_upload_comments');
     $view->upload_csrf_str = $this->csrf->generate('_upload_content');
     $view->file_mime = $upload->getMIME();
     $view->keyword_arr = $upload->getKeywords();
     $view->created_at = \FA\Utilities::fa_date_format($upload->created_at, $upload->user->getTimezoneDiff());
     if ($this->user != NULL) {
         // Determine if the user is the owner of the upload
         $view->is_owner = $upload->user->id == $this->user->id;
         // Get if the user prefer fullview first
         $view->fullview = $this->user->fullview ? 'true' : 'false';
         // Apparently, Volt doesn't seem to want convert straight to string
     }
     // Comments!
     // Create the comment forms
     $form_config = $this->current_module_config->forms->upload_comment->toArray();
     $form_config['action'] = $this->url->named('upload_view', array('id' => $upload->id)) . '/comment/new';
     // Add the action so they can actually comment!
     $view->comment_form = new \FA\Form($form_config);
     // Reply form. Uses the same config, but different id.
     $form_config['action'] = '';
     // No need for this.
     $form_config['id'] = 'reply_form';
     $view->reply_form = new \FA\Form($form_config);
     // Edit form. Same story.
     $form_config['id'] = 'edit_form';
     $view->edit_form = new \FA\Form($form_config);
     // Construct the comments
     $comment_ents = \Entity\UploadComment::getRepository()->findBy(array('upload_id' => $upload->id), array('id' => 'DESC'));
     // TODO: Move to CommentTrait for a more global use
     // Initialize our upload comment array
     $up_comments = array();
     foreach ($comment_ents as $comment) {
         // Get the comment's parents
         $parent_path = array_reverse($comment->getParentPath());
         // Map the array, creating new arrays along the way
         $results = self::_mapArray($parent_path, array($comment), 'a');
         // Merge our new array with our overall one!
         $up_comments = array_merge_recursive($results, $up_comments);
     }
     // Flatten the array to allow Volt to run through it without issue
     $view->upload_comments = \Nette\Utils\Arrays::flatten($up_comments);
     // Only need to do these when users with access need to see these stats.
     if ($this->acl->isAllowed('administer all')) {
         $view->total_deleted_comments = 0;
         $view->total_deleted_comments_by_admin = 0;
         $view->total_deleted_comments_by_uploader = 0;
         $view->total_deleted_comments_by_poster = 0;
         // Get the total comments deleted
         foreach ($comment_ents as $comment) {
             $deleting_user = $comment->deleting_user;
             if ($deleting_user != NULL) {
                 // Post has been deleted
                 $view->total_deleted_comments++;
                 // Determine who deleted it!
                 if ($deleting_user->id == $comment->user_id) {
                     // Poster deleted it!
                     $view->total_deleted_comments_by_poster++;
                 } elseif ($deleting_user->id == $upload->user . id) {
                     // Uploader deleted it!
                     $view->total_deleted_comments_by_uploader++;
                 } elseif ($this->acl->userAllowed('administer all', $deleting_user)) {
                     // Admin deleted it!
                     $view->total_deleted_comments_by_admin++;
                 }
             }
         }
     }
     // Grab the EXIF info (If any) and pass it to the view
     // TODO: Will need to determine if we need to include more or less information
     //$exif = exif_read_data($upload->getFullPath(), 'EXIF');
     //$view->exif_info = ($exif ? $exif : '');
     // Legacy stuff
     // TODO: Move this off to either ACL or some other config. Most if not all is controller specific
     $view->edit_duration_sec = \Entity\UploadComment::getEditDuration();
     $view->STATIC_ASSET_MODIFICATION_DATE = self::STATIC_ASSET_MODIFICATION_DATE;
     // Assuming this is for versioning.
 }
开发者ID:einstein95,项目名称:FAOpen,代码行数:88,代码来源:UploadController.php

示例14: loadIsAdminMember

 /**
  * @param array $userData
  * @return bool
  */
 protected function loadIsAdminMember(array $userData)
 {
     $flatten = Arrays::flatten($userData['memberOf']);
     $isAdmin = false;
     foreach ($this->config['adminGroups'] as $one) {
         $isAdmin = $isAdmin || in_array($one, $flatten);
     }
     return $isAdmin;
 }
开发者ID:foglcz,项目名称:ldap-authenticator,代码行数:13,代码来源:Authenticator.php


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