Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /** * Collection of the available product link types * * Copyright Magento, Inc...
Decoded Output download
<?php
/**
* Collection of the available product link types
*
* Copyright Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\Product;
class LinkTypeProvider implements \Magento\Catalog\Api\ProductLinkTypeListInterface
{
/**
* Available product link types
*
* Represented by an assoc array with the following format 'product_link_name' => 'product_link_code'
*
* @var array
*/
protected $linkTypes;
/**
* @var \Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory
*/
protected $linkTypeFactory;
/**
* @var \Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory
*/
protected $linkAttributeFactory;
/**
* @var \Magento\Catalog\Model\Product\LinkFactory
*/
protected $linkFactory;
/**
* @param \Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory $linkTypeFactory
* @param \Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory $linkAttributeFactory
* @param LinkFactory $linkFactory
* @param array $linkTypes
*/
public function __construct(
\Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory $linkTypeFactory,
\Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory $linkAttributeFactory,
\Magento\Catalog\Model\Product\LinkFactory $linkFactory,
array $linkTypes = []
) {
$this->linkTypes = $linkTypes;
$this->linkTypeFactory = $linkTypeFactory;
$this->linkAttributeFactory = $linkAttributeFactory;
$this->linkFactory = $linkFactory;
}
/**
* Retrieve information about available product link types
*
* @return array
*/
public function getLinkTypes()
{
return $this->linkTypes;
}
/**
* {@inheritdoc}
*/
public function getItems()
{
$output = [];
foreach ($this->getLinkTypes() as $type => $typeCode) {
/** @var \Magento\Catalog\Api\Data\ProductLinkTypeInterface $linkType */
$linkType = $this->linkTypeFactory->create();
$linkType->setName($type)
->setCode($typeCode);
$output[] = $linkType;
}
return $output;
}
/**
* {@inheritdoc}
*/
public function getItemAttributes($type)
{
$output = [];
$types = $this->getLinkTypes();
$typeId = isset($types[$type]) ? $types[$type] : null;
/** @var \Magento\Catalog\Model\Product\Link $link */
$link = $this->linkFactory->create(['data' => ['link_type_id' => $typeId]]);
$attributes = $link->getAttributes();
foreach ($attributes as $item) {
/** @var \Magento\Catalog\Api\Data\ProductLinkAttributeInterface $linkAttribute */
$linkAttribute = $this->linkAttributeFactory->create();
$linkAttribute->setCode($item['code'])
->setType($item['type']);
$output[] = $linkAttribute;
}
return $output;
}
}
?>
Did this file decode correctly?
Original Code
<?php
/**
* Collection of the available product link types
*
* Copyright Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\Product;
class LinkTypeProvider implements \Magento\Catalog\Api\ProductLinkTypeListInterface
{
/**
* Available product link types
*
* Represented by an assoc array with the following format 'product_link_name' => 'product_link_code'
*
* @var array
*/
protected $linkTypes;
/**
* @var \Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory
*/
protected $linkTypeFactory;
/**
* @var \Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory
*/
protected $linkAttributeFactory;
/**
* @var \Magento\Catalog\Model\Product\LinkFactory
*/
protected $linkFactory;
/**
* @param \Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory $linkTypeFactory
* @param \Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory $linkAttributeFactory
* @param LinkFactory $linkFactory
* @param array $linkTypes
*/
public function __construct(
\Magento\Catalog\Api\Data\ProductLinkTypeInterfaceFactory $linkTypeFactory,
\Magento\Catalog\Api\Data\ProductLinkAttributeInterfaceFactory $linkAttributeFactory,
\Magento\Catalog\Model\Product\LinkFactory $linkFactory,
array $linkTypes = []
) {
$this->linkTypes = $linkTypes;
$this->linkTypeFactory = $linkTypeFactory;
$this->linkAttributeFactory = $linkAttributeFactory;
$this->linkFactory = $linkFactory;
}
/**
* Retrieve information about available product link types
*
* @return array
*/
public function getLinkTypes()
{
return $this->linkTypes;
}
/**
* {@inheritdoc}
*/
public function getItems()
{
$output = [];
foreach ($this->getLinkTypes() as $type => $typeCode) {
/** @var \Magento\Catalog\Api\Data\ProductLinkTypeInterface $linkType */
$linkType = $this->linkTypeFactory->create();
$linkType->setName($type)
->setCode($typeCode);
$output[] = $linkType;
}
return $output;
}
/**
* {@inheritdoc}
*/
public function getItemAttributes($type)
{
$output = [];
$types = $this->getLinkTypes();
$typeId = isset($types[$type]) ? $types[$type] : null;
/** @var \Magento\Catalog\Model\Product\Link $link */
$link = $this->linkFactory->create(['data' => ['link_type_id' => $typeId]]);
$attributes = $link->getAttributes();
foreach ($attributes as $item) {
/** @var \Magento\Catalog\Api\Data\ProductLinkAttributeInterface $linkAttribute */
$linkAttribute = $this->linkAttributeFactory->create();
$linkAttribute->setCode($item['code'])
->setType($item['type']);
$output[] = $linkAttribute;
}
return $output;
}
}
Function Calls
None |
Stats
MD5 | 55a7d074084b534d3cc2a71f11d54a50 |
Eval Count | 0 |
Decode Time | 110 ms |