Exemplo n.º 1
0
 /**
  * Merges all of the arrays found in the defaults configuration in the order defined by the context 
  *
  * @param ArrayOk $sequence
  * @param ArrayOk $config
  * @access protected
  * @return array
  */
 protected function mergeDefaults(ArrayOk $sequence, ArrayOk $config)
 {
     $toMerge = array();
     foreach ($sequence->toArray() as $context) {
         if ($config->exists($context)) {
             $toMerge[] = $config[$context]->toArray();
         }
     }
     return empty($toMerge) ?: call_user_func_array('array_merge', $toMerge);
 }
Exemplo n.º 2
0
 /**
  * Checks to see if the given context matches any of the current conditions
  * 
  * @param  ArrayOk $Context
  * @return bool
  */
 public function matchesContext(ArrayOk $Context)
 {
     if (empty($this->conditions)) {
         return false;
     }
     foreach ($this->conditions as $key => $value) {
         // Bug out if the key isn't even set
         if (!$Context->exists($key)) {
             return false;
         }
         // Bug out if the key is set, but the value doesn't match
         if (!preg_match("#{$Context[$key]}#", $value)) {
             return false;
         }
     }
     return true;
 }