-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimizations for Reader implementation
- Loading branch information
1 parent
ae5451e
commit 73c1e62
Showing
20 changed files
with
160 additions
and
300 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2017 Magenerds | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
|
@@ -12,10 +12,11 @@ | |
|
||
namespace Magenerds\Dashboard\Block\Adminhtml; | ||
|
||
use Exception; | ||
use Magento\Backend\Block\Template; | ||
|
||
/** | ||
* @copyright Copyright (c) 2017 Magenerds (http://www.magenerds.com) | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
|
@@ -41,26 +42,44 @@ class Dashboard extends Template | |
*/ | ||
const NUMBER_NEWS_FEEDS = 5; | ||
|
||
/** | ||
* @return object | ||
*/ | ||
protected function getReader() | ||
{ | ||
if (class_exists('\Zend_Feed_Reader')) { | ||
return new \Zend_Feed_Reader(); | ||
} | ||
/** @noinspection PhpFullyQualifiedNameUsageInspection PhpUndefinedNamespaceInspection */ | ||
return new \Zend\Feed\Reader\Reader(); | ||
} | ||
|
||
/** | ||
* Returns the blog feeds | ||
* | ||
* @return [] | ||
* @return array | ||
*/ | ||
public function getBlogFeeds() | ||
{ | ||
$feeds = []; | ||
$reader = new \Zend_Feed_Reader(); | ||
$reader = $this->getReader(); | ||
|
||
$ctr = 1; | ||
foreach ($reader->import(self::BLOG_FEED_URL) as $feed) { | ||
$feeds[] = [ | ||
'link' => $feed->getLink(), | ||
'title' => $feed->getTitle(), | ||
'date' => substr($feed->getDateCreated(), 0, 10), | ||
'description' => $feed->getDescription() | ||
]; | ||
if ($ctr == self::NUMBER_BLOG_FEEDS) break; | ||
$ctr++; | ||
try { | ||
foreach ($reader->import(self::BLOG_FEED_URL) as $feed) { | ||
$feeds[] = [ | ||
'link' => $feed->getLink(), | ||
'title' => $feed->getTitle(), | ||
'date' => substr($feed->getDateCreated(), 0, 10), | ||
'description' => $feed->getDescription() | ||
]; | ||
if ($ctr == self::NUMBER_BLOG_FEEDS) { | ||
break; | ||
} | ||
$ctr++; | ||
} | ||
} catch (Exception $e) { | ||
// do nothing | ||
} | ||
|
||
return $feeds; | ||
|
@@ -69,25 +88,31 @@ public function getBlogFeeds() | |
/** | ||
* Returns the news feeds | ||
* | ||
* @return [] | ||
* @return array | ||
*/ | ||
public function getNewsFeeds() | ||
{ | ||
$feeds = []; | ||
$reader = new \Zend_Feed_Reader(); | ||
$reader = $this->getReader(); | ||
|
||
$ctr = 1; | ||
foreach ($reader->import(self::NEWS_FEED_URL) as $feed) { | ||
$feeds[] = [ | ||
'link' => $feed->getLink(), | ||
'title' => $feed->getTitle(), | ||
'date' => substr($feed->getDateCreated(), 0, 10), | ||
'content' => $feed->getContent() | ||
]; | ||
if ($ctr == self::NUMBER_NEWS_FEEDS) break; | ||
$ctr++; | ||
try { | ||
foreach ($reader->import(self::NEWS_FEED_URL) as $feed) { | ||
$feeds[] = [ | ||
'link' => $feed->getLink(), | ||
'title' => $feed->getTitle(), | ||
'date' => substr($feed->getDateCreated(), 0, 10), | ||
'content' => $feed->getContent() | ||
]; | ||
if ($ctr == self::NUMBER_NEWS_FEEDS) { | ||
break; | ||
} | ||
$ctr++; | ||
} | ||
} catch (Exception $e) { | ||
// do nothing | ||
} | ||
|
||
return $feeds; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2017 Magenerds | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
|
@@ -13,18 +13,19 @@ | |
namespace Magenerds\Dashboard\Controller\Adminhtml\Dashboard; | ||
|
||
use Magento\Backend\App\Action\Context; | ||
use Magento\Backend\Model\View\Result\Page; | ||
use Magento\Framework\View\Result\PageFactory; | ||
use Magento\Backend\App\Action; | ||
|
||
/** | ||
* @copyright Copyright (c) 2017 Magenerds (http://www.magenerds.com) | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
class Index extends Action | ||
{ | ||
/** | ||
* @var \Magento\Framework\View\Result\PageFactory | ||
* @var PageFactory | ||
*/ | ||
protected $_resultPageFactory; | ||
|
||
|
@@ -35,19 +36,20 @@ class Index extends Action | |
public function __construct( | ||
Context $context, | ||
PageFactory $resultPageFactory | ||
) { | ||
) | ||
{ | ||
parent::__construct($context); | ||
$this->_resultPageFactory = $resultPageFactory; | ||
} | ||
|
||
/** | ||
* Index action | ||
* | ||
* @return \Magento\Backend\Model\View\Result\Page | ||
* @return Page | ||
*/ | ||
public function execute() | ||
{ | ||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */ | ||
/** @var Page $resultPage */ | ||
$resultPage = $this->_resultPageFactory->create(); | ||
$resultPage->setActiveMenu('Magenerds_Dashboard::dashboard'); | ||
$resultPage->addBreadcrumb(__('Magenerds'), __('Magenerds')); | ||
|
@@ -66,4 +68,4 @@ protected function _isAllowed() | |
{ | ||
return $this->_authorization->isAllowed('Magenerds_Dashboard::index'); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Magenerds_Dashboard | ||
# Magenerds Dashboard | ||
|
||
This module will serve information about Magenerds. |
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
{ | ||
"name": "magenerds/dashboard", | ||
"description": "The Magenerds dashboard provides useful information about Magenerds", | ||
"require": { | ||
"magento/framework": "^100.0.0|^101.0.0|^102.0.0" | ||
}, | ||
"type": "magento2-module", | ||
"license": [ | ||
"OSL-3.0" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
"name": "magenerds/dashboard", | ||
"description": "The Magenerds dashboard provides useful information about Magenerds", | ||
"require": { | ||
"magento/framework": "^100.0.0|^101.0.0|^102.0.0" | ||
}, | ||
"type": "magento2-module", | ||
"license": [ | ||
"OSL-3.0" | ||
], | ||
"psr-4": { | ||
"Magenerds\\Dashboard\\": "" | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Magenerds\\Dashboard\\": "" | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright (c) 2017 Magenerds | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
* For more information see http://www.mageneds.com/ | ||
* For more information see http://www.magenerds.com/ | ||
* | ||
* To obtain a valid license for using this software please contact us at | ||
* [email protected] | ||
*/ | ||
/** | ||
* @copyright Copyright (c) 2017 Magenerds (http://www.magenerds.com) | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
|
@@ -22,10 +22,10 @@ | |
<acl> | ||
<resources> | ||
<resource id="Magento_Backend::admin"> | ||
<resource id="Magenerds_Dashboard::dashboard" title="Magenerds" sortOrder="10" > | ||
<resource id="Magenerds_Dashboard::index" title="Magenerds" sortOrder="10" /> | ||
<resource id="Magenerds_Dashboard::dashboard" title="Magenerds" sortOrder="10"> | ||
<resource id="Magenerds_Dashboard::index" title="Magenerds" sortOrder="10"/> | ||
</resource> | ||
</resource> | ||
</resources> | ||
</acl> | ||
</config> | ||
</config> |
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright (c) 2017 Magenerds | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
* For more information see http://www.mageneds.com/ | ||
* For more information see http://www.magenerds.com/ | ||
* | ||
* To obtain a valid license for using this software please contact us at | ||
* [email protected] | ||
*/ | ||
/** | ||
* @copyright Copyright (c) 2017 Magenerds (http://www.magenerds.com) | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
|
@@ -27,4 +27,4 @@ | |
action="magenerds/dashboard" | ||
/> | ||
</menu> | ||
</config> | ||
</config> |
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright (c) 2017 Magenerds | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
* For more information see http://www.mageneds.com/ | ||
* For more information see http://www.magenerds.com/ | ||
* | ||
* To obtain a valid license for using this software please contact us at | ||
* [email protected] | ||
*/ | ||
/** | ||
* @copyright Copyright (c) 2017 Magenerds (http://www.magenerds.com) | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
|
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright (c) 2017 Magenerds | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
* For more information see http://www.mageneds.com/ | ||
* For more information see http://www.magenerds.com/ | ||
* | ||
* To obtain a valid license for using this software please contact us at | ||
* [email protected] | ||
*/ | ||
/** | ||
* @copyright Copyright (c) 2017 Magenerds (http://www.magenerds.com) | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Magenerds_Dashboard" setup_version="0.0.1" /> | ||
</config> | ||
<module name="Magenerds_Dashboard" setup_version="0.0.1"/> | ||
</config> |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2017 Magenerds | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
|
@@ -11,12 +11,12 @@ | |
*/ | ||
|
||
/** | ||
* @copyright Copyright (c) 2017 Magenerds (http://www.magenerds.com) | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
\Magento\Framework\Component\ComponentRegistrar::register( | ||
\Magento\Framework\Component\ComponentRegistrar::MODULE, | ||
'Magenerds_Dashboard', | ||
__DIR__ | ||
); | ||
); |
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 |
---|---|---|
@@ -1,4 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright (c) 2019 Magenerds | ||
* All rights reserved | ||
* | ||
* This product includes proprietary software developed at Magenerds, Germany | ||
* For more information see http://www.magenerds.com/ | ||
* | ||
* To obtain a valid license for using this software please contact us at | ||
* [email protected] | ||
*/ | ||
/** | ||
* @copyright Copyright (c) 2019 Magenerds (http://www.magenerds.com) | ||
* @link http://www.magenerds.com/ | ||
* @author Florian Sydekum <[email protected]> | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<head> | ||
<css src="Magenerds_Dashboard::css/menu.css"/> | ||
|
Oops, something went wrong.