From 4766562d73728f4013650960afaa81a33e2e70af Mon Sep 17 00:00:00 2001
From: Vadim Justus <v.justus@techdivision.com>
Date: Sat, 9 Feb 2019 20:25:43 +0100
Subject: [PATCH] Introduce content entry key

---
 Api/Data/ContentEntryInterface.php | 11 +++++++++++
 Model/Config/Converter.php         |  4 +++-
 Model/Console/ListCommand.php      |  3 ++-
 Model/ContentEntry.php             | 16 ++++++++++++++++
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/Api/Data/ContentEntryInterface.php b/Api/Data/ContentEntryInterface.php
index bb5ef7d..76ae6d3 100644
--- a/Api/Data/ContentEntryInterface.php
+++ b/Api/Data/ContentEntryInterface.php
@@ -13,12 +13,18 @@ interface ContentEntryInterface
     const CONTENT = 'content';
     const STORES = 'stores';
     const IS_MAINTAINED = 'is_maintained';
+    const KEY = 'key';
 
     /**
      * @return string
      */
     public function getType(): string;
 
+    /**
+     * @return string
+     */
+    public function getKey(): string;
+
     /**
      * @return string
      */
@@ -44,6 +50,11 @@ interface ContentEntryInterface
      */
     public function setType(string $type): void;
 
+    /**
+     * @param string $key
+     */
+    public function setKey(string $key): void;
+
     /**
      * @param string $identifier
      */
diff --git a/Model/Config/Converter.php b/Model/Config/Converter.php
index 4ff8dde..12358ef 100644
--- a/Model/Config/Converter.php
+++ b/Model/Config/Converter.php
@@ -68,7 +68,9 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
             $identifier = $this->getAttributeValue($node, 'identifier');
             try {
                 $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::TYPE => $nodeKey,
                     ContentEntryInterface::IS_MAINTAINED =>
diff --git a/Model/Console/ListCommand.php b/Model/Console/ListCommand.php
index 0a4ec79..8541cac 100644
--- a/Model/Console/ListCommand.php
+++ b/Model/Console/ListCommand.php
@@ -34,10 +34,11 @@ class ListCommand extends Command
     protected function execute(InputInterface $input, OutputInterface $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) {
             $table->addRow([
+                $entry->getKey(),
                 $entry->getType(),
                 $entry->getIdentifier(),
                 implode(', ', $entry->getStores()),
diff --git a/Model/ContentEntry.php b/Model/ContentEntry.php
index fb8ebc9..2f42fd0 100644
--- a/Model/ContentEntry.php
+++ b/Model/ContentEntry.php
@@ -16,6 +16,14 @@ class ContentEntry extends DataObject implements ContentEntryInterface
         return (string)$this->getData(ContentEntryInterface::TYPE);
     }
 
+    /**
+     * @return string
+     */
+    public function getKey(): string
+    {
+        return (string)$this->getData(ContentEntryInterface::KEY);
+    }
+
     /**
      * @return string
      */
@@ -56,6 +64,14 @@ class ContentEntry extends DataObject implements ContentEntryInterface
         $this->setData(ContentEntryInterface::TYPE, $type);
     }
 
+    /**
+     * @param string $key
+     */
+    public function setKey(string $key): void
+    {
+        $this->setData(ContentEntryInterface::KEY, $key);
+    }
+
     /**
      * @param string $identifier
      */
-- 
GitLab