当前位置: 首页>>代码示例>>PHP>>正文


PHP Json\EncoderInterface类代码示例

本文整理汇总了PHP中Magento\Framework\Json\EncoderInterface的典型用法代码示例。如果您正苦于以下问题:PHP EncoderInterface类的具体用法?PHP EncoderInterface怎么用?PHP EncoderInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EncoderInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     $this->config = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\Config')->disableOriginalConstructor()->setMethods(['isNewRelicEnabled'])->getMock();
     $this->collectMock = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\Module\\Collect')->disableOriginalConstructor()->setMethods(['getModuleData'])->getMock();
     $this->systemFactoryMock = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\SystemFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->systemModelMock = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\System')->disableOriginalConstructor()->getMock();
     $this->jsonEncoderMock = $this->getMockBuilder('Magento\\Framework\\Json\\EncoderInterface')->getMock();
     $this->systemFactoryMock->expects($this->any())->method('create')->willReturn($this->systemModelMock);
     $this->jsonEncoderMock->expects($this->any())->method('encode')->willReturn('json_string');
     $this->model = new ReportModulesInfo($this->config, $this->collectMock, $this->systemFactoryMock, $this->jsonEncoderMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:ReportModulesInfoTest.php

示例2: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     $this->config = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\Config')->disableOriginalConstructor()->setMethods(['isNewRelicEnabled'])->getMock();
     $this->collect = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\Module\\Collect')->disableOriginalConstructor()->setMethods(['getModuleData'])->getMock();
     $this->systemFactory = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\SystemFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->systemModel = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\System')->disableOriginalConstructor()->getMock();
     $this->jsonEncoder = $this->getMockBuilder('Magento\\Framework\\Json\\EncoderInterface')->getMock();
     $this->dateTime = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime')->disableOriginalConstructor()->setMethods(['formatDate'])->getMock();
     $this->systemFactory->expects($this->any())->method('create')->willReturn($this->systemModel);
     $this->jsonEncoder->expects($this->any())->method('encode')->willReturn('json_string');
     $this->dateTime->expects($this->any())->method('formatDate')->willReturn('1970-01-01 00:00:00');
     $this->model = new ReportModulesInfo($this->config, $this->collect, $this->systemFactory, $this->jsonEncoder, $this->dateTime);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:18,代码来源:ReportModulesInfoTest.php

示例3: report

 /**
  * Reports Modules and module changes to the database reporting_module_status table
  *
  * @return \Magento\NewRelicReporting\Model\Cron\ReportModulesInfo
  */
 public function report()
 {
     if ($this->config->isNewRelicEnabled()) {
         $moduleData = $this->collect->getModuleData();
         if (count($moduleData['changes']) > 0) {
             foreach ($moduleData['changes'] as $change) {
                 switch ($change['type']) {
                     case Config::ENABLED:
                         $modelData = ['type' => Config::MODULE_ENABLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)];
                         break;
                     case Config::DISABLED:
                         $modelData = ['type' => Config::MODULE_DISABLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)];
                         break;
                     case Config::INSTALLED:
                         $modelData = ['type' => Config::MODULE_INSTALLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)];
                         break;
                     case Config::UNINSTALLED:
                         $modelData = ['type' => Config::MODULE_UNINSTALLED, 'action' => $this->jsonEncoder->encode($change), 'updated_at' => $this->dateTime->formatDate(true)];
                         break;
                 }
                 /** @var \Magento\NewRelicReporting\Model\System $systemModel */
                 $systemModel = $this->systemFactory->create();
                 $systemModel->setData($modelData);
                 $systemModel->save();
             }
         }
     }
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:34,代码来源:ReportModulesInfo.php

示例4: getAlists

 public function getAlists($json = false)
 {
     //       return [1];
     $id = $this->getRequest()->getParam('id');
     $collection = $this->_testFactory->create()->setId($id);
     $listso = $this->_objectManager->create('Sugarcode\\Test\\Model\\Test')->load($id);
     $collection = unserialize($listso->getInListsGrid());
     if (sizeof($collection) > 0) {
         if ($json) {
             $jsonLists = [];
             foreach ($collection as $usrid) {
                 $jsonLists[$usrid] = 0;
             }
             return $this->_jsonEncoder->encode((object) $jsonLists);
         } else {
             return array_values($collection);
         }
     } else {
         if ($json) {
             return '{}';
         } else {
             return [];
         }
     }
 }
开发者ID:pradeeprcs,项目名称:TestModule,代码行数:25,代码来源:Gridtabs.php

示例5: install

 /**
  * {@inheritdoc}
  */
 public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     /** @var State[] $stateIndexers */
     $stateIndexers = [];
     $states = $this->statesFactory->create();
     foreach ($states->getItems() as $state) {
         /** @var State $state */
         $stateIndexers[$state->getIndexerId()] = $state;
     }
     foreach ($this->config->getIndexers() as $indexerId => $indexerConfig) {
         $expectedHashConfig = $this->encryptor->hash($this->encoder->encode($indexerConfig), Encryptor::HASH_VERSION_MD5);
         if (isset($stateIndexers[$indexerId])) {
             if ($stateIndexers[$indexerId]->getHashConfig() != $expectedHashConfig) {
                 $stateIndexers[$indexerId]->setStatus(StateInterface::STATUS_INVALID);
                 $stateIndexers[$indexerId]->setHashConfig($expectedHashConfig);
                 $stateIndexers[$indexerId]->save();
             }
         } else {
             /** @var State $state */
             $state = $this->stateFactory->create();
             $state->loadByIndexer($indexerId);
             $state->setHashConfig($expectedHashConfig);
             $state->setStatus(StateInterface::STATUS_INVALID);
             $state->save();
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:30,代码来源:Recurring.php

示例6: _toHtml

 /**
  * Forms script response
  *
  * @return string
  */
 public function _toHtml()
 {
     $updateResult = $this->_coreRegistry->registry('composite_update_result');
     $resultJson = $this->_jsonEncoder->encode($updateResult);
     $jsVarname = $updateResult->getJsVarName();
     return $this->_jsHelper->getScript(sprintf('var %s = %s', $jsVarname, $resultJson));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Result.php

示例7: getProductsJson

 /**
  * @return string
  */
 public function getProductsJson()
 {
     $products = $this->getCategory()->getProductsPosition();
     if (!empty($products)) {
         return $this->jsonEncoder->encode($products);
     }
     return '{}';
 }
开发者ID:Zash22,项目名称:magento,代码行数:11,代码来源:AssignProducts.php

示例8: _toOptionHtml

 /**
  * Render single action as dropdown option html
  *
  * @param array $action
  * @param \Magento\Framework\DataObject $row
  * @return string
  */
 protected function _toOptionHtml($action, \Magento\Framework\DataObject $row)
 {
     $actionAttributes = new \Magento\Framework\DataObject();
     $actionCaption = '';
     $this->_transformActionData($action, $actionCaption, $row);
     $htmlAttibutes = ['value' => $this->escapeHtml($this->_jsonEncoder->encode($action))];
     $actionAttributes->setData($htmlAttibutes);
     return '<option ' . $actionAttributes->serialize() . '>' . $actionCaption . '</option>';
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Action.php

示例9: testAfterGetOptions

 public function testAfterGetOptions()
 {
     $resultJson = '[]';
     $this->jsonDecoder->expects($this->once())->method('decode')->with('[]')->willReturn([]);
     $expected = ['configurable_attribute_1' => [['mediaType' => 'type', 'videoUrl' => 'url', 'isBase' => true]]];
     $this->jsonEncoder->expects($this->any())->method('encode')->with($expected)->willReturn(json_encode($expected));
     $blockMock = $this->getMockBuilder('\\Magento\\ProductVideo\\Block\\Product\\View\\Gallery')->disableOriginalConstructor()->getMock();
     $result = $this->plugin->afterGetOptionsMediaGalleryDataJson($blockMock, $resultJson);
     $this->assertEquals(json_encode($expected), $result);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:10,代码来源:GalleryTest.php

示例10: execute

 /**
  * Reports a system cache flush to the database reporting_system_updates table
  *
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         $jsonData = ['status' => 'updated'];
         $modelData = ['type' => Config::FLUSH_CACHE, 'action' => $this->jsonEncoder->encode($jsonData)];
         /** @var \Magento\NewRelicReporting\Model\System $systemModel */
         $systemModel = $this->systemFactory->create();
         $systemModel->setData($modelData);
         $systemModel->save();
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:ReportSystemCacheFlush.php

示例11: testGetWidgetOptions

 public function testGetWidgetOptions()
 {
     $rand = rand();
     $this->mathRandom->expects($this->any())->method('getUniqueHash')->with('id_')->willReturn('id_' . $rand);
     $saveVideoUrl = 'http://host/index.php/admin/catalog/product_gallery/upload/key/';
     $saveRemoteVideoUrl = 'http://host/index.php/admin/product_video/product_gallery/retrieveImage/';
     $this->urlBuilder->expects($this->exactly(2))->method('getUrl')->willReturnOnConsecutiveCalls($saveVideoUrl, $saveRemoteVideoUrl);
     $value = ['saveVideoUrl' => $saveVideoUrl, 'saveRemoteVideoUrl' => $saveRemoteVideoUrl, 'htmlId' => 'id_' . $rand];
     $this->jsonEncoderMock->expects($this->once())->method('encode')->with($value)->willReturn(json_encode($value));
     $this->block->getWidgetOptions();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:11,代码来源:NewVideoTest.php

示例12: getDataAsJSON

 /**
  * Get object data as JSON
  *
  * @return string
  */
 public function getDataAsJSON()
 {
     $result = [];
     $inputNames = $this->getInputNames();
     if ($serializeData = $this->getSerializeData()) {
         $result = $serializeData;
     } elseif (!empty($inputNames)) {
         return '{}';
     }
     return $this->_jsonEncoder->encode($result);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Serializer.php

示例13: testReportSystemCacheFlush

 /**
  * Test case when module is enabled in config
  *
  * @return void
  */
 public function testReportSystemCacheFlush()
 {
     $testType = 'systemCacheFlush';
     $testAction = 'JSON string';
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $this->jsonEncoder->expects($this->once())->method('encode')->willReturn($testAction);
     $this->systemModel->expects($this->once())->method('setData')->with(['type' => $testType, 'action' => $testAction])->willReturnSelf();
     $this->systemModel->expects($this->once())->method('save');
     $this->model->execute($eventObserver);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:ReportSystemCacheFlushTest.php

示例14: execute

 /**
  * Reports any products deleted to the database reporting_system_updates table
  *
  * @param Observer $observer
  * @return void
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $observer->getEvent()->getProduct();
         $jsonData = ['id' => $product->getId(), 'status' => 'deleted'];
         $modelData = ['type' => Config::PRODUCT_CHANGE, 'action' => $this->jsonEncoder->encode($jsonData), 'updated_at' => $this->dateTime->formatDate(true)];
         /** @var \Magento\NewRelicReporting\Model\System $systemModel */
         $systemModel = $this->systemFactory->create();
         $systemModel->setData($modelData);
         $systemModel->save();
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:19,代码来源:ReportProductDeleted.php

示例15: execute

 /**
  * Reports concurrent admins to the database reporting_users table
  *
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         if ($this->backendAuthSession->isLoggedIn()) {
             $user = $this->backendAuthSession->getUser();
             $jsonData = ['id' => $user->getId(), 'username' => $user->getUsername(), 'name' => $user->getFirstname() . ' ' . $user->getLastname()];
             $modelData = ['type' => 'admin_activity', 'action' => $this->jsonEncoder->encode($jsonData)];
             /** @var \Magento\NewRelicReporting\Model\Users $usersModel */
             $usersModel = $this->usersFactory->create();
             $usersModel->setData($modelData);
             $usersModel->save();
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:ReportConcurrentAdmins.php


注:本文中的Magento\Framework\Json\EncoderInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。