/** * Remove an block from the current Item Set * @param Block $block */ public function removeBlock(Block $block) { if ($this->blocks == null) { if ($this->id != null) { $this->setBlocks(Block::findAllByItemSet($this)); } else { $this->blocks = []; } } $block->delete(); $index = array_search($block, $this->blocks); if ($index !== false) { unset($this->blocks[$index]); } }