Skip to content
Snippets Groups Projects
Commit 4766562d authored by Vadim Justus's avatar Vadim Justus
Browse files

Introduce content entry key

parent aa119c75
No related branches found
No related tags found
No related merge requests found
...@@ -13,12 +13,18 @@ interface ContentEntryInterface ...@@ -13,12 +13,18 @@ interface ContentEntryInterface
const CONTENT = 'content'; const CONTENT = 'content';
const STORES = 'stores'; const STORES = 'stores';
const IS_MAINTAINED = 'is_maintained'; const IS_MAINTAINED = 'is_maintained';
const KEY = 'key';
/** /**
* @return string * @return string
*/ */
public function getType(): string; public function getType(): string;
/**
* @return string
*/
public function getKey(): string;
/** /**
* @return string * @return string
*/ */
...@@ -44,6 +50,11 @@ interface ContentEntryInterface ...@@ -44,6 +50,11 @@ interface ContentEntryInterface
*/ */
public function setType(string $type): void; public function setType(string $type): void;
/**
* @param string $key
*/
public function setKey(string $key): void;
/** /**
* @param string $identifier * @param string $identifier
*/ */
......
...@@ -68,7 +68,9 @@ class Converter implements \Magento\Framework\Config\ConverterInterface ...@@ -68,7 +68,9 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
$identifier = $this->getAttributeValue($node, 'identifier'); $identifier = $this->getAttributeValue($node, 'identifier');
try { try {
$stores = $this->extractStores($node); $stores = $this->extractStores($node);
$output[$this->buildKey($identifier, $stores, $nodeKey)] = [ $key = $this->buildKey($identifier, $stores, $nodeKey);
$output[$key] = [
ContentEntryInterface::KEY => $key,
ContentEntryInterface::IDENTIFIER => $identifier, ContentEntryInterface::IDENTIFIER => $identifier,
ContentEntryInterface::TYPE => $nodeKey, ContentEntryInterface::TYPE => $nodeKey,
ContentEntryInterface::IS_MAINTAINED => ContentEntryInterface::IS_MAINTAINED =>
......
...@@ -34,10 +34,11 @@ class ListCommand extends Command ...@@ -34,10 +34,11 @@ class ListCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$table = new Table($output); $table = new Table($output);
$table->setHeaders(['Type', 'Identifier', 'Stores', 'Maintained', 'Content (Teaser)']); $table->setHeaders(['Key', 'Type', 'Identifier', 'Stores', 'Maintained', 'Content (Teaser)']);
foreach ($this->getAllContentEntries->get() as $entry) { foreach ($this->getAllContentEntries->get() as $entry) {
$table->addRow([ $table->addRow([
$entry->getKey(),
$entry->getType(), $entry->getType(),
$entry->getIdentifier(), $entry->getIdentifier(),
implode(', ', $entry->getStores()), implode(', ', $entry->getStores()),
......
...@@ -16,6 +16,14 @@ class ContentEntry extends DataObject implements ContentEntryInterface ...@@ -16,6 +16,14 @@ class ContentEntry extends DataObject implements ContentEntryInterface
return (string)$this->getData(ContentEntryInterface::TYPE); return (string)$this->getData(ContentEntryInterface::TYPE);
} }
/**
* @return string
*/
public function getKey(): string
{
return (string)$this->getData(ContentEntryInterface::KEY);
}
/** /**
* @return string * @return string
*/ */
...@@ -56,6 +64,14 @@ class ContentEntry extends DataObject implements ContentEntryInterface ...@@ -56,6 +64,14 @@ class ContentEntry extends DataObject implements ContentEntryInterface
$this->setData(ContentEntryInterface::TYPE, $type); $this->setData(ContentEntryInterface::TYPE, $type);
} }
/**
* @param string $key
*/
public function setKey(string $key): void
{
$this->setData(ContentEntryInterface::KEY, $key);
}
/** /**
* @param string $identifier * @param string $identifier
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment