Esempio n. 1
0
function array_deep_merge()
{
    $args = func_get_args();
    $count = count($args);
    if ($count == 0) {
        return false;
    }
    if ($count == 1) {
        return $args[0];
    }
    if ($count > 2) {
        $args[1] = array_deep_merge($args[0], $args[1]);
        array_shift($args);
        return call_user_func_array('Nucleus\\array_deep_merge', $args);
    }
    //If both are not array we return the last occurence found
    if (!is_array($args[0]) || !is_array($args[1])) {
        return $args[1];
    }
    $return = array();
    foreach (array_unique(array_merge(array_keys($args[0]), array_keys($args[1]))) as $key) {
        $isKey0 = array_key_exists($key, $args[0]);
        $isKey1 = array_key_exists($key, $args[1]);
        if ($isKey0 && $isKey1) {
            if (is_int($key)) {
                $return[] = $args[0][$key];
                $return[] = $args[1][$key];
                continue;
            }
            $value = array_deep_merge($args[0][$key], $args[1][$key]);
        } else {
            $value = $isKey0 ? $args[0][$key] : $args[1][$key];
        }
        if (is_int($key)) {
            $return[] = $value;
        } else {
            $return[$key] = $value;
        }
    }
    return $return;
}
Esempio n. 2
0
 private function setDefaultConfiguration()
 {
     $defaultConfiguration = array();
     $defaultConfiguration['services']['aspectKernel']['arguments'] = array($this->dnaConfiguration->getAspectConfiguration());
     $defaultConfiguration['services']['configuration']['configuration']['generatedDirectory'] = $this->dnaConfiguration->getCachePath();
     $this->configuration = array_deep_merge($defaultConfiguration, $this->configuration);
 }
 function __construct($options = array())
 {
     $this->options = array_deep_merge(array('prefix_id' => 'pages_selector', 'language_domain' => 'pages_selector', 'field_prefix' => 'pages_selector[pages]', 'toggle_prefix' => 'pages_selector[all]', 'show_on_front_prefix' => 'pages_selector[show_on_front]', 'labels' => array('widget' => array('selector' => 'Choose content:', 'selected' => 'Appears on:'), 'buttons' => array('all_pages' => 'All Pages', 'specific_pages' => 'Specific Pages'), 'empty' => 'No Posts selected yet.', 'show_on_front' => 'Show on front page? ', 'check_all' => 'Check All')), $options);
     $this->get_post_types();
     $this->posts = array();
 }
Esempio n. 4
0
 public function generate($name, array $parameters = array(), $referenceType = self::ABSOLUTE_PATH, $scheme = null)
 {
     $contextParameters = array_deep_merge($this->sessionDefaultParameters, $this->defaultParameters, $this->context->getParameters());
     $oldContextParameters = $this->context->getParameters();
     $this->context->setParameters($contextParameters);
     $oldScheme = null;
     if ($scheme) {
         $oldScheme = $this->context->getScheme();
         $this->context->setScheme($scheme);
     }
     $oldHost = $this->context->getHost();
     $context = $this->context;
     $finalize = new OutOfScopeFinalize(function () use($oldContextParameters, $oldScheme, $oldHost, $context, $scheme) {
         if ($scheme) {
             $context->setScheme($oldScheme);
         }
         $context->setHost($oldHost);
         $context->setParameters($oldContextParameters);
     });
     $cultures = $this->getCultures(array_merge($contextParameters, $parameters));
     $route = null;
     foreach ($cultures as $culture) {
         $routeName = $this->getI18nRouteName($name, $culture);
         if ($this->routeCollection->get($routeName)) {
             try {
                 $host = $this->getHostForCulture($culture == '' ? 'default' : $culture);
                 $this->context->setHost($host);
                 if ($host != $oldHost) {
                     $referenceType = self::ABSOLUTE_URL;
                 }
             } catch (NoHostFoundForCultureException $e) {
                 //We do nothing with the exception, it will use the request domain
             }
             $route = $this->urlGenerator->generate($routeName, $parameters, $referenceType);
             break;
         }
     }
     if (is_null($route)) {
         $route = $this->urlGenerator->generate($name, $parameters);
     }
     return $route;
 }
Esempio n. 5
0
 /**
  * @param mixed $configuration A file name or a array of configuration
  * @return DnaConfiguration
  * @throws InvalidArgumentException
  */
 public function prependConfiguration($configuration)
 {
     switch (true) {
         case is_null($this->configuration):
             $this->setConfiguration($configuration);
             break;
         case is_array($this->configuration) && is_array($configuration):
             $this->configuration = array_deep_merge($configuration, $this->configuration);
             break;
         case is_array($this->configuration) && is_string($configuration):
             $this->configuration = array_deep_merge(array('imports' => array($configuration)), $this->configuration);
             break;
         case is_string($this->configuration) && is_array($configuration):
             $this->configuration = array_deep_merge($configuration, array('imports' => array(array('file' => $this->configuration, 'append' => true))));
             break;
         case is_string($this->configuration) && is_string($configuration):
             $this->configuration = array('imports' => array($configuration, $this->configuration));
             break;
         default:
             throw new InvalidArgumentException('Configuration argument must be a array or file name, [' . gettype($configuration . '] have be pass.'));
             break;
     }
     return $this;
 }
Esempio n. 6
0
 public function merge(array $configuration = array())
 {
     $this->configuration = array_deep_merge($this->configuration, $configuration);
 }
Esempio n. 7
0
 /**
  * @\Nucleus\IService\DependencyInjection\Inject(configuration="$")
  *
  * @param array $configuration
  */
 public function __construct($configuration)
 {
     $this->configuration = array_deep_merge(self::$defaultConfiguration, $configuration);
 }