Skip to content

Commit

Permalink
Merge pull request #3 from alaa-almaliki/upgrade-v2.0.0
Browse files Browse the repository at this point in the history
Upgrade to version 2.0.0
  • Loading branch information
alaa-almaliki authored Dec 23, 2018
2 parents 7172a01 + f9b7601 commit 7cf1803
Show file tree
Hide file tree
Showing 44 changed files with 1,809 additions and 214 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.DS_STORE
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
<?php
/**
* @copyright 2018 Alaa Al-Maliki <[email protected]>
* @license MIT
*/

declare(strict_types=1);

namespace Alaa\XmlFeedModel\Block\Adminhtml\System\Config\Form\Field\FieldArray;

use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;

/**
* Class SubjectFieldArray
* @package Alaa\XmlFeedModel\Block\Adminhtml\System\Config\Form\Field\FieldArray
* @author Alaa Al-Maliki <[email protected]>
*
* @package Alaa\XmlFeedModel\Block\Adminhtml\System\Config\Form\Field\FieldArray
* @author Alaa Al-Maliki <[email protected]>
* @SuppressWarnings(PHPMD)
*/
class SubjectFieldArray extends AbstractFieldArray
{
/**
* Prepare fields
* @inheritdoc
*
* @SuppressWarnings(PHPMD)
* @codingStandardsIgnoreStart
*/
protected function _prepareToRender()
{
$this->addColumn('custom_attribute', [ 'label' => __('Custom Attribute')]);
$this->addColumn('magento_attribute', [ 'label' => __('Magento Attribute')]);
$this->addColumn('custom_attribute', [ 'label' => __('Custom Attribute')]);
$this->_addAfter = false;
parent::_prepareToRender();
}
}
//@codingStandardsIgnoreEnd
}
20 changes: 20 additions & 0 deletions Exception/AttributeAlreadyExistsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* @copyright 2018 Alaa Al-Maliki <[email protected]>
* @license MIT
*/

declare(strict_types=1);

namespace Alaa\XmlFeedModel\Exception;

/**
* Class AttributeAlreadyExistsException
*
* @package Alaa\XmlFeedModel\Exception
* @author Alaa Al-Maliki <[email protected]>
*/
class AttributeAlreadyExistsException extends \Exception
{

}
20 changes: 20 additions & 0 deletions Exception/FileNotExistsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* @copyright 2018 Alaa Al-Maliki <[email protected]>
* @license MIT
*/

declare(strict_types=1);

namespace Alaa\XmlFeedModel\Exception;

/**
* Class FileNotExistsException
*
* @package Alaa\XmlFeedModel\Exception
* @author Alaa Al-Maliki <[email protected]>
*/
class FileNotExistsException extends \Exception
{

}
20 changes: 20 additions & 0 deletions Exception/SubjectException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* @copyright 2018 Alaa Al-Maliki <[email protected]>
* @license MIT
*/

declare(strict_types=1);

namespace Alaa\XmlFeedModel\Exception;

/**
* Class SubjectException
*
* @package Alaa\XmlFeedModel\Exception
* @author Alaa Al-Maliki <[email protected]>
*/
class SubjectException extends \Exception
{

}
13 changes: 0 additions & 13 deletions Model/AbstractDataProvider.php

This file was deleted.

77 changes: 0 additions & 77 deletions Model/AbstractXmlGenerator.php

This file was deleted.

21 changes: 0 additions & 21 deletions Model/DataProviderInterface.php

This file was deleted.

81 changes: 0 additions & 81 deletions Model/MagentoSubject.php

This file was deleted.

74 changes: 74 additions & 0 deletions Model/MappedKeys.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* @copyright 2018 Alaa Al-Maliki <[email protected]>
* @license MIT
*/

declare(strict_types=1);

namespace Alaa\XmlFeedModel\Model;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Store\Model\ScopeInterface;

/**
* Class MappedKeys
*
* @package Alaa\XmlFeedModel\Model
* @author Alaa Al-Maliki <[email protected]>
*/
class MappedKeys implements MappedKeysInterface
{
/**
* @var string
*/
protected $xmlPath;

/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;

/**
* @var Json
*/
protected $serializer;

/**
* XmlPathValue constructor.
*
* @param string $xmlPath
* @param ScopeConfigInterface $scopeConfig
* @param Json $serializer
*/
public function __construct(
string $xmlPath,
ScopeConfigInterface $scopeConfig,
Json $serializer
) {
$this->xmlPath = $xmlPath;
$this->scopeConfig = $scopeConfig;
$this->serializer = $serializer;
}

/**
* @param null $store
* @return array
*/
public function getMappedKeys($store = null): array
{
if (!!$this->xmlPath === false) {
return [];
}

$value = (string) $this->scopeConfig
->getValue($this->xmlPath, ScopeInterface::SCOPE_STORE, $store);
$mappedKeys = [];
foreach ($this->serializer->unserialize($value) as $serializedValue) {
$mappedKeys[$serializedValue['magento_attribute']] = $serializedValue['custom_attribute'];
}

return $mappedKeys;
}
}
Loading

0 comments on commit 7cf1803

Please sign in to comment.