original_string: public static function get_overrides_for_purpose(purpose $purpose) : array {
          $cache = \cache::make('tool_dataprivacy', 'purpose_overrides');
  
          $overrides = [];
          $alldata = $cache->get($purpose->get('id'));
          if (false === $alldata) {
              $tocache = [];
              foreach (self::get_records(['purposeid' => $purpose->get('id')]) as $override) {
                  $tocache[] = $override->to_record();
                  $overrides[$override->get('roleid')] = $override;
              }
              $cache->set($purpose->get('id'), $tocache);
          } else {
              foreach ($alldata as $data) {
                  $override = new self(0, $data);
                  $overrides[$override->get('roleid')] = $override;
              }
          }
  
          return $overrides;
      }
code: public static function get_overrides_for_purpose(purpose $purpose) : array {
          $cache = \cache::make('tool_dataprivacy', 'purpose_overrides');
  
          $overrides = [];
          $alldata = $cache->get($purpose->get('id'));
          if (false === $alldata) {
              $tocache = [];
              foreach (self::get_records(['purposeid' => $purpose->get('id')]) as $override) {
                  $tocache[] = $override->to_record();
                  $overrides[$override->get('roleid')] = $override;
              }
              $cache->set($purpose->get('id'), $tocache);
          } else {
              foreach ($alldata as $data) {
                  $override = new self(0, $data);
                  $overrides[$override->get('roleid')] = $override;
              }
          }
  
          return $overrides;
      }
code_tokens: public static function get_overrides_for_purpose ( purpose $ purpose ) : array { $ cache = \ cache :: make ( 'tool_dataprivacy' , 'purpose_overrides' ) ; $ overrides = [ ] ; $ alldata = $ cache -> get ( $ purpose -> get ( 'id' ) ) ; if ( false === $ alldata ) { $ tocache = [ ] ; foreach ( self :: get_records ( [ 'purposeid' => $ purpose -> get ( 'id' ) ] ) as $ override ) { $ tocache [ ] = $ override -> to_record ( ) ; $ overrides [ $ override -> get ( 'roleid' ) ] = $ override ; } $ cache -> set ( $ purpose -> get ( 'id' ) , $ tocache ) ; } else { foreach ( $ alldata as $ data ) { $ override = new self ( 0 , $ data ) ; $ overrides [ $ override -> get ( 'roleid' ) ] = $ override ; } } return $ overrides ; }
docstring: Get all role overrides for the purpose.
  
  @param   purpose $purpose
  @return  array
docstring_tokens: Get all role overrides for the purpose .