Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix128 committed Jun 12, 2017
0 parents commit a24c6fa
Show file tree
Hide file tree
Showing 34 changed files with 1,841 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
38 changes: 38 additions & 0 deletions Api/CacheKeyProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Api;

/**
* Interface CacheKeyProcessorInterface
*
* ONLY FOR INTERNAL CACHE USAGE.
* If you are using Varnish see: VarnishTokenProcessorInterface
*
* @package MSP\APIEnhancer\Api
*/
interface CacheKeyProcessorInterface
{
/**
* Return a list of cache keys for a request
* @return array
*/
public function getKeys();
}
37 changes: 37 additions & 0 deletions Api/CacheManagementInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Api;

interface CacheManagementInterface
{
/**
* Get a cache response or false if not existing
* @return \Magento\Framework\App\ResponseInterface|false
*/
public function getCacheResult();

/**
* Set a cache response for a request
* @param \Magento\Framework\App\ResponseInterface $response
* @return void
*/
public function setCacheResult(\Magento\Framework\App\ResponseInterface $response);
}
30 changes: 30 additions & 0 deletions Api/CustomerAuthInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Api;

interface CustomerAuthInterface
{
/**
* Get customer by oauth token
* @return \Magento\Customer\Api\Data\CustomerInterface|false
*/
public function getCustomer();
}
42 changes: 42 additions & 0 deletions Api/EnhancerManagementInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Api;

interface EnhancerManagementInterface
{
/**
* Return true if FPC is handled by Varnish
* @return bool
*/
public function useVarnish();

/**
* Return true if can cache this request
* @return bool
*/
public function canCacheRequest();

/**
* Return true if cache is enabled
* @return bool
*/
public function isCacheEnabled();
}
37 changes: 37 additions & 0 deletions Api/TagInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Api;

interface TagInterface
{
/**
* Return a list of collected tags
* @return array
*/
public function getTags();

/**
* Return a list of collected tags
* @param array $tags
* @return $this
*/
public function addTags(array $tags);
}
38 changes: 38 additions & 0 deletions Api/VarnishManagementInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Api;

interface VarnishManagementInterface
{
/**
* Get new token with vary information
* @param string $originalToken
* @return string
*/
public function getVaryToken($originalToken);

/**
* Inject varnish cache headers in response
* @param \Magento\Framework\App\ResponseInterface $response
* @return void
*/
public function setVarnishHeaders(\Magento\Framework\App\ResponseInterface $response);
}
40 changes: 40 additions & 0 deletions Api/VarnishTokenProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Api;

/**
* Interface CacheKeyProcessorInterface
*
* ONLY FOR VARNISH CACHE USAGE.
* If you are not using Varnish see: CacheKeyProcessorInterface
*
* @package MSP\APIEnhancer\Api
*/
interface VarnishTokenProcessorInterface
{
/**
* Return a list of cache keys for a request
* @param string $token
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @return array
*/
public function getKeys($token, \Magento\Customer\Api\Data\CustomerInterface $customer);
}
53 changes: 53 additions & 0 deletions Model/CacheKeyProcessor/Base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Model\CacheKeyProcessor;

use Magento\Framework\App\RequestInterface;
use MSP\APIEnhancer\Api\CacheKeyProcessorInterface;

/**
* This class is only for non-Varnish use
*/
class Base implements CacheKeyProcessorInterface
{
/**
* @var RequestInterface
*/
private $request;

public function __construct(RequestInterface $request)
{
$this->request = $request;
}

/**
* Return a list of cache keys for a request
* @return array
*/
public function getKeys()
{
return [
$this->request->getMethod(),
$this->request->getRequestUri(),
$this->request->getHeader('Content-Type'),
];
}
}
51 changes: 51 additions & 0 deletions Model/CacheKeyProcessor/Group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to info@magespecialist.it so we can send you a copy immediately.
*
* @category MSP
* @package MSP_APIEnhancer
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\APIEnhancer\Model\CacheKeyProcessor;

use MSP\APIEnhancer\Api\CacheKeyProcessorInterface;
use MSP\APIEnhancer\Api\CustomerAuthInterface;

class Group implements CacheKeyProcessorInterface
{
/**
* @var CustomerAuthInterface
*/
private $customerAuth;

public function __construct(
CustomerAuthInterface $customerAuth
) {
$this->customerAuth = $customerAuth;
}

/**
* Return a list of cache keys for a request
* @return array
*/
public function getKeys()
{
if ($customer = $this->customerAuth->getCustomer()) {
return [$customer->getGroupId()];
}

return [0];
}
}
Loading

0 comments on commit a24c6fa

Please sign in to comment.