original_string: public function afterSave(Event $event, Menu $menu, ArrayObject $options = null)
      {
          if ($menu->isNew()) {
              $block = TableRegistry::get('Block.Blocks')->newEntity([
                  'title' => $menu->title . ' ' . __d('menu', '[menu: {0}]', $menu->id),
                  'handler' => 'Menu\Widget\MenuWidget',
                  'description' => (!empty($menu->description) ? $menu->description : __d('menu', 'Associated block for "{0}" menu.', $menu->title)),
                  'visibility' => 'except',
                  'pages' => null,
                  'locale' => null,
                  'status' => 0,
                  'settings' => ['menu_id' => $menu->id]
              ], ['validate' => false]);
              TableRegistry::get('Block.Blocks')->save($block);
          }
          $this->clearCache();
      }
code: public function afterSave(Event $event, Menu $menu, ArrayObject $options = null)
      {
          if ($menu->isNew()) {
              $block = TableRegistry::get('Block.Blocks')->newEntity([
                  'title' => $menu->title . ' ' . __d('menu', '[menu: {0}]', $menu->id),
                  'handler' => 'Menu\Widget\MenuWidget',
                  'description' => (!empty($menu->description) ? $menu->description : __d('menu', 'Associated block for "{0}" menu.', $menu->title)),
                  'visibility' => 'except',
                  'pages' => null,
                  'locale' => null,
                  'status' => 0,
                  'settings' => ['menu_id' => $menu->id]
              ], ['validate' => false]);
              TableRegistry::get('Block.Blocks')->save($block);
          }
          $this->clearCache();
      }
code_tokens: public function afterSave ( Event $ event , Menu $ menu , ArrayObject $ options = null ) { if ( $ menu -> isNew ( ) ) { $ block = TableRegistry :: get ( 'Block.Blocks' ) -> newEntity ( [ 'title' => $ menu -> title . ' ' . __d ( 'menu' , '[menu: {0}]' , $ menu -> id ) , 'handler' => 'Menu\Widget\MenuWidget' , 'description' => ( ! empty ( $ menu -> description ) ? $ menu -> description : __d ( 'menu' , 'Associated block for "{0}" menu.' , $ menu -> title ) ) , 'visibility' => 'except' , 'pages' => null , 'locale' => null , 'status' => 0 , 'settings' => [ 'menu_id' => $ menu -> id ] ] , [ 'validate' => false ] ) ; TableRegistry :: get ( 'Block.Blocks' ) -> save ( $ block ) ; } $ this -> clearCache ( ) ; }
docstring: Triggered after menu was persisted in DB.
  
  It will also create menu's associated block if not exists.
  
  @param \Cake\Event\Event $event The event that was triggered
  @param \Menu\Model\Entity\Menu $menu The menu entity that was saved
  @param \ArrayObject $options Options given as an array
  @return void
docstring_tokens: Triggered after menu was persisted in DB .