original_string: public function afterDelete(Event $event, Menu $menu, ArrayObject $options = null)
      {
          $blocks = TableRegistry::get('Block.Blocks')
              ->find('all')
              ->select(['id', 'handler', 'settings'])
              ->where(['handler' => 'Menu\Widget\MenuWidget']);
          foreach ($blocks as $block) {
              if (!empty($menu->settings['menu_id']) && $menu->settings['menu_id'] == $menu->id) {
                  TableRegistry::get('Block.Blocks')->delete($block);
  
                  return;
              }
          }
  
          $this->clearCache();
      }
code: public function afterDelete(Event $event, Menu $menu, ArrayObject $options = null)
      {
          $blocks = TableRegistry::get('Block.Blocks')
              ->find('all')
              ->select(['id', 'handler', 'settings'])
              ->where(['handler' => 'Menu\Widget\MenuWidget']);
          foreach ($blocks as $block) {
              if (!empty($menu->settings['menu_id']) && $menu->settings['menu_id'] == $menu->id) {
                  TableRegistry::get('Block.Blocks')->delete($block);
  
                  return;
              }
          }
  
          $this->clearCache();
      }
code_tokens: public function afterDelete ( Event $ event , Menu $ menu , ArrayObject $ options = null ) { $ blocks = TableRegistry :: get ( 'Block.Blocks' ) -> find ( 'all' ) -> select ( [ 'id' , 'handler' , 'settings' ] ) -> where ( [ 'handler' => 'Menu\Widget\MenuWidget' ] ) ; foreach ( $ blocks as $ block ) { if ( ! empty ( $ menu -> settings [ 'menu_id' ] ) && $ menu -> settings [ 'menu_id' ] == $ menu -> id ) { TableRegistry :: get ( 'Block.Blocks' ) -> delete ( $ block ) ; return ; } } $ this -> clearCache ( ) ; }
docstring: Triggered after menu was removed from DB.
  
  This method will delete any associated block the removed menu could have.
  This operation may take a while if there are too many menus created.
  
  @param \Cake\Event\Event $event The event that was triggered
  @param \Menu\Model\Entity\Menu $menu The menu entity that was deleted
  @param \ArrayObject $options Options given as an array
  @return void
docstring_tokens: Triggered after menu was removed from DB .