public function storeItem(ItemFactoryEvent $event) { if ($event->getItem() instanceof SimpleTypeInterface) { $itemId = $event->getItem()->getId(); $type = $this->getType($event->getItem()); $conf = $event->getItem()->toArray(); $this->getStorage()->store($itemId, $type, $conf); } }
public function testGettersAndSetters() { $event = new ItemFactoryEvent(); $expectedItem = $this->getMock(ItemInterface::class); $this->assertFalse($event->hasItem()); $this->assertInstanceOf(ItemFactoryEvent::class, $event->setItem($expectedItem)); $this->assertTrue($event->hasItem()); $this->assertEquals($expectedItem, $event->getItem()); }
public function storeItem(ItemFactoryEvent $event) { $item = $event->getItem(); if ($item instanceof TreeTypeInterface) { $itemId = $item->getId(); $type = $this->getType($item); $conf = $item->getBaseConfig(); foreach ($item->getAll() as $subItem) { $this->getItemFactory()->storeItem($subItem); } $this->getStorage()->store($type, $itemId, $conf); } }