original_string: public function addScopes(array $scopes)
      {
          foreach ($scopes as $name => $config) {
  
              $scopeObj = $this->makeFilterScope($name, $config);
  
              /*
               * Check that the filter scope matches the active context
               */
              if ($scopeObj->context !== null) {
                  $context = is_array($scopeObj->context) ? $scopeObj->context : [$scopeObj->context];
                  if (!in_array($this->getContext(), $context)) {
                      continue;
                  }
              }
  
              /*
               * Validate scope model
               */
              if (isset($config['modelClass'])) {
                  $class = $config['modelClass'];
                  $model = new $class;
                  $this->scopeModels[$name] = $model;
              }
  
              /*
               * Ensure scope type options are set
               */
              $scopeProperties = [];
              switch ($scopeObj->type) {
                  case 'date':
                  case 'daterange':
                      $scopeProperties = [
                          'minDate'   => '2000-01-01',
                          'maxDate'   => '2099-12-31',
                          'firstDay'  => 0,
                          'yearRange' => 10,
                      ];
  
                      break;
              }
  
              foreach ($scopeProperties as $property => $value) {
                  if (isset($config[$property])) {
                      $value = $config[$property];
                  }
  
                  $scopeObj->{$property} = $value;
              }
  
              $this->allScopes[$name] = $scopeObj;
          }
      }
code: public function addScopes(array $scopes)
      {
          foreach ($scopes as $name => $config) {
  
              $scopeObj = $this->makeFilterScope($name, $config);
  
              /*
               * Check that the filter scope matches the active context
               */
              if ($scopeObj->context !== null) {
                  $context = is_array($scopeObj->context) ? $scopeObj->context : [$scopeObj->context];
                  if (!in_array($this->getContext(), $context)) {
                      continue;
                  }
              }
  
              /*
               * Validate scope model
               */
              if (isset($config['modelClass'])) {
                  $class = $config['modelClass'];
                  $model = new $class;
                  $this->scopeModels[$name] = $model;
              }
  
              /*
               * Ensure scope type options are set
               */
              $scopeProperties = [];
              switch ($scopeObj->type) {
                  case 'date':
                  case 'daterange':
                      $scopeProperties = [
                          'minDate'   => '2000-01-01',
                          'maxDate'   => '2099-12-31',
                          'firstDay'  => 0,
                          'yearRange' => 10,
                      ];
  
                      break;
              }
  
              foreach ($scopeProperties as $property => $value) {
                  if (isset($config[$property])) {
                      $value = $config[$property];
                  }
  
                  $scopeObj->{$property} = $value;
              }
  
              $this->allScopes[$name] = $scopeObj;
          }
      }
code_tokens: public function addScopes ( array $ scopes ) { foreach ( $ scopes as $ name => $ config ) { $ scopeObj = $ this -> makeFilterScope ( $ name , $ config ) ; /*
               * Check that the filter scope matches the active context
               */ if ( $ scopeObj -> context !== null ) { $ context = is_array ( $ scopeObj -> context ) ? $ scopeObj -> context : [ $ scopeObj -> context ] ; if ( ! in_array ( $ this -> getContext ( ) , $ context ) ) { continue ; } } /*
               * Validate scope model
               */ if ( isset ( $ config [ 'modelClass' ] ) ) { $ class = $ config [ 'modelClass' ] ; $ model = new $ class ; $ this -> scopeModels [ $ name ] = $ model ; } /*
               * Ensure scope type options are set
               */ $ scopeProperties = [ ] ; switch ( $ scopeObj -> type ) { case 'date' : case 'daterange' : $ scopeProperties = [ 'minDate' => '2000-01-01' , 'maxDate' => '2099-12-31' , 'firstDay' => 0 , 'yearRange' => 10 , ] ; break ; } foreach ( $ scopeProperties as $ property => $ value ) { if ( isset ( $ config [ $ property ] ) ) { $ value = $ config [ $ property ] ; } $ scopeObj -> { $ property } = $ value ; } $ this -> allScopes [ $ name ] = $ scopeObj ; } }
docstring: Programatically add scopes, used internally and for extensibility.
docstring_tokens: Programatically add scopes used internally and for extensibility .