original_string: protected function _reorder()
      {
          if (!empty($this->request->data['regions'])) {
              foreach ($this->request->data['regions'] as $theme => $regions) {
                  foreach ($regions as $region => $ids) {
                      $ordering = 0;
                      foreach ($ids as $id) {
                          $blockRegion = $this->Blocks
                              ->BlockRegions
                              ->newEntity([
                                  'id' => $id,
                                  'theme' => $theme,
                                  'region' => $region,
                                  'ordering' => $ordering
                              ]);
                          $blockRegion->isNew(false);
                          $this->Blocks->BlockRegions->save($blockRegion);
                          $ordering++;
                      }
                  }
              }
  
              return true;
          }
  
          return false;
      }
code: protected function _reorder()
      {
          if (!empty($this->request->data['regions'])) {
              foreach ($this->request->data['regions'] as $theme => $regions) {
                  foreach ($regions as $region => $ids) {
                      $ordering = 0;
                      foreach ($ids as $id) {
                          $blockRegion = $this->Blocks
                              ->BlockRegions
                              ->newEntity([
                                  'id' => $id,
                                  'theme' => $theme,
                                  'region' => $region,
                                  'ordering' => $ordering
                              ]);
                          $blockRegion->isNew(false);
                          $this->Blocks->BlockRegions->save($blockRegion);
                          $ordering++;
                      }
                  }
              }
  
              return true;
          }
  
          return false;
      }
code_tokens: protected function _reorder ( ) { if ( ! empty ( $ this -> request -> data [ 'regions' ] ) ) { foreach ( $ this -> request -> data [ 'regions' ] as $ theme => $ regions ) { foreach ( $ regions as $ region => $ ids ) { $ ordering = 0 ; foreach ( $ ids as $ id ) { $ blockRegion = $ this -> Blocks -> BlockRegions -> newEntity ( [ 'id' => $ id , 'theme' => $ theme , 'region' => $ region , 'ordering' => $ ordering ] ) ; $ blockRegion -> isNew ( false ) ; $ this -> Blocks -> BlockRegions -> save ( $ blockRegion ) ; $ ordering ++ ; } } } return true ; } return false ; }
docstring: Reorders blocks based on the order provided via POST.
  
  @return bool True on success, false otherwise
docstring_tokens: Reorders blocks based on the order provided via POST .