Magento2: [CMS] Add ability to load block and pages by identifiers

Created on 3 Aug 2017  路  4Comments  路  Source: magento/magento2

Description

As a Magento develop I would like to have a @api interface to get CMS pages and blocks by identifiers and store id.

Existing API

Existing API of the CMS module provides an ability to:

  • get page/block by ID (BlockRepositoryInterface::get, PageRepositoryInterface::get)
  • search page/block by search criteria (BlockRepositoryInterface::search, PageRepositoryInterface::search)

Solution

  1. Introduce BlockManagementInterface and PageManagementInterface to provide an ability get CMS pages and blocks by identifiers and store id.
namespace Magento\Cms\Model;
/**
 * @api
 */
interface BlockManagementInterface
{
    /**
     * Load Block data by given Block identifier.
     *
     * @param string $identifier
     * @param int|null $storeId
     * @return \Magento\Cms\Api\Data\BlockInterface
     */
    public function getByIdentifier($identifier, $storeId = null);
}
namespace Magento\Cms\Model;

/**
 * @api
 */
interface PageManagementInterface
{
    /**
     * Load Page data by given Page identifier.
     *
     * @param string $identifier
     * @param int|null $storeId
     * @return \Magento\Cms\Api\Data\PageInterface
     */
    public function getByIdentifier($identifier, $storeId = null);
}
  1. Provide default implemetation for the new interfaces.
  2. If store id is NULL, use current store ID.

Note: All new @api classes must be covered with the tests

Related issues:

  1. https://github.com/magento/magento2/issues/6570
  2. https://github.com/magento/magento2/pull/7417
  3. https://github.com/magento/magento2/pull/9163
  4. https://github.com/magento/magento2/issues/8858
Cms Fixed in 2.3.x Format is not valid up for grabs

Most helpful comment

@okorshenko I'll have time to work on it. If you could assign it to me.

All 4 comments

@okorshenko if no one will grab it before next week you can assign it to me. I should have some time to work on it next weekend.

@okorshenko I'll have time to work on it. If you could assign it to me.

@damiantomczak

Hi @damiantomczak thank you for working on this. Closing the issue

Was this page helpful?
0 / 5 - 0 ratings