public function getLastValidBlockItem(Block $block)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select(
                $this->connection->quoteIdentifier('p.object_id'),
                $this->connection->quoteIdentifier('p.node_id'),
                $this->connection->quoteIdentifier('p.priority'),
                $this->connection->quoteIdentifier('p.ts_publication'),
                $this->connection->quoteIdentifier('p.ts_visible'),
                $this->connection->quoteIdentifier('p.ts_hidden'),
                $this->connection->quoteIdentifier('p.rotation_until'),
                $this->connection->quoteIdentifier('p.moved_to')
            )
            ->from($this->connection->quoteIdentifier(self::EZM_POOL_TABLE), 'p')
            ->where(
                $query->expr()->eq('p.block_id', ':blockId'),
                $query->expr()->gt('p.ts_visible', ':tsVisible'),
                $query->expr()->eq('p.ts_hidden', ':tsHidden')
            )
            ->setParameter(':blockId', $block->id)
            ->setParameter(':tsVisible', 0, PDO::PARAM_INT)
            ->setParameter(':tsHidden', 0, PDO::PARAM_INT)
            ->orderBy('p.ts_visible', 'DESC')
            ->setMaxResults(1)
        ;

        $statement = $query->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);
        if (empty($rows)) {
            return null;
        }

        return $this->buildBlockItem(
            $rows[0] + array(
                'block_id' => $block->id,
                'ts_hidden' => 0,
            )
        );
    }
public function getLastValidBlockItem(Block $block)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select(
                $this->connection->quoteIdentifier('p.object_id'),
                $this->connection->quoteIdentifier('p.node_id'),
                $this->connection->quoteIdentifier('p.priority'),
                $this->connection->quoteIdentifier('p.ts_publication'),
                $this->connection->quoteIdentifier('p.ts_visible'),
                $this->connection->quoteIdentifier('p.ts_hidden'),
                $this->connection->quoteIdentifier('p.rotation_until'),
                $this->connection->quoteIdentifier('p.moved_to')
            )
            ->from($this->connection->quoteIdentifier(self::EZM_POOL_TABLE), 'p')
            ->where(
                $query->expr()->eq('p.block_id', ':blockId'),
                $query->expr()->gt('p.ts_visible', ':tsVisible'),
                $query->expr()->eq('p.ts_hidden', ':tsHidden')
            )
            ->setParameter(':blockId', $block->id)
            ->setParameter(':tsVisible', 0, PDO::PARAM_INT)
            ->setParameter(':tsHidden', 0, PDO::PARAM_INT)
            ->orderBy('p.ts_visible', 'DESC')
            ->setMaxResults(1)
        ;

        $statement = $query->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);
        if (empty($rows)) {
            return null;
        }

        return $this->buildBlockItem(
            $rows[0] + array(
                'block_id' => $block->id,
                'ts_hidden' => 0,
            )
        );
    }
public function getLastValidBlockItem ( Block $ block ) { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( $ this -> connection -> quoteIdentifier ( 'p.object_id' ) , $ this -> connection -> quoteIdentifier ( 'p.node_id' ) , $ this -> connection -> quoteIdentifier ( 'p.priority' ) , $ this -> connection -> quoteIdentifier ( 'p.ts_publication' ) , $ this -> connection -> quoteIdentifier ( 'p.ts_visible' ) , $ this -> connection -> quoteIdentifier ( 'p.ts_hidden' ) , $ this -> connection -> quoteIdentifier ( 'p.rotation_until' ) , $ this -> connection -> quoteIdentifier ( 'p.moved_to' ) ) -> from ( $ this -> connection -> quoteIdentifier ( self :: EZM_POOL_TABLE ) , 'p' ) -> where ( $ query -> expr ( ) -> eq ( 'p.block_id' , ':blockId' ) , $ query -> expr ( ) -> gt ( 'p.ts_visible' , ':tsVisible' ) , $ query -> expr ( ) -> eq ( 'p.ts_hidden' , ':tsHidden' ) ) -> setParameter ( ':blockId' , $ block -> id ) -> setParameter ( ':tsVisible' , 0 , PDO :: PARAM_INT ) -> setParameter ( ':tsHidden' , 0 , PDO :: PARAM_INT ) -> orderBy ( 'p.ts_visible' , 'DESC' ) -> setMaxResults ( 1 ) ; $ statement = $ query -> execute ( ) ; $ rows = $ statement -> fetchAll ( PDO :: FETCH_ASSOC ) ; if ( empty ( $ rows ) ) { return null ; } return $ this -> buildBlockItem ( $ rows [ 0 ] + array ( 'block_id' => $ block -> id , 'ts_hidden' => 0 , ) ) ; }
Return the block item having a highest visible date, for given block.
Return null if no block item is registered for block.

@param \eZ\Publish\Core\FieldType\Page\Parts\Block $block

@return \eZ\Publish\Core\FieldType\Page\Parts\Item|null
Return the block item having a highest visible date for given block . Return null if no block item is registered for block .