本文整理汇总了PHP中Magento\Framework\Session\Generic类的典型用法代码示例。如果您正苦于以下问题:PHP Generic类的具体用法?PHP Generic怎么用?PHP Generic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Generic类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param CustomerViewHelper $customerViewHelper
* @param \Magento\Framework\Session\Generic $testimonialSession
*/
public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Customer\Model\Session $customerSession, CustomerViewHelper $customerViewHelper, \Magento\Framework\Session\Generic $testimonialSession)
{
$this->_customerSession = $customerSession;
$this->_customerViewHelper = $customerViewHelper;
$this->_data = $testimonialSession->getFormData(true);
parent::__construct($context);
}
开发者ID:swissup,项目名称:testimonials,代码行数:13,代码来源:Form.php
示例2: setUp
/**
* Set up before test
*
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setUp()
{
$this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->_installerMock = $this->getMock('\\Magento\\Install\\Model\\Installer', array('isApplicationInstalled'), array(), '', false);
$this->_installerMock->expects($this->any())->method('isApplicationInstalled')->will($this->returnValue(true));
$this->_blockMock = $this->getMock('\\Magento\\Install\\Block\\Locale', array(), array(), '', false);
$this->_layoutMock = $this->getMock('\\Magento\\Framework\\View\\Layout', array('getBlock', 'initMessages', 'addBlock'), array(), '', false);
$this->_layoutMock->expects($this->any())->method('initMessages')->withAnyParameters()->will($this->returnValue(true));
$this->_layoutMock->expects($this->any())->method('addBlock')->withAnyParameters()->will($this->returnValue(true));
$this->_viewMock = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\ViewInterface', array(), '', false, false, true, array('getLayout'));
$this->_viewMock->expects($this->any())->method('getLayout')->withAnyParameters()->will($this->returnValue($this->_layoutMock));
$this->_requestMock = $this->_getClearMock('\\Magento\\Framework\\App\\RequestInterface');
$this->_responseMock = $this->_getClearMock('\\Magento\\Framework\\App\\ResponseInterface');
$this->_actionFlagMock = $this->_getClearMock('\\Magento\\Framework\\App\\ActionFlag');
$this->_contextMock = $this->getMock('\\Magento\\Framework\\App\\Action\\Context', array('getView', 'getRequest', 'getResponse', 'getActionFlag'), array(), '', false);
$this->_contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->_viewMock));
$this->_contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->_requestMock));
$this->_contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->_responseMock));
$this->_contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->_actionFlagMock));
$this->_blockContextMock = $this->getMock('\\Magento\\Framework\\View\\Element\\Template\\Context', array(), array(), '', false);
$this->_wizardMock = $this->getMock('\\Magento\\Install\\Model\\Wizard', array('getStepByRequest'), array(), '', false);
$this->_wizardMock->expects($this->any())->method('getStepByRequest')->withAnyParameters()->will($this->returnValue(false));
$this->_sessionMock = $this->getMock('\\Magento\\Framework\\Session\\Generic', array('getLocale'), array(), '', false);
$this->_sessionMock->expects($this->any())->method('getLocale')->will($this->returnValue(self::LOCALE));
$this->_block = $this->_objectManager->getObject('Magento\\Install\\Block\\Locale', array('context' => $this->_blockContextMock, 'installer' => $this->_installerMock, 'installWizard' => $this->_wizardMock, 'session' => $this->_sessionMock, 'data' => array()));
$this->_layoutMock->expects($this->any())->method('getBlock')->with('install.locale')->will($this->returnValue($this->_block));
$this->_controller = $this->_objectManager->getObject('Magento\\Install\\Controller\\Wizard\\Locale', array('context' => $this->_contextMock, 'configScope' => $this->_getClearMock('Magento\\Framework\\Config\\Scope'), 'installer' => $this->_getClearMock('Magento\\Install\\Model\\Installer'), 'wizard' => $this->_wizardMock, 'session' => $this->_sessionMock, 'dbUpdater' => $this->_getClearMock('Magento\\Framework\\Module\\UpdaterInterface'), 'storeManager' => $this->_getClearMock('Magento\\Store\\Model\\StoreManagerInterface'), 'appState' => $this->_getClearMock('Magento\\Framework\\App\\State')));
}
开发者ID:,项目名称:,代码行数:34,代码来源:
示例3: execute
/**
* Register form key in session from cookie value
*
* @return void
*/
public function execute()
{
$formKeyFromCookie = $this->_formKey->get();
if ($formKeyFromCookie) {
$this->_session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->_escaper->escapeHtml($formKeyFromCookie));
}
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:12,代码来源:RegisterFormKeyFromCookie.php
示例4: execute
/**
* Initiate a session for unregistered users. Send back the session id.
*
* @return void
*/
public function execute()
{
$this->session->start('frontend');
$this->session->setUserId(0);
$this->session->setUserType(UserIdentifier::USER_TYPE_GUEST);
$this->session->regenerateId(true);
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:Anonymous.php
示例5: savePaymentInQuote
/**
* Saves payment information in quote
*
* @param Object $response
* @return void
*/
public function savePaymentInQuote($response)
{
$quote = $this->quoteRepository->get($this->sessionTransparent->getQuoteId());
/** @var InfoInterface $payment */
$payment = $this->paymentManagement->get($quote->getId());
$payment->setAdditionalInformation('pnref', $response->getPnref());
$this->errorHandler->handle($payment, $response);
$this->paymentManagement->set($quote->getId(), $payment);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Transaction.php
示例6: testExecute
public function testExecute()
{
//Data
$formKey = '<asdfaswqrwqe12>';
$escapedFormKey = 'asdfaswqrwqe12';
//Verification
$this->_formKey->expects($this->once())->method('get')->will($this->returnValue($formKey));
$this->_escaper->expects($this->once())->method('escapeHtml')->with($formKey)->will($this->returnValue($escapedFormKey));
$this->_session->expects($this->once())->method('setData')->with(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $escapedFormKey);
$this->_model->execute();
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:11,代码来源:RegisterFormKeyFromCookieTest.php
示例7: bindLocale
/**
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function bindLocale($observer)
{
$locale = $observer->getEvent()->getLocale();
if ($locale) {
$choosedLocale = $this->_session->getLocale();
if ($choosedLocale) {
$locale->setLocaleCode($choosedLocale);
}
}
return $this;
}
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Observer.php
示例8: getEnteredData
/**
* Retrieve Entered Data by key
*
* @param string $key
* @return string|null
*/
public function getEnteredData($key)
{
if ($this->_enteredData === null) {
$this->_enteredData = $this->_wishlistSession->getData('sharing_form', true);
}
if (!$this->_enteredData || !isset($this->_enteredData[$key])) {
return null;
} else {
return $this->escapeHtml($this->_enteredData[$key]);
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Sharing.php
示例9: execute
/**
* Send request to PayfloPro gateway for get Secure Token
*
* @return ResultInterface
*/
public function execute()
{
$this->sessionTransparent->setQuoteId($this->sessionManager->getQuote()->getId());
$token = $this->secureTokenService->requestToken($this->sessionManager->getQuote());
$result = [];
$result[$this->transparent->getCode()]['fields'] = $token->getData();
$result['success'] = $token->getSecuretoken() ? true : false;
if (!$result['success']) {
$result['error'] = true;
$result['error_messages'] = __('Secure Token Error. Try again.');
}
return $this->resultJsonFactory->create()->setData($result);
}
开发者ID:nja78,项目名称:magento2,代码行数:18,代码来源:RequestSecureToken.php
示例10: getFormData
/**
* Retrieve configuration form data object
*
* @return \Magento\Framework\Object
*/
public function getFormData()
{
$data = $this->getData('form_data');
if (is_null($data)) {
$data = $this->_session->getConfigData(true);
if (empty($data)) {
$data = $this->_installerConfig->getFormData();
} else {
$data = new \Magento\Framework\Object($data);
}
$this->setFormData($data);
}
return $data;
}
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:Type.php
示例11: testSavePaymentInQuote
public function testSavePaymentInQuote()
{
$quoteId = 1;
$response = new DataObject();
$payment = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock();
$payment->expects($this->once())->method('setAdditionalInformation')->with('pnref');
$this->errorHandlerMock->expects($this->once())->method('handle')->with($payment, $response);
$quote = $this->getMock('Magento\\Quote\\Api\\Data\\CartInterface', [], [], '', false);
$quote->expects($this->exactly(2))->method('getId')->willReturn($quoteId);
$this->sessionTransparent->expects($this->once())->method('getQuoteId')->willReturn($quoteId);
$this->quoteRepository->expects($this->once())->method('get')->willReturn($quote);
$this->paymentMethodManagementInterface->expects($this->once())->method('get')->willReturn($payment);
$this->paymentMethodManagementInterface->expects($this->once())->method('set');
$this->model->savePaymentInQuote($response);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:TransactionTest.php
示例12: execute
/**
* Check CAPTCHA on New Testmonial page
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$formId = 'testimonial_new';
$captcha = $this->_helper->getCaptcha($formId);
if ($captcha->isRequired()) {
/** @var \Magento\Framework\App\Action\Action $controller */
$controller = $observer->getControllerAction();
if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
$this->_testimonialSession->setFormData($controller->getRequest()->getPost());
$this->messageManager->addError(__('Incorrect CAPTCHA.'));
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->redirect->redirect($controller->getResponse(), $this->redirect->getRefererUrl());
}
}
}
开发者ID:swissup,项目名称:testimonials,代码行数:21,代码来源:CheckTestimonialFormObserver.php
示例13: execute
/**
* Login registered users and initiate a session. Send back the session id.
*
* Expects a POST. ex for JSON {"username":"[email protected]", "password":"userpassword"}
*
* @return void
*/
public function execute()
{
$contentTypeHeaderValue = $this->getRequest()->getHeader('Content-Type');
$contentType = $this->getContentType($contentTypeHeaderValue);
$loginData = null;
try {
$loginData = $this->deserializerFactory->get($contentType)->deserialize($this->getRequest()->getRawBody());
} catch (Exception $e) {
$this->getResponse()->setHttpResponseCode($e->getCode());
return;
}
if (!$loginData || $this->getRequest()->getMethod() !== \Magento\Webapi\Model\Rest\Config::HTTP_METHOD_POST) {
$this->getResponse()->setHttpResponseCode(HttpException::HTTP_BAD_REQUEST);
return;
}
$customerData = null;
try {
$customerData = $this->customerAccountService->authenticate($loginData['username'], $loginData['password']);
} catch (AuthenticationException $e) {
$this->getResponse()->setHttpResponseCode(HttpException::HTTP_UNAUTHORIZED);
return;
}
$this->session->start('frontend');
$this->session->setUserId($customerData->getId());
$this->session->setUserType(UserIdentifier::USER_TYPE_CUSTOMER);
$this->session->regenerateId(true);
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:34,代码来源:Index.php
示例14: testGetSessionIdQueryParamCustom
public function testGetSessionIdQueryParamCustom()
{
$oldSessionName = $this->session->getName();
$this->session->setName($this->customSessionName);
$this->assertEquals($this->customSessionQueryParam, $this->model->getSessionIdQueryParam($this->session));
$this->session->setName($oldSessionName);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:SidResolverTest.php
示例15: testSessionUrlVarWithoutMatchedHostsAndBaseUrl
public function testSessionUrlVarWithoutMatchedHostsAndBaseUrl()
{
$requestMock = $this->getRequestMock();
$model = $this->getUrlModel(
[
'session' => $this->sessionMock,
'request' => $requestMock,
'sidResolver' => $this->sidResolverMock,
'scopeResolver' => $this->scopeResolverMock,
'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
]
);
$requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('localhost'));
$this->scopeMock->expects($this->once())
->method('getBaseUrl')
->will($this->returnValue('http://example.com'));
$this->scopeResolverMock->expects($this->any())
->method('getScope')
->will($this->returnValue($this->scopeMock));
$this->sidResolverMock->expects($this->once())->method('getSessionIdQueryParam')
->will($this->returnValue('SID'));
$this->sessionMock->expects($this->once())->method('getSessionId')
->will($this->returnValue('session-id'));
$this->assertEquals(
'<a href="http://example.com/?SID=session-id">www.example.com</a>',
$model->sessionUrlVar('<a href="http://example.com/?___SID=U">www.example.com</a>')
);
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:30,代码来源:UrlTest.php
示例16: registerFormKeyFromCookie
/**
* Register form key in session from cookie value
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function registerFormKeyFromCookie(\Magento\Framework\Event\Observer $observer)
{
$formKeyFromCookie = $this->_formKey->get();
if ($formKeyFromCookie) {
$this->_session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->_escaper->escapeHtml($formKeyFromCookie));
}
}
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Observer.php
示例17: testExecute
/**
* Run test execute method
*
* @param array $result
* @param array $resultExpectation
*
* @dataProvider executeDataProvider
*/
public function testExecute(array $result, array $resultExpectation)
{
$quoteId = 99;
$quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
$tokenMock = $this->getMockBuilder('Magento\\Framework\\Object')->setMethods(['getData', 'getSecuretoken'])->disableOriginalConstructor()->getMock();
$jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
$this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
$this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
$quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
$this->sessionTransparentMock->expects($this->once())->method('setQuoteId')->with($quoteId);
$this->secureTokenServiceMock->expects($this->once())->method('requestToken')->with($quoteMock)->willReturn($tokenMock);
$this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
$tokenMock->expects($this->once())->method('getData')->willReturn($result['transparent']['fields']);
$tokenMock->expects($this->once())->method('getSecuretoken')->willReturn($result['success']);
$this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
$jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
$this->assertEquals($jsonMock, $this->controller->execute());
}
开发者ID:nja78,项目名称:magento2,代码行数:26,代码来源:RequestSecureTokenTest.php
示例18: executeInternal
/**
* Send request to PayfloPro gateway for get Secure Token
*
* @return ResultInterface
*/
public function executeInternal()
{
/** @var Quote $quote */
$quote = $this->sessionManager->getQuote();
if (!$quote or !$quote instanceof Quote) {
return $this->getErrorResponse();
}
$this->sessionTransparent->setQuoteId($quote->getId());
try {
$token = $this->secureTokenService->requestToken($quote);
if (!$token->getData('securetoken')) {
throw new \LogicException();
}
return $this->resultJsonFactory->create()->setData([$this->transparent->getCode() => ['fields' => $token->getData()], 'success' => true, 'error' => false]);
} catch (\Exception $e) {
return $this->getErrorResponse();
}
}
开发者ID:nblair,项目名称:magescotch,代码行数:23,代码来源:RequestSecureToken.php
示例19: testToHtmlCoreRegistryRatingData
public function testToHtmlCoreRegistryRatingData()
{
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->rating));
$this->form->expects($this->at(7))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->at(13))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->at(16))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->at(17))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->any())->method('getElement')->will($this->returnValue(false));
$this->session->expects($this->any())->method('getRatingData')->will($this->returnValue(false));
$ratingCodes = ['rating_codes' => ['0' => 'rating_code']];
$this->rating->expects($this->any())->method('getRatingCodes')->will($this->returnValue($ratingCodes));
$this->block->toHtml();
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:FormTest.php
示例20: testExecuteTokenRequestException
public function testExecuteTokenRequestException()
{
$quoteId = 99;
$resultExpectation = ['success' => false, 'error' => true, 'error_messages' => __('Your payment has been declined. Please try again.')];
$quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
$jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
$this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
$quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
$this->sessionTransparentMock->expects($this->once())->method('setQuoteId')->with($quoteId);
$this->secureTokenServiceMock->expects($this->once())->method('requestToken')->with($quoteMock)->willThrowException(new \Exception());
$this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
$jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
$this->assertEquals($jsonMock, $this->controller->execute());
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:RequestSecureTokenTest.php
注:本文中的Magento\Framework\Session\Generic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论