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


PHP array_replace_recursive函数代码示例

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


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

示例1: makeOptions

 public function makeOptions($siteOptions, $compressOptions)
 {
     foreach ($compressOptions as $key => $value) {
         $compressOptions[$key] = true;
     }
     $this->curOptions = array_replace_recursive($this->defaultOptions, array("site" => $siteOptions, "compress" => $compressOptions));
 }
开发者ID:saviobosco,项目名称:lobby,代码行数:7,代码来源:class.site-compressor.php

示例2: init

 /**
  * Set up application environment
  *
  * This sets up the PHP environment, loads the provided module and returns
  * the MVC application.
  *
  * @param string $module Module to load
  * @param bool $addTestConfig Add config for test environment (enable all debug options, no config file)
  * @param array $applicationConfig Extends default application config
  * @return \Zend\Mvc\Application
  * @codeCoverageIgnore
  */
 public static function init($module, $addTestConfig = false, $applicationConfig = array())
 {
     // Set up PHP environment.
     session_cache_limiter('nocache');
     // Default headers to prevent caching
     return \Zend\Mvc\Application::init(array_replace_recursive(static::getApplicationConfig($module, $addTestConfig), $applicationConfig));
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:19,代码来源:Application.php

示例3: __construct

 /**
  * Constructor
  * @param array $opts
  */
 public function __construct(array $opts)
 {
     // merging options
     $this->options = array_replace_recursive($this->options, $opts);
     // getting a client object
     $this->client = $this->getClient();
 }
开发者ID:kkamkou,项目名称:sms-online-api,代码行数:11,代码来源:Api.php

示例4: merge

 /**
  * Merges new config values with the existing ones (overriding)
  *
  * @param array $config
  */
 public function merge(array $config)
 {
     // override defaults with given config
     if (!empty($config['config']) && is_array($config['config'])) {
         $this->config = array_replace_recursive($this->config, $config['config']);
     }
     if (!empty($config['repositories']) && is_array($config['repositories'])) {
         $this->repositories = array_reverse($this->repositories, true);
         $newRepos = array_reverse($config['repositories'], true);
         foreach ($newRepos as $name => $repository) {
             // disable a repository by name
             if (false === $repository) {
                 unset($this->repositories[$name]);
                 continue;
             }
             // disable a repository with an anonymous {"name": false} repo
             if (1 === count($repository) && false === current($repository)) {
                 unset($this->repositories[key($repository)]);
                 continue;
             }
             // store repo
             if (is_int($name)) {
                 $this->repositories[] = $repository;
             } else {
                 $this->repositories[$name] = $repository;
             }
         }
         $this->repositories = array_reverse($this->repositories, true);
     }
 }
开发者ID:rufinus,项目名称:composer,代码行数:35,代码来源:Config.php

示例5: productCreationProvider

 /**
  * @return array
  */
 public function productCreationProvider()
 {
     $productBuilder = function ($data) {
         return array_replace_recursive($this->getSimpleProductData(), $data);
     };
     return [[$productBuilder([ProductInterface::TYPE_ID => 'simple', ProductInterface::SKU => 'psku-test-1'])], [$productBuilder([ProductInterface::TYPE_ID => 'virtual', ProductInterface::SKU => 'psku-test-2'])]];
 }
开发者ID:nja78,项目名称:magento2,代码行数:10,代码来源:ProductRepositoryInterfaceTest.php

示例6: getTable

 protected function getTable($name)
 {
     $table = (include_once dirname($this->getFileLocation()) . "/" . $this->getFolderLocation() . "/" . $name . ".php");
     $table = array_replace_recursive($this->tableDefault, $table);
     foreach ($table["fields"] as $name => $field) {
         $table["fields"][$name] = array_merge($this->tableFieldDefault, $field);
         if (!isset($field["label"])) {
             $table["fields"][$name]["label"] = ucwords($name);
         }
         if (!in_array($this->tableAction, array("data", "update", "delete", "insert", "reorder"))) {
             // page
             $_list = $table["fields"][$name]["_list"];
             if (is_array($_list)) {
                 $list = array();
                 $rows = $_list["src"]();
                 foreach ($rows as $row) {
                     $idField = $_list["primary"];
                     $displayAttrField = $_list["displayAttr"];
                     $list["" . $row->{$idField}] = $row->{$displayAttrField};
                 }
                 $table["fields"][$name]["list"] = $list;
             }
         }
     }
     $table["url"] = $this->md($this->id . "/" . $table["tableAlias"], false);
     if ($table["actions"]["_view"] == "*") {
         $table["actions"]["_view"] = array();
         foreach ($table["fields"] as $column => $field) {
             $table["actions"]["_view"][] = $column;
         }
     }
     $table["multiPages"] = $table["editType"] == "page" || $table["viewType"] == "page" || $table["createType"] == "page";
     return $table;
 }
开发者ID:huynt57,项目名称:bluebee-uet.com,代码行数:34,代码来源:AdminTableController.php

示例7: tests

 public function tests()
 {
     PHPUsableTest::$current_test = $this;
     describe('Arrays', function ($test) {
         describe('Merge', function ($test) {
             it('should not convert scalars to arrays', function ($test) {
                 $a = array('level 1' => array('level 2' => 2));
                 $b = array('level 1' => array('level 2' => 5));
                 $test->expect(array_replace_recursive($a, $b))->to->eql(array('level 1' => array('level 2' => 5)));
             });
             it('should unionize arrays', function ($test) {
                 $a = array('level 1' => array('level 2' => array(2, 3)));
                 $b = array('level 1' => array('level 2' => array(5)));
                 $test->expect(array_replace_recursive($a, $b))->to->eql(array('level 1' => array('level 2' => array(5, 3))));
             });
         });
         describe('Get', function ($test) {
             it('should get a single level value', function ($test) {
                 $arr = array('planets' => 'pluto');
                 $test->expect(Arrays::get($arr, 'planets'))->to->eql('pluto');
             });
             it('should get a multi level value', function ($test) {
                 $arr = array('milky_way' => array('planets' => array('earth')));
                 $test->expect(Arrays::get($arr, 'milky_way.planets'))->to->eql(array('earth'));
             });
             it('should return null for an undefined key', function ($test) {
                 $arr = array('milky_way' => array('planets' => array('earth')));
                 $test->expect(Arrays::get($arr, 'andromeda.planets'))->to->eql(null);
             });
         });
     });
 }
开发者ID:mover-io,项目名称:belt,代码行数:32,代码来源:ArraysTests.php

示例8: __construct

 /**
  * @param Container $container
  */
 public function __construct(Container $container, array $config, $debug = false)
 {
     $this->container = $container;
     $config['debug'] = $debug;
     $this->config = array_replace_recursive($this->config, $config);
     $container->registerFactory($this);
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:10,代码来源:GoogleServicesFactory.php

示例9: factory

 /**
  * @param array $options
  * @param JobBuilderInterface|null $jobBuilder
  * @return FileConversionClient
  */
 public static function factory($options = array(), JobBuilderInterface $jobBuilder = null)
 {
     //        $requiredOptions = array(
     //            'application_id',
     //        );
     //
     //        foreach ($requiredOptions as $optionName) {
     //            if (!isset($options[$optionName]) || $options[$optionName] === '') {
     //                throw new Exception\InvalidArgumentException(
     //                    sprintf('Missing required configuration option "%s"', $optionName)
     //                );
     //            }
     //        }
     $defaultOptions = array('base_url' => 'https://dws-fileconversion.detailnet.ch/api', 'defaults' => array('connect_timeout' => 10, 'timeout' => 60));
     $headers = array('Accept' => 'application/json', 'User-Agent' => 'dfw-fileconversion/' . self::CLIENT_VERSION);
     if (isset($options[self::OPTION_APP_ID])) {
         $headers[self::HEADER_APP_ID] = $options[self::OPTION_APP_ID];
     }
     if (isset($options[self::OPTION_APP_KEY])) {
         $headers[self::HEADER_APP_KEY] = $options[self::OPTION_APP_KEY];
     }
     // These are always applied
     $overrideOptions = array('defaults' => array('exceptions' => false, 'headers' => $headers));
     // Apply options
     $config = array_replace_recursive($defaultOptions, $options, $overrideOptions);
     $httpClient = new HttpClient($config);
     $httpClient->getEmitter()->attach(new Subscriber\Http\ProcessError());
     $description = new ServiceDescription(require __DIR__ . '/ServiceDescription/FileConversion.php');
     $client = new static($httpClient, $description, $jobBuilder);
     return $client;
 }
开发者ID:detailnet,项目名称:dfw-fileconversion,代码行数:36,代码来源:FileConversionClient.php

示例10: factory

 public static function factory($options = array())
 {
     //        $requiredOptions = array();
     //
     //        foreach ($requiredOptions as $optionName) {
     //            if (!isset($options[$optionName]) || $options[$optionName] === '') {
     //                throw new Exception\InvalidArgumentException(
     //                    sprintf('Missing required configuration option "%s"', $optionName)
     //                );
     //            }
     //        }
     // These are applied if not otherwise specified
     $defaultOptions = array('base_url' => self::getDefaultServiceUrl(), 'defaults' => array('connect_timeout' => 10, 'timeout' => 60));
     $headers = array('Accept' => 'application/json', 'User-Agent' => 'denner-client/' . self::CLIENT_VERSION);
     if (isset($options[self::OPTION_APP_ID])) {
         $headers[self::HEADER_APP_ID] = $options[self::OPTION_APP_ID];
     }
     if (isset($options[self::OPTION_APP_KEY])) {
         $headers[self::HEADER_APP_KEY] = $options[self::OPTION_APP_KEY];
     }
     // These are always applied
     $overrideOptions = array('defaults' => array('exceptions' => false, 'headers' => $headers));
     // Apply options
     $config = array_replace_recursive($defaultOptions, $options, $overrideOptions);
     $httpClient = new HttpClient($config);
     $httpClient->getEmitter()->attach(new Subscriber\Http\ProcessError());
     $serviceDescriptionFile = __DIR__ . sprintf('/ServiceDescription/%s.php', self::getServiceDescriptionName());
     if (!file_exists($serviceDescriptionFile)) {
         throw new Exception\RuntimeException(sprintf('Service description does not exist at "%s"', $serviceDescriptionFile));
     }
     $description = new ServiceDescription(require $serviceDescriptionFile);
     $client = new static($httpClient, $description);
     return $client;
 }
开发者ID:detailnet,项目名称:denner-client,代码行数:34,代码来源:DennerClient.php

示例11: makeConfiguration

 /**
  * @param array $configuration
  *
  * @return Configuration
  */
 protected function makeConfiguration(array $configuration)
 {
     $defaults = ['paths' => ['app' => realpath(getcwd() . '/..'), 'cache' => realpath(__DIR__ . '/../cache'), 'views' => realpath(__DIR__ . '/../views'), 'deployer' => realpath(getcwd())], 'allowed_ips' => ['127.0.0.1'], 'scm' => ['url' => 'git@github.com:foo/bar.git', 'branch' => 'master'], 'tasks' => [Deploy::class]];
     $configuration = array_replace_recursive($defaults, $configuration);
     $configuration = new Configuration($configuration);
     return $configuration;
 }
开发者ID:anahkiasen,项目名称:sadness-deployer,代码行数:12,代码来源:SadnessDeployer.php

示例12: setup

 /**
  * Sets up the Aimeos environemnt
  *
  * @param string $extdir Absolute or relative path to the Aimeos extension directory
  * @return \Aimeos\Slim\Bootstrap Self instance
  */
 public function setup($extdir = '../ext')
 {
     $container = $this->app->getContainer();
     $container['router'] = function ($c) {
         return new \Aimeos\Slim\Router();
     };
     $container['mailer'] = function ($c) {
         return \Swift_Mailer::newInstance(\Swift_SendmailTransport::newInstance());
     };
     $default = (require __DIR__ . DIRECTORY_SEPARATOR . 'aimeos-default.php');
     $settings = array_replace_recursive($default, $this->settings);
     $container['aimeos'] = function ($c) use($extdir) {
         return new \Aimeos\Bootstrap((array) $extdir, false);
     };
     $container['aimeos_config'] = function ($c) use($settings) {
         return new \Aimeos\Slim\Base\Config($c, $settings);
     };
     $container['aimeos_context'] = function ($c) {
         return new \Aimeos\Slim\Base\Context($c);
     };
     $container['aimeos_i18n'] = function ($c) {
         return new \Aimeos\Slim\Base\I18n($c);
     };
     $container['aimeos_locale'] = function ($c) {
         return new \Aimeos\Slim\Base\Locale($c);
     };
     $container['aimeos_page'] = function ($c) {
         return new \Aimeos\Slim\Base\Page($c);
     };
     $container['aimeos_view'] = function ($c) {
         return new \Aimeos\Slim\Base\View($c);
     };
     return $this;
 }
开发者ID:aimeos,项目名称:aimeos-slim,代码行数:40,代码来源:Bootstrap.php

示例13: createDelegatorWithName

 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @param string $name
  * @param string $requestedName
  * @param callable $callback
  * @return SimpleRouteStack
  * @throws Exception
  */
 public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
 {
     /* @var $router TreeRouteStack */
     $router = $callback();
     if ($router instanceof SimpleRouteStack) {
         return $router;
     }
     $config = $serviceLocator->get('Config');
     $doCompileOnRequest = (bool) $config['annotated_router']['compile_on_request'];
     $cacheFile = $config['annotated_router']['cache_file'];
     $useCache = $config['annotated_router']['use_cache'];
     $annotatedRouterConfig = array();
     if ($doCompileOnRequest) {
         $annotatedRouterConfig = $serviceLocator->get('AnnotatedRouter\\ControllerParser')->getRouteConfig();
     } else {
         if ($useCache) {
             if (file_exists($cacheFile)) {
                 $annotatedRouterConfig = (include $cacheFile);
             } else {
                 throw new Exception('Cache file: "' . $cacheFile . '" does not exists.');
             }
         }
     }
     $defaultRouterConfig = isset($config['router']['routes']) ? $config['router']['routes'] : array();
     $mergedRouterConfig = array_replace_recursive($annotatedRouterConfig, $defaultRouterConfig);
     $router->addRoutes($mergedRouterConfig);
     return $router;
 }
开发者ID:alex-oleshkevich,项目名称:zf2-annotated-router,代码行数:36,代码来源:RouterDelegatorFactory.php

示例14: execute

 /**
  * Execute this configuration handler.
  *
  * @param AgaviXmlConfigDomDocument $document configuration document
  *
  * @return string data to be written to a cache file
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'view_templates');
     $all_view_templates = [];
     // iterate over configuration nodes and collect templates
     foreach ($document->getConfigurationElements() as $configuration) {
         $all_view_templates = array_merge($all_view_templates, $this->parseViewTemplates($configuration, $document));
     }
     // TODO recursively extend view_configs
     for ($i = 0; $i < 5; $i++) {
         // when view_templates have an "extends" attribute with a valid scope name, we merge scopes
         foreach ($all_view_templates as $view_scope => &$view_templates) {
             if (!empty($view_templates['extends'])) {
                 if (empty($all_view_templates[$view_templates['extends']])) {
                     throw new ConfigError(sprintf('The "extends" attribute value of the scope "%s" view_templates node is invalid. ' . 'No view_templates node with scope "%s" found in configuration file "%s".', $view_scope, $view_templates['extends'], $document->documentURI));
                 }
                 $view_templates = array_replace_recursive($all_view_templates[$view_templates['extends']], $view_templates);
             }
             // unset($view_templates['extends']);
         }
     }
     // var_dump($all_view_templates);die;
     $config_code = sprintf('return %s;', var_export($all_view_templates, true));
     return $this->generate($config_code, $document->documentURI);
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:32,代码来源:ViewTemplatesConfigHandler.php

示例15: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if (in_array('collection', $view->vars['block_prefixes'])) {
         if ($options['widget_add_btn'] !== null && !is_array($options['widget_add_btn'])) {
             throw new InvalidArgumentException('The "widget_add_btn" option must be an "array".');
         }
         if (isset($options['allow_add']) && true === $options['allow_add'] && $options['widget_add_btn']) {
             if (isset($options['widget_add_btn']['attr']) && !is_array($options['widget_add_btn']['attr'])) {
                 throw new InvalidArgumentException('The "widget_add_btn.attr" option must be an "array".');
             }
             $options['widget_add_btn'] = array_replace_recursive($this->options['widget_add_btn'], $options['widget_add_btn']);
         }
     }
     if ($view->parent && in_array('collection', $view->parent->vars['block_prefixes'])) {
         if ($options['widget_remove_btn'] !== null && !is_array($options['widget_remove_btn'])) {
             throw new InvalidArgumentException('The "widget_remove_btn" option must be an "array".');
         }
         if (isset($view->parent->vars['allow_delete']) && true === $view->parent->vars['allow_delete'] && $options['widget_remove_btn']) {
             if (isset($options['widget_remove_btn']) && !is_array($options['widget_remove_btn'])) {
                 throw new InvalidArgumentException('The "widget_remove_btn" option must be an "array".');
             }
             $options['widget_remove_btn'] = array_replace_recursive($this->options['widget_remove_btn'], $options['widget_remove_btn']);
         }
     }
     $view->vars['omit_collection_item'] = $options['omit_collection_item'];
     $view->vars['widget_add_btn'] = $options['widget_add_btn'];
     $view->vars['widget_remove_btn'] = $options['widget_remove_btn'];
     $view->vars['prototype_names'] = $options['prototype_names'];
     $view->vars['horizontal_wrap_children'] = $options['horizontal_wrap_children'];
 }
开发者ID:hirenbhut93,项目名称:MopaBootstrapBundle,代码行数:33,代码来源:WidgetCollectionFormTypeExtension.php


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