eZ\Publish\Core\FieldType\Page\PageService::getArchivedBlockItems PHP Method

getArchivedBlockItems() public method

Returns archived items (that were previously displayed), for a given block.
public getArchivedBlockItems ( Block $block ) : Item[]
$block eZ\Publish\Core\FieldType\Page\Parts\Block
return eZ\Publish\Core\FieldType\Page\Parts\Item[]
    public function getArchivedBlockItems(Block $block)
    {
        if (isset($this->archivedBlockItems[$block])) {
            return $this->archivedBlockItems[$block];
        }
        return $this->archivedBlockItems[$block] = $this->getStorageGateway()->getArchivedBlockItems($block);
    }

Usage Example

 /**
  * @covers eZ\Publish\Core\FieldType\Page\PageService::hasStorageGateway
  * @covers eZ\Publish\Core\FieldType\Page\PageService::getStorageGateway
  * @covers eZ\Publish\Core\FieldType\Page\PageService::getArchivedBlockItems
  */
 public function testGetArchivedBlockItems()
 {
     $block = $this->buildBlock();
     $items = array(new Item(), new Item());
     $this->storageGateway->expects($this->once())->method('getArchivedBlockItems')->with($block)->will($this->returnValue($items));
     $this->pageService->setStorageGateway($this->storageGateway);
     // Calling assertion twice to test cache (comes along with storage gateway's getArchivedBlockItems() that should be called only once. See above)
     $this->assertSame($items, $this->pageService->getArchivedBlockItems($block));
     $this->assertSame($items, $this->pageService->getArchivedBlockItems($block));
 }