forked from magespecialist/m2-MSP_APIEnhancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a24c6fa
Showing
34 changed files
with
1,841 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
} |
Oops, something went wrong.