本文整理汇总了PHP中Magento\Backend\App\ConfigInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ConfigInterface类的具体用法?PHP ConfigInterface怎么用?PHP ConfigInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(\Magento\Backend\App\ConfigInterface $backendConfig, \Symfony\Component\Yaml\Parser $yamlParser, \Magento\Framework\Filesystem $filesystem, \Magento\Config\Model\Config\Factory $configFactory)
{
$this->_yamlParser = $yamlParser;
$this->_backendConfig = $backendConfig;
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$this->_folderLocation = str_replace('###MAGE_BASE###', $this->_getBaseDir(), $this->_backendConfig->getValue(self::XML_SYSTEM_PATH));
$this->_configFactory = $configFactory;
}
示例2: __construct
/**
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Framework\ObjectManager\ConfigInterface $config
*/
public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\ObjectManager\ConfigInterface $config, \Magento\Backend\App\ConfigInterface $backendConfig, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Module\ResourceInterface $moduleResource, \Magento\Framework\Module\ModuleList\Loader $loader, \Magento\Framework\Xml\Parser $parser, \Magento\Framework\Filesystem\Driver\File $driver, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\ProductMetadataInterface $productMetadata, \Magento\Framework\ObjectManagerInterface $objectManager)
{
$this->_backendConfig = $backendConfig;
$this->moduleList = $moduleList;
$this->moduleResource = $moduleResource;
$this->_loader = $loader;
$this->parser = $parser;
$this->driver = $driver;
$this->_objectManager = $objectManager;
$this->urlBuilder = $urlBuilder;
$this->productMetadata = $productMetadata;
$this->_allowedFeedType = explode(',', $backendConfig->getValue(\Ced\DevTool\Model\Feed::XML_FEED_TYPES));
parent::__construct($context);
}
示例3: testCheckUpdate
/**
* @dataProvider checkUpdateDataProvider
* @param bool $callInbox
* @param string $curlRequest
*/
public function testCheckUpdate($callInbox, $curlRequest)
{
$mockName = 'Test Product Name';
$mockVersion = '0.0.0';
$mockEdition = 'Test Edition';
$mockUrl = 'http://test-url';
$this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
$this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
$this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
$configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
$lastUpdate = 0;
$this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
$this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
$this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
if ($callInbox) {
$this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
$this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
} else {
$this->inboxFactory->expects($this->never())->method('create');
$this->inboxModel->expects($this->never())->method('parse');
}
$this->feed->checkUpdate();
}
示例4: getFrontName
/**
* Retrieve area front name
*
* @return string
*/
public function getFrontName()
{
$isCustomPathUsed = (bool) (string) $this->config->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_PATH);
if ($isCustomPathUsed) {
return (string) $this->config->getValue(self::XML_PATH_CUSTOM_ADMIN_PATH);
}
return $this->defaultFrontName;
}
示例5: getFrontName
/**
* Retrieve area front name
*
* @param bool $checkHost If true, verify front name is valid for this url (hostname is correct)
* @return string|bool
*/
public function getFrontName($checkHost = false)
{
if ($checkHost && !$this->isHostBackend()) {
return false;
}
$isCustomPathUsed = (bool)(string)$this->config->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_PATH);
if ($isCustomPathUsed) {
return (string)$this->config->getValue(self::XML_PATH_CUSTOM_ADMIN_PATH);
}
return $this->defaultFrontName;
}
示例6: _canShowNotification
/**
* Check verification result and return true if system must to show notification message
*
* @return bool
*/
private function _canShowNotification()
{
if ($this->_cache->load(self::VERIFICATION_RESULT_CACHE_KEY)) {
return false;
}
if ($this->_isFileAccessible()) {
return true;
}
$adminSessionLifetime = (int) $this->_backendConfig->getValue('admin/security/session_lifetime');
$this->_cache->save(true, self::VERIFICATION_RESULT_CACHE_KEY, [], $adminSessionLifetime);
return false;
}
示例7: authenticate
/**
* Authenticate user name and password and save loaded record
*
* @param string $username
* @param string $password
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function authenticate($username, $password)
{
$config = $this->_config->isSetFlag('admin/security/use_case_sensitive_login');
$result = false;
try {
$this->_eventManager->dispatch(
'admin_user_authenticate_before',
['username' => $username, 'user' => $this]
);
$this->loadByUsername($username);
$sensitive = $config ? $username == $this->getUsername() : true;
if ($sensitive && $this->getId()) {
$result = $this->verifyIdentity($password);
}
$this->_eventManager->dispatch(
'admin_user_authenticate_after',
['username' => $username, 'password' => $password, 'user' => $this, 'result' => $result]
);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->unsetData();
throw $e;
}
if (!$result) {
$this->unsetData();
}
return $result;
}
示例8: testAuthenticateException
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
* @return void
*/
public function testAuthenticateException()
{
$username = 'username';
$password = 'password';
$config = 'config';
$this->configMock->expects($this->once())->method('isSetFlag')->with('admin/security/use_case_sensitive_login')->willReturn($config);
$this->eventManagerMock->expects($this->any())->method('dispatch');
$this->resourceMock->expects($this->once())->method('loadByUsername')->willThrowException(new \Magento\Framework\Exception\LocalizedException(__()));
$this->model->authenticate($username, $password);
}
示例9: prolong
/**
* Set session UpdatedAt to current time and update cookie expiration time
*
* @return void
*/
public function prolong()
{
$lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
$currentTime = time();
$this->setUpdatedAt($currentTime);
$cookieValue = $this->_cookie->get($this->getName());
if ($cookieValue) {
$this->_cookie->set($this->getName(), $cookieValue, $lifetime, $this->sessionConfig->getCookiePath(), $this->sessionConfig->getCookieDomain(), $this->sessionConfig->getCookieSecure(), $this->sessionConfig->getCookieHttpOnly());
}
}
示例10: prolong
/**
* Set session UpdatedAt to current time and update cookie expiration time
*
* @return void
*/
public function prolong()
{
$lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
$currentTime = time();
$this->setUpdatedAt($currentTime);
$cookieValue = $this->cookieManager->getCookie($this->getName());
if ($cookieValue) {
$cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration($lifetime)->setPath($this->sessionConfig->getCookiePath())->setDomain($this->sessionConfig->getCookieDomain())->setSecure($this->sessionConfig->getCookieSecure())->setHttpOnly($this->sessionConfig->getCookieHttpOnly());
$this->cookieManager->setPublicCookie($this->getName(), $cookieValue, $cookieMetadata);
}
}
示例11: testTrackAdminPassword
public function testTrackAdminPassword()
{
$newPW = "mYn3wpassw0rd";
$uid = 123;
/** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
$eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
/** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
$eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getObject'])->getMock();
/** @var \Magento\User\Model\User|\PHPUnit_Framework_MockObject_MockObject $userMock */
$userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getPassword', 'getForceNewPassword'])->getMock();
$eventObserverMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
$eventMock->expects($this->once())->method('getObject')->willReturn($userMock);
$userMock->expects($this->once())->method('getId')->willReturn($uid);
$userMock->expects($this->once())->method('getPassword')->willReturn($newPW);
$this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
$userMock->expects($this->once())->method('getForceNewPassword')->willReturn(false);
/** @var \Magento\Framework\Message\Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
$collectionMock = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods([])->getMock();
$this->managerInterfaceMock->expects($this->once())->method('getMessages')->willReturn($collectionMock);
$this->authSessionMock->expects($this->once())->method('unsPciAdminUserIsPasswordExpired')->willReturn(null);
$this->model->execute($eventObserverMock);
}
示例12: isLoggedIn
/**
* Check if user is logged in
*
* @return boolean
*/
public function isLoggedIn()
{
$lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
$currentTime = time();
/* Validate admin session lifetime that should be more than 60 seconds */
if ($lifetime >= 60 && $this->getUpdatedAt() < $currentTime - $lifetime) {
return false;
}
if ($this->getUser() && $this->getUser()->getId()) {
return true;
}
return false;
}
示例13: testCustomerHasFailedMaxNumberOfAttempts
/**
* @return void
*/
public function testCustomerHasFailedMaxNumberOfAttempts()
{
$customerId = 1;
$date = new \DateTime();
$date->modify('-500 second');
$formattedDate = $date->format('Y-m-d H:i:s');
$this->backendConfigMock->expects($this->exactly(2))->method('getValue')->withConsecutive([\Magento\Customer\Helper\AccountManagement::LOCKOUT_THRESHOLD_PATH], [\Magento\Customer\Helper\AccountManagement::MAX_FAILURES_PATH])->willReturnOnConsecutiveCalls(10, 5);
$this->customerRegistryMock->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
$this->customerSecure->expects($this->once())->method('getFailuresNum')->willReturn(5);
$this->customerSecure->expects($this->once())->method('getFirstFailure')->willReturn($formattedDate);
$this->customerSecure->expects($this->once())->method('setLockExpires');
$this->customerSecure->expects($this->once())->method('setFailuresNum');
$this->helper->processCustomerLockoutData($customerId);
}
示例14: testForceAdminPasswordChange
public function testForceAdminPasswordChange()
{
/** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
$eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
/** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
$eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getControllerAction', 'getRequest'])->getMock();
$this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
$this->authSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
$eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
/** @var \Magento\Framework\App\Action\Action $controllerMock */
$controllerMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\AbstractAction')->disableOriginalConstructor()->setMethods(['getRedirect', 'getRequest'])->getMockForAbstractClass();
/** @var \Magento\Framework\App\RequestInterface $requestMock */
$requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getFullActionName', 'setDispatched'])->getMockForAbstractClass();
$eventMock->expects($this->once())->method('getControllerAction')->willReturn($controllerMock);
$eventMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
$this->authSessionMock->expects($this->once())->method('getPciAdminUserIsPasswordExpired')->willReturn(true);
$requestMock->expects($this->once())->method('getFullActionName')->willReturn('not_in_array');
$this->authSessionMock->expects($this->once())->method('clearStorage');
$this->sessionMock->expects($this->once())->method('clearStorage');
$this->managerInterfaceMock->expects($this->once())->method('addErrorMessage');
$controllerMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
$requestMock->expects($this->once())->method('setDispatched')->willReturn(false);
$this->model->execute($eventObserverMock);
}
示例15: testSendPasswordResetConfirmationEmail
public function testSendPasswordResetConfirmationEmail()
{
$storeId = 0;
$email = 'test@example.com';
$firstName = 'Foo';
$lastName = 'Bar';
$this->_model->setEmail($email);
$this->_model->setFirstname($firstName);
$this->_model->setLastname($lastName);
$this->_configMock->expects($this->at(0))->method('getValue')->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_TEMPLATE)->will($this->returnValue('templateId'));
$this->_configMock->expects($this->at(1))->method('getValue')->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_IDENTITY)->will($this->returnValue('sender'));
$this->_transportBuilderMock->expects($this->once())->method('setTemplateOptions')->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(['user' => $this->_model, 'store' => $this->_storetMock])->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('addTo')->with($this->equalTo($email), $this->equalTo($firstName . ' ' . $lastName))->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('setFrom')->with('sender')->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with('templateId')->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transportMock));
$this->_transportMock->expects($this->once())->method('sendMessage');
$this->_storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnValue($this->_storetMock));
$this->assertInstanceOf('\\Magento\\User\\Model\\User', $this->_model->sendPasswordResetConfirmationEmail());
}