[
  {
    "path": "Api/AuthorRepositoryInterface.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Api;\n\nuse Magento\\Framework\\Api\\SearchCriteriaInterface;\nuse Sample\\News\\Api\\Data\\AuthorInterface;\n\n/**\n * @api\n */\ninterface AuthorRepositoryInterface\n{\n    /**\n     * Save page.\n     *\n     * @param AuthorInterface $author\n     * @return AuthorInterface\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function save(AuthorInterface $author);\n\n    /**\n     * Retrieve Author.\n     *\n     * @param int $authorId\n     * @return AuthorInterface\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function getById($authorId);\n\n    /**\n     * Retrieve pages matching the specified criteria.\n     *\n     * @param SearchCriteriaInterface $searchCriteria\n     * @return \\Sample\\News\\Api\\Data\\AuthorSearchResultsInterface\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function getList(SearchCriteriaInterface $searchCriteria);\n\n    /**\n     * Delete author.\n     *\n     * @param AuthorInterface $author\n     * @return bool true on success\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function delete(AuthorInterface $author);\n\n    /**\n     * Delete author by ID.\n     *\n     * @param int $authorId\n     * @return bool true on success\n     * @throws \\Magento\\Framework\\Exception\\NoSuchEntityException\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function deleteById($authorId);\n}\n"
  },
  {
    "path": "Api/Data/AuthorInterface.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Api\\Data;\n\n/**\n * @api\n */\ninterface AuthorInterface\n{\n    /**\n     * Constants for keys of data array. Identical to the name of the getter in snake case\n     */\n    const AUTHOR_ID         = 'author_id';\n    const NAME              = 'name';\n    const URL_KEY           = 'url_key';\n    const IS_ACTIVE         = 'is_active';\n    const IN_RSS            = 'in_rss';\n    const BIOGRAPHY         = 'biography';\n    const DOB               = 'dob';\n    const TYPE              = 'type';\n    const AWARDS            = 'awards';\n    const AVATAR            = 'avatar';\n    const RESUME            = 'resume';\n    const COUNTRY           = 'country';\n    const CREATED_AT        = 'created_at';\n    const UPDATED_AT        = 'updated_at';\n    const META_TITLE        = 'meta_title';\n    const META_DESCRIPTION  = 'meta_description';\n    const META_KEYWORDS     = 'meta_keywords';\n    const STORE_ID          = 'store_id';\n\n\n    /**\n     * Get ID\n     *\n     * @return int|null\n     */\n    public function getId();\n\n    /**\n     * Get name\n     *\n     * @return string\n     */\n    public function getName();\n\n    /**\n     * Get url key\n     *\n     * @return string\n     */\n    public function getUrlKey();\n\n    /**\n     * Get is active\n     *\n     * @return bool|int\n     */\n    public function getIsActive();\n\n    /**\n     * Get in rss\n     *\n     * @return bool|int\n     */\n    public function getInRss();\n\n    /**\n     * Get biography\n     *\n     * @return string\n     */\n    public function getBiography();\n\n    /**\n     * @return string\n     */\n    public function getProcessedBiography();\n\n    /**\n     * Get DOB\n     *\n     * @return string\n     */\n    public function getDob();\n\n    /**\n     * Get type\n     *\n     * @return int\n     */\n    public function getType();\n\n    /**\n     * Get awards\n     *\n     * @return string\n     */\n    public function getAwards();\n\n    /**\n     * Get avatar\n     *\n     * @return string\n     */\n    public function getAvatar();\n\n    /**\n     * Get resume\n     *\n     * @return string\n     */\n    public function getResume();\n\n    /**\n     * Get country\n     *\n     * @return string\n     */\n    public function getCountry();\n\n    /**\n     * set id\n     *\n     * @param $id\n     * @return AuthorInterface\n     */\n    public function setId($id);\n\n    /**\n     * set name\n     *\n     * @param $name\n     * @return AuthorInterface\n     */\n    public function setName($name);\n\n    /**\n     * set url key\n     *\n     * @param $urlKey\n     * @return AuthorInterface\n     */\n    public function setUrlKey($urlKey);\n\n    /**\n     * Set is active\n     *\n     * @param $isActive\n     * @return AuthorInterface\n     */\n    public function setIsActive($isActive);\n\n    /**\n     * Set in rss\n     *\n     * @param $inRss\n     * @return AuthorInterface\n     */\n    public function setInRss($inRss);\n\n    /**\n     * Set biography\n     *\n     * @param $biography\n     * @return AuthorInterface\n     */\n    public function setBiography($biography);\n\n    /**\n     * Set DOB\n     *\n     * @param $dob\n     * @return AuthorInterface\n     */\n    public function setDob($dob);\n\n    /**\n     * set type\n     *\n     * @param $type\n     * @return AuthorInterface\n     */\n    public function setType($type);\n\n    /**\n     * set awards\n     *\n     * @param $awards\n     * @return AuthorInterface\n     */\n    public function setAwards($awards);\n\n    /**\n     * set avatar\n     *\n     * @param $avatar\n     * @return AuthorInterface\n     */\n    public function setAvatar($avatar);\n\n    /**\n     * set resume\n     *\n     * @param $resume\n     * @return AuthorInterface\n     */\n    public function setResume($resume);\n\n    /**\n     * Set country\n     *\n     * @param $country\n     * @return AuthorInterface\n     */\n    public function setCountry($country);\n\n    /**\n     * Get created at\n     *\n     * @return string\n     */\n    public function getCreatedAt();\n\n    /**\n     * set created at\n     *\n     * @param $createdAt\n     * @return AuthorInterface\n     */\n    public function setCreatedAt($createdAt);\n\n    /**\n     * Get updated at\n     *\n     * @return string\n     */\n    public function getUpdatedAt();\n\n    /**\n     * set updated at\n     *\n     * @param $updatedAt\n     * @return AuthorInterface\n     */\n    public function setUpdatedAt($updatedAt);\n\n    /**\n     * @param $storeId\n     * @return AuthorInterface\n     */\n    public function setStoreId($storeId);\n\n    /**\n     * @return int[]\n     */\n    public function getStoreId();\n\n    /**\n     * @return string\n     */\n    public function getMetaTitle();\n\n    /**\n     * @param $metaTitle\n     * @return AuthorInterface\n     */\n    public function setMetaTitle($metaTitle);\n\n    /**\n     * @return string\n     */\n    public function getMetaDescription();\n\n    /**\n     * @param $metaDescription\n     * @return AuthorInterface\n     */\n    public function setMetaDescription($metaDescription);\n\n    /**\n     * @return string\n     */\n    public function getMetaKeywords();\n\n    /**\n     * @param $metaKeywords\n     * @return AuthorInterface\n     */\n    public function setMetaKeywords($metaKeywords);\n}\n"
  },
  {
    "path": "Api/Data/AuthorSearchResultsInterface.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Api\\Data;\n\nuse Magento\\Framework\\Api\\SearchResultsInterface;\n\n/**\n * @api\n */\ninterface AuthorSearchResultsInterface extends SearchResultsInterface\n{\n    /**\n     * Get author list.\n     *\n     * @return \\Sample\\News\\Api\\Data\\AuthorInterface[]\n     */\n    public function getItems();\n\n    /**\n     * Set authors list.\n     *\n     * @param \\Sample\\News\\Api\\Data\\AuthorInterface[] $items\n     * @return $this\n     */\n    public function setItems(array $items);\n}\n"
  },
  {
    "path": "Block/Adminhtml/Author/Edit/Buttons/Back.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons;\n\nuse Magento\\Framework\\View\\Element\\UiComponent\\Control\\ButtonProviderInterface;\n\nclass Back extends Generic implements ButtonProviderInterface\n{\n    /**\n     * get button data\n     *\n     * @return array\n     */\n    public function getButtonData()\n    {\n        return [\n            'label' => __('Back'),\n            'on_click' => sprintf(\"location.href = '%s';\", $this->getBackUrl()),\n            'class' => 'back',\n            'sort_order' => 10\n        ];\n    }\n\n    /**\n     * Get URL for back (reset) button\n     *\n     * @return string\n     */\n    public function getBackUrl()\n    {\n        return $this->getUrl('*/*/');\n    }\n}\n"
  },
  {
    "path": "Block/Adminhtml/Author/Edit/Buttons/Delete.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons;\n\nuse Magento\\Framework\\View\\Element\\UiComponent\\Control\\ButtonProviderInterface;\n\nclass Delete extends Generic implements ButtonProviderInterface\n{\n    /**\n     * get button data\n     *\n     * @return array\n     */\n    public function getButtonData()\n    {\n        $data = [];\n        if ($this->getAuthorId()) {\n            $data = [\n                'label' => __('Delete Author'),\n                'class' => 'delete',\n                'on_click' => 'deleteConfirm(\\'' . __(\n                    'Are you sure you want to do this?'\n                ) . '\\', \\'' . $this->getDeleteUrl() . '\\')',\n                'sort_order' => 20,\n            ];\n        }\n        return $data;\n    }\n\n    /**\n     * @return string\n     */\n    public function getDeleteUrl()\n    {\n        return $this->getUrl('*/*/delete', ['author_id' => $this->getAuthorId()]);\n    }\n}\n"
  },
  {
    "path": "Block/Adminhtml/Author/Edit/Buttons/Generic.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons;\n\nuse Magento\\Backend\\Block\\Widget\\Context;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\nuse Magento\\Framework\\Exception\\NoSuchEntityException;\n\nclass Generic\n{\n    /**\n     * @var Context\n     */\n    protected $context;\n\n    /**\n     * @var AuthorRepositoryInterface\n     */\n    protected $authorRepository;\n\n    /**\n     * @param Context $context\n     * @param AuthorRepositoryInterface $authorRepository\n     */\n    public function __construct(\n        Context $context,\n        AuthorRepositoryInterface $authorRepository\n    ) {\n        $this->context = $context;\n        $this->authorRepository = $authorRepository;\n    }\n\n    /**\n     * Return Author page ID\n     *\n     * @return int|null\n     */\n    public function getAuthorId()\n    {\n        try {\n            return $this->authorRepository->getById(\n                $this->context->getRequest()->getParam('author_id')\n            )->getId();\n        } catch (NoSuchEntityException $e) {\n            return null;\n        }\n    }\n\n    /**\n     * Generate url by route and parameters\n     *\n     * @param   string $route\n     * @param   array $params\n     * @return  string\n     */\n    public function getUrl($route = '', $params = [])\n    {\n        return $this->context->getUrlBuilder()->getUrl($route, $params);\n    }\n}\n"
  },
  {
    "path": "Block/Adminhtml/Author/Edit/Buttons/Reset.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons;\n\nuse Magento\\Framework\\View\\Element\\UiComponent\\Control\\ButtonProviderInterface;\n\nclass Reset implements ButtonProviderInterface\n{\n    /**\n     * get button data\n     *\n     * @return array\n     */\n    public function getButtonData()\n    {\n        return [\n            'label' => __('Reset'),\n            'class' => 'reset',\n            'on_click' => 'location.reload();',\n            'sort_order' => 30\n        ];\n    }\n}\n"
  },
  {
    "path": "Block/Adminhtml/Author/Edit/Buttons/Save.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons;\n\nuse Magento\\Framework\\View\\Element\\UiComponent\\Control\\ButtonProviderInterface;\n\nclass Save extends Generic implements ButtonProviderInterface\n{\n    /**\n     * get button data\n     *\n     * @return array\n     */\n    public function getButtonData()\n    {\n        return [\n            'label' => __('Save Author'),\n            'class' => 'save primary',\n            'data_attribute' => [\n                'mage-init' => ['button' => ['event' => 'save']],\n                'form-role' => 'save',\n            ],\n            'sort_order' => 90,\n        ];\n    }\n}\n"
  },
  {
    "path": "Block/Adminhtml/Author/Edit/Buttons/SaveAndContinue.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons;\n\nuse Magento\\Framework\\View\\Element\\UiComponent\\Control\\ButtonProviderInterface;\n\nclass SaveAndContinue extends Generic implements ButtonProviderInterface\n{\n\n    /**\n     * get button data\n     *\n     * @return array\n     */\n    public function getButtonData()\n    {\n        return [\n            'label' => __('Save and Continue Edit'),\n            'class' => 'save',\n            'data_attribute' => [\n                'mage-init' => [\n                    'button' => ['event' => 'saveAndContinueEdit'],\n                ],\n            ],\n            'sort_order' => 80,\n        ];\n    }\n}\n"
  },
  {
    "path": "Block/Author/ListAuthor/Rss/Link.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Author\\ListAuthor\\Rss;\n\nuse Magento\\Framework\\View\\Element\\Template;\nuse Magento\\Framework\\View\\Element\\Template\\Context;\nuse Sample\\News\\Model\\Author\\Rss as RssModel;\n\nclass Link extends Template\n{\n    /**\n     * @var RssModel\n     */\n    protected $rssModel;\n\n    /**\n     * @param RssModel $rssModel\n     * @param Context $context\n     * @param array $data\n     */\n    public function __construct(\n        Context $context,\n        RssModel $rssModel,\n        array $data = []\n    ) {\n        $this->rssModel = $rssModel;\n        parent::__construct($context, $data);\n    }\n\n    /**\n     * @return string\n     */\n    public function isRssEnabled()\n    {\n        return $this->rssModel->isRssEnabled();\n    }\n\n    /**\n     * @return string\n     */\n    public function getLabel()\n    {\n        return __('Subscribe to RSS Feed');\n    }\n    /**\n     * @return string\n     */\n    public function getLink()\n    {\n        return $this->rssModel->getRssLink();\n    }\n}\n"
  },
  {
    "path": "Block/Author/ListAuthor/Rss.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Author\\ListAuthor;\n\nuse Magento\\Framework\\App\\Rss\\DataProviderInterface;\nuse Magento\\Framework\\View\\Element\\AbstractBlock;\nuse Magento\\Framework\\View\\Element\\Context;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Sample\\News\\Model\\Author;\nuse Sample\\News\\Model\\Author\\Rss as RssModel;\nuse Sample\\News\\Model\\Author\\Url;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory;\n\nclass Rss extends AbstractBlock implements DataProviderInterface\n{\n    /**\n     * @var string\n     */\n    const CACHE_LIFETIME_CONFIG_PATH = 'sample_news/author/rss_cache';\n\n    /**\n     * @var \\Sample\\News\\Model\\Author\\Rss\n     */\n    protected $rssModel;\n\n    /**\n     * @var \\Sample\\News\\Model\\Author\\Url\n     */\n    protected $urlModel;\n\n    /**\n     * @var \\Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory\n     */\n    protected $authorCollectionFactory;\n\n    /**\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * @param Context $context\n     * @param RssModel $rssModel\n     * @param Url $urlModel\n     * @param CollectionFactory $authorCollectionFactory\n     * @param StoreManagerInterface $storeManager\n     * @param array $data\n     */\n    public function __construct(\n        Context $context,\n        RssModel $rssModel,\n        Url $urlModel,\n        CollectionFactory $authorCollectionFactory,\n        StoreManagerInterface $storeManager,\n        array $data = []\n    ) {\n        $this->rssModel = $rssModel;\n        $this->urlModel = $urlModel;\n        $this->authorCollectionFactory = $authorCollectionFactory;\n        $this->storeManager = $storeManager;\n        parent::__construct($context, $data);\n    }\n\n    /**\n     * @return int\n     */\n    protected function getStoreId()\n    {\n        $storeId = (int)$this->getRequest()->getParam('store_id');\n        if ($storeId == null) {\n            $storeId = $this->storeManager->getStore()->getId();\n        }\n        return $storeId;\n    }\n\n    /**\n     * @return array\n     */\n    public function getRssData()\n    {\n        $url = $this->urlModel->getListUrl();\n        $data = [\n            'title' => __('Authors'),\n            'description' => __('Authors'),\n            'link' => $url,\n            'charset' => 'UTF-8'\n        ];\n        $collection = $this->authorCollectionFactory->create();\n        $collection->addStoreFilter($this->getStoreId());\n        $collection->addFieldToFilter('is_active', Author::STATUS_ENABLED);\n        $collection->addFieldToFilter('in_rss', 1);\n        foreach ($collection as $item) {\n            /** @var \\Sample\\News\\Model\\Author $item */\n            $description = '<table><tr><td><a href=\"%s\">%s</a></td></tr></table>';\n            $description = sprintf($description, $item->getAuthorUrl(), $item->getName());\n            $data['entries'][] = [\n                'title' => $item->getName(),\n                'link' => $item->getAuthorUrl(),\n                'description' => $description,\n            ];\n        }\n        return $data;\n    }\n\n    /**\n     * Check if RSS feed allowed\n     *\n     * @return mixed\n     */\n    public function isAllowed()\n    {\n        return $this->rssModel->isRssEnabled();\n    }\n\n    /**\n     * Get information about all feeds this Data Provider is responsible for\n     *\n     * @return array\n     */\n    public function getFeeds()\n    {\n        $feeds = [];\n        $feeds[] = [\n            'label' => __('Authors'),\n            'link' => $this->rssModel->getRssLink(),\n        ];\n        $result = ['group' => __('News'), 'feeds' => $feeds];\n        return $result;\n    }\n\n    /**\n     * @return bool\n     */\n    public function isAuthRequired()\n    {\n        return false;\n    }\n\n    /**\n     * @return int\n     */\n    public function getCacheLifetime()\n    {\n        $lifetime = $this->_scopeConfig->getValue(\n            self::CACHE_LIFETIME_CONFIG_PATH,\n            ScopeInterface::SCOPE_STORE\n        );\n        return $lifetime ?: null;\n    }\n}\n"
  },
  {
    "path": "Block/Author/ListAuthor.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Author;\n\nuse Magento\\Framework\\UrlFactory;\nuse Magento\\Framework\\View\\Element\\Template;\nuse Magento\\Framework\\View\\Element\\Template\\Context;\nuse Magento\\Theme\\Block\\Html\\Pager;\nuse Sample\\News\\Model\\Author;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory as AuthorCollectionFactory;\n\nclass ListAuthor extends Template\n{\n    /**\n     * @var AuthorCollectionFactory\n     */\n    protected $authorCollectionFactory;\n    /**\n     * @var UrlFactory\n     */\n    protected $urlFactory;\n\n    /**\n     * @var \\Sample\\News\\Model\\ResourceModel\\Author\\Collection\n     */\n    protected $authors;\n\n    /**\n     * @param Context $context\n     * @param AuthorCollectionFactory $authorCollectionFactory\n     * @param UrlFactory $urlFactory\n     * @param array $data\n     */\n    public function __construct(\n        Context $context,\n        AuthorCollectionFactory $authorCollectionFactory,\n        UrlFactory $urlFactory,\n        array $data = []\n    ) {\n        $this->authorCollectionFactory = $authorCollectionFactory;\n        $this->urlFactory = $urlFactory;\n        parent::__construct($context, $data);\n    }\n\n    /**\n     * @return \\Sample\\News\\Model\\ResourceModel\\Author\\Collection\n     */\n    public function getAuthors()\n    {\n        if (is_null($this->authors)) {\n            $this->authors = $this->authorCollectionFactory->create()\n                ->addFieldToSelect('*')\n                ->addFieldToFilter('is_active', Author::STATUS_ENABLED)\n                ->addStoreFilter($this->_storeManager->getStore()->getId())\n                ->setOrder('name', 'ASC');\n        }\n        return $this->authors;\n    }\n\n    /**\n     * @return $this\n     */\n    protected function _prepareLayout()\n    {\n        parent::_prepareLayout();\n        /** @var \\Magento\\Theme\\Block\\Html\\Pager $pager */\n        $pager = $this->getLayout()->createBlock(Pager::class, 'sample_news.author.list.pager');\n        $pager->setCollection($this->getAuthors());\n        $this->setChild('pager', $pager);\n        $this->getAuthors()->load();\n        return $this;\n    }\n\n    /**\n     * @return string\n     */\n    public function getPagerHtml()\n    {\n        return $this->getChildHtml('pager');\n    }\n}\n"
  },
  {
    "path": "Block/Author/ViewAuthor.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block\\Author;\n\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\View\\Element\\Template;\nuse Magento\\Framework\\View\\Element\\Template\\Context;\nuse Sample\\News\\Block\\ImageBuilder;\n\nclass ViewAuthor extends Template\n{\n    /**\n     * @var Registry\n     */\n    protected $coreRegistry;\n\n    /**\n     * @var ImageBuilder\n     */\n    protected $imageBuilder;\n\n    /**\n     * @param Context $context\n     * @param Registry $registry\n     * @param $imageBuilder\n     * @param array $data\n     */\n    public function __construct(\n        Context $context,\n        Registry $registry,\n        ImageBuilder $imageBuilder,\n        array $data = []\n    ) {\n        $this->coreRegistry = $registry;\n        $this->imageBuilder = $imageBuilder;\n        parent::__construct($context, $data);\n    }\n\n    /**\n     * get current author\n     *\n     * @return \\Sample\\News\\Model\\Author\n     */\n    public function getCurrentAuthor()\n    {\n        return $this->coreRegistry->registry('current_author');\n    }\n\n    /**\n     * @param $entity\n     * @param $imageId\n     * @param array $attributes\n     * @return \\Sample\\News\\Block\\Image\n     */\n    public function getImage($entity, $imageId, $attributes = [])\n    {\n        return $this->imageBuilder->setEntity($entity)\n            ->setImageId($imageId)\n            ->setAttributes($attributes)\n            ->create();\n    }\n}\n"
  },
  {
    "path": "Block/Image.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block;\n\nuse Magento\\Framework\\View\\Element\\Template\\Context;\nuse Magento\\Framework\\View\\Element\\Template;\n/**\n * @method string getImageUrl()\n * @method string getWidth()\n * @method string getHeight()\n * @method string getLabel()\n * @method mixed getResizedImageWidth()\n * @method mixed getResizedImageHeight()\n * @method float getRatio()\n * @method string getCustomAttributes()\n */\nclass Image extends Template\n{\n    /**\n     * @var \\Magento\\Framework\\Model\\AbstractModel\n     */\n    protected $entity;\n\n    /**\n     * @var array\n     */\n    protected $attributes = [];\n\n    /**\n     * @param Context $context\n     * @param array $data\n     */\n    public function __construct(\n        Context $context,\n        array $data = []\n    ) {\n        if (isset($data['template'])) {\n            $this->setTemplate($data['template']);\n            unset($data['template']);\n        }\n        parent::__construct($context, $data);\n    }\n}\n"
  },
  {
    "path": "Block/ImageBuilder.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Block;\n\nuse Magento\\Framework\\Model\\AbstractModel;\nuse Sample\\News\\Helper\\Image as ImageHelper;\nuse Sample\\News\\Helper\\ImageFactory as HelperFactory;\n\nclass ImageBuilder\n{\n    /**\n     * @var ImageFactory\n     */\n    protected $imageFactory;\n\n    /**\n     * @var HelperFactory\n     */\n    protected $helperFactory;\n\n    /**\n     * @var \\Magento\\Framework\\Model\\AbstractModel\n     */\n    protected $entity;\n\n    /**\n     * @var string\n     */\n    protected $imageId;\n\n    /**\n     * @var array\n     */\n    protected $attributes = [];\n\n    /**\n     * @var string\n     */\n    protected $entityCode;\n\n    /**\n     * @param HelperFactory $helperFactory\n     * @param ImageFactory $imageFactory\n     * @param $entityCode\n     */\n    public function __construct(\n        HelperFactory $helperFactory,\n        ImageFactory $imageFactory,\n        $entityCode\n    ) {\n        $this->helperFactory = $helperFactory;\n        $this->imageFactory  = $imageFactory;\n        $this->entityCode    = $entityCode;\n    }\n\n    /**\n     * @param \\Magento\\Framework\\Model\\AbstractModel $entity\n     * @return $this\n     */\n    public function setEntity(AbstractModel $entity)\n    {\n        $this->entity = $entity;\n        return $this;\n    }\n\n    /**\n     * Set image ID\n     *\n     * @param string $imageId\n     * @return $this\n     */\n    public function setImageId($imageId)\n    {\n        $this->imageId = $imageId;\n        return $this;\n    }\n\n    /**\n     * Set custom attributes\n     *\n     * @param array $attributes\n     * @return $this\n     */\n    public function setAttributes(array $attributes)\n    {\n        if ($attributes) {\n            $this->attributes = $attributes;\n        }\n        return $this;\n    }\n\n    /**\n     * Retrieve image custom attributes for HTML element\n     *\n     * @return string\n     */\n    protected function getCustomAttributes()\n    {\n        $result = [];\n        foreach ($this->attributes as $name => $value) {\n            $result[] = $name . '=\"' . $value . '\"';\n        }\n        return !empty($result) ? implode(' ', $result) : '';\n    }\n\n    /**\n     * Calculate image ratio\n     *\n     * @param ImageHelper $helper\n     * @return float|int\n     */\n    protected function getRatio(ImageHelper $helper)\n    {\n        $width = $helper->getWidth();\n        $height = $helper->getHeight();\n        if ($width && $height) {\n            return $height / $width;\n        }\n        return 1;\n    }\n\n    /**\n     * Create image block\n     *\n     * @return \\Sample\\News\\Block\\Image\n     */\n    public function create()\n    {\n        /** @var ImageHelper $helper */\n        $helper = $this->helperFactory\n            ->create([\n                'entityCode' => $this->entityCode\n            ])\n            ->init(\n                $this->entity,\n                $this->imageId,\n                $this->attributes\n            );\n\n        $template = $helper->getFrame()\n            ? 'Sample_News::image.phtml'\n            : 'Sample_News::image_with_borders.phtml';\n\n        $imagesize = $helper->getResizedImageInfo();\n\n        $data = [\n            'data' => [\n                'template'              => $template,\n                'image_url'             => $helper->getUrl(),\n                'width'                 => $helper->getWidth(),\n                'height'                => $helper->getHeight(),\n                'label'                 => $helper->getLabel(),\n                'ratio'                 => $this->getRatio($helper),\n                'custom_attributes'     => $this->getCustomAttributes(),\n                'resized_image_width'   => !empty($imagesize[0]) ? $imagesize[0] : $helper->getWidth(),\n                'resized_image_height'  => !empty($imagesize[1]) ? $imagesize[1] : $helper->getHeight(),\n            ],\n        ];\n\n        return $this->imageFactory->create($data);\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/Delete.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Magento\\Framework\\Exception\\LocalizedException;\nuse Magento\\Framework\\Exception\\NoSuchEntityException;\nuse Sample\\News\\Controller\\Adminhtml\\Author;\n\nclass Delete extends Author\n{\n    /**\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Redirect\n     */\n    public function execute()\n    {\n        $resultRedirect = $this->resultRedirectFactory->create();\n        $id = $this->getRequest()->getParam('author_id');\n        if ($id) {\n            try {\n                $this->authorRepository->deleteById($id);\n                $this->messageManager->addSuccessMessage(__('The author has been deleted.'));\n                $resultRedirect->setPath('sample_news/*/');\n                return $resultRedirect;\n            } catch (NoSuchEntityException $e) {\n                $this->messageManager->addErrorMessage(__('The author no longer exists.'));\n                return $resultRedirect->setPath('sample_news/*/');\n            } catch (LocalizedException $e) {\n                $this->messageManager->addErrorMessage($e->getMessage());\n                return $resultRedirect->setPath('sample_news/author/edit', ['author_id' => $id]);\n            } catch (\\Exception $e) {\n                $this->messageManager->addErrorMessage(__('There was a problem deleting the author'));\n                return $resultRedirect->setPath('sample_news/author/edit', ['author_id' => $id]);\n            }\n        }\n        $this->messageManager->addErrorMessage(__('We can\\'t find a author to delete.'));\n        $resultRedirect->setPath('sample_news/*/');\n        return $resultRedirect;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/Edit.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Sample\\News\\Controller\\Adminhtml\\Author;\nuse Sample\\News\\Controller\\RegistryConstants;\n\nclass Edit extends Author\n{\n    /**\n     * Initialize current author and set it in the registry.\n     *\n     * @return int\n     */\n    protected function _initAuthor()\n    {\n        $authorId = $this->getRequest()->getParam('author_id');\n        $this->coreRegistry->register(RegistryConstants::CURRENT_AUTHOR_ID, $authorId);\n\n        return $authorId;\n    }\n\n    /**\n     * Edit or create author\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Page\n     */\n    public function execute()\n    {\n        $authorId = $this->_initAuthor();\n\n        /** @var \\Magento\\Backend\\Model\\View\\Result\\Page $resultPage */\n        $resultPage = $this->resultPageFactory->create();\n        $resultPage->setActiveMenu('Sample_News::author');\n        $resultPage->getConfig()->getTitle()->prepend(__('Authors'));\n        $resultPage->addBreadcrumb(__('News'), __('News'));\n        $resultPage->addBreadcrumb(__('Authors'), __('Authors'), $this->getUrl('sample_news/author'));\n\n        if ($authorId === null) {\n            $resultPage->addBreadcrumb(__('New Author'), __('New Author'));\n            $resultPage->getConfig()->getTitle()->prepend(__('New Author'));\n        } else {\n            $resultPage->addBreadcrumb(__('Edit Author'), __('Edit Author'));\n            $resultPage->getConfig()->getTitle()->prepend(\n                $this->authorRepository->getById($authorId)->getName()\n            );\n        }\n        return $resultPage;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/File/Upload.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author\\File;\n\nuse Sample\\News\\Controller\\Adminhtml\\Author\\Upload as GenericUpload;\n\nclass Upload extends GenericUpload\n{\n\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/Image/Upload.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author\\Image;\n\nuse Sample\\News\\Controller\\Adminhtml\\Author\\Upload as GenericUpload;\n\nclass Upload extends GenericUpload\n{\n\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/Index.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse \\Sample\\News\\Controller\\Adminhtml\\Author as AuthorController;\n\nclass Index extends AuthorController\n{\n    /**\n     * Authors list.\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Page\n     */\n    public function execute()\n    {\n        /** @var \\Magento\\Backend\\Model\\View\\Result\\Page $resultPage */\n        $resultPage = $this->resultPageFactory->create();\n        $resultPage->setActiveMenu('Sample_News::author');\n        $resultPage->getConfig()->getTitle()->prepend(__('Authors'));\n        $resultPage->addBreadcrumb(__('News'), __('News'));\n        $resultPage->addBreadcrumb(__('Authors'), __('Authors'));\n        return $resultPage;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/InlineEdit.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Backend\\Model\\Session;\nuse Magento\\Framework\\Api\\DataObjectHelper;\nuse Magento\\Framework\\Controller\\Result\\JsonFactory;\nuse Magento\\Framework\\Exception\\LocalizedException;\nuse Magento\\Framework\\Reflection\\DataObjectProcessor;\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\Stdlib\\DateTime\\Filter\\Date;\nuse Magento\\Framework\\View\\Result\\PageFactory;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\nuse Sample\\News\\Api\\Data\\AuthorInterface;\nuse Sample\\News\\Api\\Data\\AuthorInterfaceFactory;\nuse Sample\\News\\Controller\\Adminhtml\\Author as AuthorController;\nuse Sample\\News\\Model\\Author;\nuse Sample\\News\\Model\\ResourceModel\\Author as AuthorResourceModel;\n\nclass InlineEdit extends AuthorController\n{\n    /**\n     * @var DataObjectHelper\n     */\n    protected $dataObjectHelper;\n    /**\n     * @var DataObjectProcessor\n     */\n    protected $dataObjectProcessor;\n    /**\n     * @var JsonFactory\n     */\n    protected $jsonFactory;\n    /**\n     * @var AuthorResourceModel\n     */\n    protected $authorResourceModel;\n\n    /**\n     * @param Registry $registry\n     * @param AuthorRepositoryInterface $authorRepository\n     * @param PageFactory $resultPageFactory\n     * @param Date $dateFilter\n     * @param Context $context\n     * @param DataObjectProcessor $dataObjectProcessor\n     * @param DataObjectHelper $dataObjectHelper\n     * @param JsonFactory $jsonFactory\n     * @param AuthorResourceModel $authorResourceModel\n     */\n    public function __construct(\n        Registry $registry,\n        AuthorRepositoryInterface $authorRepository,\n        PageFactory $resultPageFactory,\n        Date $dateFilter,\n        Context $context,\n        DataObjectProcessor $dataObjectProcessor,\n        DataObjectHelper $dataObjectHelper,\n        JsonFactory $jsonFactory,\n        AuthorResourceModel $authorResourceModel\n    )\n    {\n        $this->dataObjectProcessor = $dataObjectProcessor;\n        $this->dataObjectHelper    = $dataObjectHelper;\n        $this->jsonFactory         = $jsonFactory;\n        $this->authorResourceModel = $authorResourceModel;\n        parent::__construct($registry, $authorRepository, $resultPageFactory, $dateFilter, $context);\n    }\n\n    /**\n     * @return \\Magento\\Framework\\Controller\\ResultInterface\n     */\n    public function execute()\n    {\n        /** @var \\Magento\\Framework\\Controller\\Result\\Json $resultJson */\n        $resultJson = $this->jsonFactory->create();\n        $error = false;\n        $messages = [];\n\n        $postItems = $this->getRequest()->getParam('items', []);\n        if (!($this->getRequest()->getParam('isAjax') && count($postItems))) {\n            return $resultJson->setData([\n                'messages' => [__('Please correct the data sent.')],\n                'error' => true,\n            ]);\n        }\n\n        foreach (array_keys($postItems) as $authorId) {\n            /** @var \\Sample\\News\\Model\\Author|AuthorInterface $author */\n            $author = $this->authorRepository->getById((int)$authorId);\n            try {\n                $authorData = $this->filterData($postItems[$authorId]);\n                $this->dataObjectHelper->populateWithArray($author, $authorData , AuthorInterface::class);\n                $this->authorResourceModel->saveAttribute($author, array_keys($authorData));\n            } catch (LocalizedException $e) {\n                $messages[] = $this->getErrorWithAuthorId($author, $e->getMessage());\n                $error = true;\n            } catch (\\RuntimeException $e) {\n                $messages[] = $this->getErrorWithAuthorId($author, $e->getMessage());\n                $error = true;\n            } catch (\\Exception $e) {\n                $messages[] = $this->getErrorWithAuthorId(\n                    $author,\n                    __('Something went wrong while saving the author.')\n                );\n                $error = true;\n            }\n        }\n\n        return $resultJson->setData([\n            'messages' => $messages,\n            'error' => $error\n        ]);\n    }\n\n    /**\n     * Add author id to error message\n     *\n     * @param Author $author\n     * @param string $errorText\n     * @return string\n     */\n    protected function getErrorWithAuthorId(Author $author, $errorText)\n    {\n        return '[Author ID: ' . $author->getId() . '] ' . $errorText;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/MassAction.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Magento\\Backend\\App\\Action;\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Framework\\Exception\\LocalizedException;\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\Stdlib\\DateTime\\Filter\\Date;\nuse Magento\\Framework\\View\\Result\\PageFactory;\nuse Magento\\Ui\\Component\\MassAction\\Filter;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\nuse Sample\\News\\Controller\\Adminhtml\\Author;\nuse Sample\\News\\Model\\Author as AuthorModel;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory;\n\nabstract class MassAction extends Author\n{\n    /**\n     * @var Filter\n     */\n    protected $filter;\n    /**\n     * @var CollectionFactory\n     */\n    protected $collectionFactory;\n    /**\n     * @var string\n     */\n    protected $successMessage;\n    /**\n     * @var string\n     */\n    protected $errorMessage;\n\n    /**\n     * @param Registry $registry\n     * @param AuthorRepositoryInterface $authorRepository\n     * @param PageFactory $resultPageFactory\n     * @param Date $dateFilter\n     * @param Context $context\n     * @param Filter $filter\n     * @param CollectionFactory $collectionFactory\n     * @param $successMessage\n     * @param $errorMessage\n     */\n    public function __construct(\n        Registry $registry,\n        AuthorRepositoryInterface $authorRepository,\n        PageFactory $resultPageFactory,\n        Date $dateFilter,\n        Context $context,\n        Filter $filter,\n        CollectionFactory $collectionFactory,\n        $successMessage,\n        $errorMessage\n    ) {\n        $this->filter            = $filter;\n        $this->collectionFactory = $collectionFactory;\n        $this->successMessage    = $successMessage;\n        $this->errorMessage      = $errorMessage;\n        parent::__construct($registry, $authorRepository, $resultPageFactory, $dateFilter, $context);\n    }\n\n    /**\n     * @param AuthorModel $author\n     * @return mixed\n     */\n    protected abstract function massAction(AuthorModel $author);\n\n    /**\n     * execute action\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Redirect\n     */\n    public function execute()\n    {\n        try {\n            $collection = $this->filter->getCollection($this->collectionFactory->create());\n            $collectionSize = $collection->getSize();\n            foreach ($collection as $author) {\n                $this->massAction($author);\n            }\n            $this->messageManager->addSuccessMessage(__($this->successMessage, $collectionSize));\n        } catch (LocalizedException $e) {\n            $this->messageManager->addErrorMessage($e->getMessage());\n        } catch (\\Exception $e) {\n            $this->messageManager->addExceptionMessage($e, __($this->errorMessage));\n        }\n        $redirectResult = $this->resultRedirectFactory->create();\n        $redirectResult->setPath('sample_news/*/index');\n        return $redirectResult;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/MassDelete.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Sample\\News\\Model\\Author;\n\nclass MassDelete extends MassAction\n{\n    /**\n     * @param Author $author\n     * @return $this\n     */\n    protected function massAction(Author $author)\n    {\n        $this->authorRepository->delete($author);\n        return $this;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/MassDisable.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Sample\\News\\Model\\Author;\n\nclass MassDisable extends MassAction\n{\n    /**\n     * @var bool\n     */\n    protected $isActive = false;\n\n    /**\n     * @param Author $author\n     * @return $this\n     */\n    protected function massAction(Author $author)\n    {\n        $author->setIsActive($this->isActive);\n        $this->authorRepository->save($author);\n        return $this;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/MassEnable.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nclass MassEnable extends MassDisable\n{\n    /**\n     * @var bool\n     */\n    protected $isActive = true;\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/NewAction.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Magento\\Backend\\App\\Action;\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Backend\\Model\\View\\Result\\ForwardFactory;\n\nclass NewAction extends Action\n{\n    /**\n     * @var string\n     */\n    const ACTION_RESOURCE = 'Sample_News::author';\n    /**\n     * @var ForwardFactory\n     */\n    protected $resultForwardFactory;\n\n    /**\n     * constructor\n     *\n     * @param Context $context\n     * @param ForwardFactory $resultForwardFactory\n     */\n    public function __construct(\n        Context $context,\n        ForwardFactory $resultForwardFactory\n    ) {\n        $this->resultForwardFactory = $resultForwardFactory;\n        parent::__construct($context);\n    }\n\n\n    /**\n     * forward to edit\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Forward\n     */\n    public function execute()\n    {\n        $resultForward = $this->resultForwardFactory->create();\n        $resultForward->forward('edit');\n        return $resultForward;\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/Save.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Magento\\Backend\\Model\\Session;\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Framework\\Api\\DataObjectHelper;\nuse Magento\\Framework\\Exception\\LocalizedException;\nuse Magento\\Framework\\Reflection\\DataObjectProcessor;\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\Stdlib\\DateTime\\Filter\\Date;\nuse Magento\\Framework\\View\\Result\\PageFactory;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\nuse Sample\\News\\Api\\Data\\AuthorInterface;\nuse Sample\\News\\Api\\Data\\AuthorInterfaceFactory;\nuse Sample\\News\\Controller\\Adminhtml\\Author;\nuse Sample\\News\\Model\\Uploader;\nuse Sample\\News\\Model\\UploaderPool;\n\nclass Save extends Author\n{\n    /**\n     * @var DataObjectProcessor\n     */\n    protected $dataObjectProcessor;\n\n    /**\n     * @var DataObjectHelper\n     */\n    protected $dataObjectHelper;\n\n    /**\n     * @var UploaderPool\n     */\n    protected $uploaderPool;\n\n    /**\n     * @param Registry $registry\n     * @param AuthorRepositoryInterface $authorRepository\n     * @param PageFactory $resultPageFactory\n     * @param Date $dateFilter\n     * @param Context $context\n     * @param AuthorInterfaceFactory $authorFactory\n     * @param DataObjectProcessor $dataObjectProcessor\n     * @param DataObjectHelper $dataObjectHelper\n     * @param UploaderPool $uploaderPool\n     */\n    public function __construct(\n        Registry $registry,\n        AuthorRepositoryInterface $authorRepository,\n        PageFactory $resultPageFactory,\n        Date $dateFilter,\n        Context $context,\n        AuthorInterfaceFactory $authorFactory,\n        DataObjectProcessor $dataObjectProcessor,\n        DataObjectHelper $dataObjectHelper,\n        UploaderPool $uploaderPool\n    )\n    {\n        $this->authorFactory = $authorFactory;\n        $this->dataObjectProcessor = $dataObjectProcessor;\n        $this->dataObjectHelper = $dataObjectHelper;\n        $this->uploaderPool = $uploaderPool;\n        parent::__construct($registry, $authorRepository, $resultPageFactory, $dateFilter, $context);\n    }\n\n    /**\n     * run the action\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Redirect\n     */\n    public function execute()\n    {\n        /** @var \\Sample\\News\\Api\\Data\\AuthorInterface $author */\n        $author = null;\n        $data = $this->getRequest()->getPostValue();\n        $id = !empty($data['author_id']) ? $data['author_id'] : null;\n        $resultRedirect = $this->resultRedirectFactory->create();\n        try {\n            if ($id) {\n                $author = $this->authorRepository->getById((int)$id);\n            } else {\n                unset($data['author_id']);\n                $author = $this->authorFactory->create();\n            }\n            $avatar = $this->getUploader('image')->uploadFileAndGetName('avatar', $data);\n            $data['avatar'] = $avatar;\n            $resume = $this->getUploader('file')->uploadFileAndGetName('resume', $data);\n            $data['resume'] = $resume;\n            $this->dataObjectHelper->populateWithArray($author, $data, AuthorInterface::class);\n            $this->authorRepository->save($author);\n            $this->messageManager->addSuccessMessage(__('You saved the author'));\n            if ($this->getRequest()->getParam('back')) {\n                $resultRedirect->setPath('sample_news/author/edit', ['author_id' => $author->getId()]);\n            } else {\n                $resultRedirect->setPath('sample_news/author');\n            }\n        } catch (LocalizedException $e) {\n            $this->messageManager->addErrorMessage($e->getMessage());\n            if ($author != null) {\n                $this->storeAuthorDataToSession(\n                    $this->dataObjectProcessor->buildOutputDataArray(\n                        $author,\n                        AuthorInterface::class\n                    )\n                );\n            }\n            $resultRedirect->setPath('sample_news/author/edit', ['author_id' => $id]);\n        } catch (\\Exception $e) {\n            $this->messageManager->addErrorMessage(__('There was a problem saving the author'));\n            if ($author != null) {\n                $this->storeAuthorDataToSession(\n                    $this->dataObjectProcessor->buildOutputDataArray(\n                        $author,\n                        AuthorInterface::class\n                    )\n                );\n            }\n            $resultRedirect->setPath('sample_news/author/edit', ['author_id' => $id]);\n        }\n        return $resultRedirect;\n    }\n\n    /**\n     * @param $type\n     * @return Uploader\n     * @throws \\Exception\n     */\n    protected function getUploader($type)\n    {\n        return $this->uploaderPool->getUploader($type);\n    }\n\n    /**\n     * @param $authorData\n     */\n    protected function storeAuthorDataToSession($authorData)\n    {\n        $this->_getSession()->setSampleNewsAuthorData($authorData);\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author/Upload.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml\\Author;\n\nuse Magento\\Backend\\App\\Action;\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Framework\\Controller\\ResultFactory;\nuse Sample\\News\\Model\\Uploader;\n\n\nclass Upload extends Action\n{\n    /**\n     * @var string\n     */\n    const ACTION_RESOURCE = 'Sample_News::author';\n    /**\n     * uploader\n     *\n     * @var Uploader\n     */\n    protected $uploader;\n\n    /**\n     * @param Context $context\n     * @param Uploader $uploader\n     */\n    public function __construct(\n        Context $context,\n        Uploader $uploader\n    ) {\n        parent::__construct($context);\n        $this->uploader = $uploader;\n    }\n\n    /**\n     * Upload file controller action\n     *\n     * @return \\Magento\\Framework\\Controller\\ResultInterface\n     */\n    public function execute()\n    {\n        try {\n            $result = $this->uploader->saveFileToTmpDir($this->getFieldName());\n\n            $result['cookie'] = [\n                'name' => $this->_getSession()->getName(),\n                'value' => $this->_getSession()->getSessionId(),\n                'lifetime' => $this->_getSession()->getCookieLifetime(),\n                'path' => $this->_getSession()->getCookiePath(),\n                'domain' => $this->_getSession()->getCookieDomain(),\n            ];\n        } catch (\\Exception $e) {\n            $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];\n        }\n        return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);\n    }\n\n    /**\n     * @return string\n     */\n    protected function getFieldName()\n    {\n        return $this->_request->getParam('field');\n    }\n}\n"
  },
  {
    "path": "Controller/Adminhtml/Author.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Adminhtml;\n\nuse Magento\\Backend\\App\\Action;\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\Stdlib\\DateTime\\Filter\\Date;\nuse Magento\\Framework\\View\\Result\\PageFactory;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\n\nabstract class Author extends Action\n{\n    /**\n     * @var string\n     */\n    const ACTION_RESOURCE = 'Sample_News::author';\n    /**\n     * author factory\n     *\n     * @var AuthorRepositoryInterface\n     */\n    protected $authorRepository;\n\n    /**\n     * Core registry\n     *\n     * @var Registry\n     */\n    protected $coreRegistry;\n\n    /**\n     * date filter\n     *\n     * @var \\Magento\\Framework\\Stdlib\\DateTime\\Filter\\Date\n     */\n    protected $dateFilter;\n\n    /**\n     * @var PageFactory\n     */\n    protected $resultPageFactory;\n\n    /**\n     * @param Registry $registry\n     * @param AuthorRepositoryInterface $authorRepository\n     * @param PageFactory $resultPageFactory\n     * @param Date $dateFilter\n     * @param Context $context\n     */\n    public function __construct(\n        Registry $registry,\n        AuthorRepositoryInterface $authorRepository,\n        PageFactory $resultPageFactory,\n        Date $dateFilter,\n        Context $context\n\n    ) {\n        $this->coreRegistry      = $registry;\n        $this->authorRepository  = $authorRepository;\n        $this->resultPageFactory = $resultPageFactory;\n        $this->dateFilter        = $dateFilter;\n        parent::__construct($context);\n    }\n\n    /**\n     * filter dates\n     *\n     * @param array $data\n     * @return array\n     */\n    public function filterData($data)\n    {\n        $inputFilter = new \\Zend_Filter_Input(\n            ['dob' => $this->dateFilter],\n            [],\n            $data\n        );\n        $data = $inputFilter->getUnescaped();\n        if (isset($data['awards'])) {\n            if (is_array($data['awards'])) {\n                $data['awards'] = implode(',', $data['awards']);\n            }\n        }\n        return $data;\n    }\n\n}\n"
  },
  {
    "path": "Controller/Author/Index.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Author;\n\nuse Magento\\Framework\\App\\Action\\Action;\nuse Magento\\Framework\\App\\Action\\Context;\nuse Magento\\Framework\\View\\Result\\PageFactory;\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\n\nclass Index extends Action\n{\n    /**\n     * @var string\n     */\n    const META_DESCRIPTION_CONFIG_PATH = 'sample_news/author/meta_description';\n    /**\n     * @var string\n     */\n    const META_KEYWORDS_CONFIG_PATH = 'sample_news/author/meta_keywords';\n    /**\n     * @var string\n     */\n    const META_TITLE_CONFIG_PATH = 'sample_news/author/meta_title';\n    /**\n     * @var string\n     */\n    const BREADCRUMBS_CONFIG_PATH = 'sample_news/author/breadcrumbs';\n\n    /**\n     * @var \\Magento\\Framework\\App\\Config\\ScopeConfigInterface\n     */\n    protected $scopeConfig;\n\n    /**\n     * @param Context $context\n     * @param PageFactory $resultPageFactory\n     * @param ScopeConfigInterface $scopeConfig\n     */\n    public function __construct(\n        Context $context,\n        PageFactory $resultPageFactory,\n        ScopeConfigInterface $scopeConfig\n    ) {\n        parent::__construct($context);\n        $this->resultPageFactory = $resultPageFactory;\n        $this->scopeConfig = $scopeConfig;\n    }\n\n    /**\n     * @return \\Magento\\Framework\\View\\Result\\Page\n     */\n    public function execute()\n    {\n        $resultPage = $this->resultPageFactory->create();\n        $resultPage->getConfig()->getTitle()->set(\n            $this->scopeConfig->getValue(self::META_TITLE_CONFIG_PATH, ScopeInterface::SCOPE_STORE)\n        );\n        $resultPage->getConfig()->setDescription(\n            $this->scopeConfig->getValue(self::META_DESCRIPTION_CONFIG_PATH, ScopeInterface::SCOPE_STORE)\n        );\n        $resultPage->getConfig()->setKeywords(\n            $this->scopeConfig->getValue(self::META_KEYWORDS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)\n        );\n        if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) {\n            /** @var \\Magento\\Theme\\Block\\Html\\Breadcrumbs $breadcrumbsBlock */\n            $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs');\n            if ($breadcrumbsBlock) {\n                $breadcrumbsBlock->addCrumb(\n                    'home',\n                    [\n                        'label'    => __('Home'),\n                        'link'     => $this->_url->getUrl('')\n                    ]\n                );\n                $breadcrumbsBlock->addCrumb(\n                    'authors',\n                    [\n                        'label'    => __('Authors'),\n                    ]\n                );\n            }\n        }\n        return $resultPage;\n    }\n}\n"
  },
  {
    "path": "Controller/Author/Rss.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Author;\n\nuse Magento\\Customer\\Api\\AccountManagementInterface;\nuse Magento\\Customer\\Model\\Session;\n\nclass Rss extends \\Magento\\Rss\\Controller\\Feed\\Index\n{\n    /**\n     * @return void\n     */\n    public function execute()\n    {\n        $this->getRequest()->setParam('type', 'authors');\n        parent::execute();\n    }\n}\n"
  },
  {
    "path": "Controller/Author/View.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller\\Author;\n\nuse Magento\\Framework\\App\\Action\\Action;\nuse Magento\\Framework\\App\\Action\\Context;\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Framework\\Controller\\Result\\ForwardFactory;\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\View\\Result\\PageFactory;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\nuse Sample\\News\\Model\\Author\\Url as UrlModel;\n\nclass View extends Action\n{\n    /**\n     * @var string\n     */\n    const BREADCRUMBS_CONFIG_PATH = 'sample_news/author/breadcrumbs';\n    /**\n     * @var \\Sample\\News\\Api\\AuthorRepositoryInterface\n     */\n    protected $authorRepository;\n\n    /**\n     * @var \\Magento\\Framework\\Controller\\Result\\ForwardFactory\n     */\n    protected $resultForwardFactory;\n\n    /**\n     * @var \\Magento\\Framework\\View\\Result\\PageFactory\n     */\n    protected $resultPageFactory;\n\n    /**\n     * @var \\Magento\\Framework\\Registry\n     */\n    protected $coreRegistry;\n\n    /**\n     * @var \\Sample\\News\\Model\\Author\\Url\n     */\n    protected $urlModel;\n\n    /**\n     * @var \\Magento\\Framework\\App\\Config\\ScopeConfigInterface\n     */\n    protected $scopeConfig;\n\n    /**\n     * @param Context $context\n     * @param AuthorRepositoryInterface $authorRepository\n     * @param ForwardFactory $resultForwardFactory\n     * @param PageFactory $resultPageFactory\n     * @param Registry $coreRegistry\n     * @param UrlModel $urlModel\n     * @param ScopeConfigInterface $scopeConfig\n     */\n    public function __construct(\n        Context $context,\n        AuthorRepositoryInterface $authorRepository,\n        ForwardFactory $resultForwardFactory,\n        PageFactory $resultPageFactory,\n        Registry $coreRegistry,\n        UrlModel $urlModel,\n        ScopeConfigInterface $scopeConfig\n    ) {\n        $this->resultForwardFactory = $resultForwardFactory;\n        $this->authorRepository     = $authorRepository;\n        $this->resultPageFactory    = $resultPageFactory;\n        $this->coreRegistry         = $coreRegistry;\n        $this->urlModel             = $urlModel;\n        $this->scopeConfig          = $scopeConfig;\n        parent::__construct($context);\n    }\n\n    /**\n     * @return \\Magento\\Framework\\Controller\\Result\\Forward|\\Magento\\Framework\\View\\Result\\Page\n     */\n    public function execute()\n    {\n        try {\n            $authorId = (int)$this->getRequest()->getParam('id');\n            $author = $this->authorRepository->getById($authorId);\n\n            if (!$author->getIsActive()) {\n                throw new \\Exception();\n            }\n        } catch (\\Exception $e){\n            $resultForward = $this->resultForwardFactory->create();\n            $resultForward->forward('noroute');\n            return $resultForward;\n        }\n\n        $this->coreRegistry->register('current_author', $author);\n\n        $resultPage = $this->resultPageFactory->create();\n        //$title = ($author->getMetaTitle()) ?: $author->getName();\n        $resultPage->getConfig()->getTitle()->set($author->getName());\n        $resultPage->getConfig()->setDescription($author->getMetaDescription());\n        $resultPage->getConfig()->setKeywords($author->getMetaKeywords());\n        if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) {\n            /** @var \\Magento\\Theme\\Block\\Html\\Breadcrumbs $breadcrumbsBlock */\n            $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs');\n            if ($breadcrumbsBlock) {\n                $breadcrumbsBlock->addCrumb(\n                    'home',\n                    [\n                        'label' => __('Home'),\n                        'link'  => $this->_url->getUrl('')\n                    ]\n                );\n                $breadcrumbsBlock->addCrumb(\n                    'authors',\n                    [\n                        'label' => __('Authors'),\n                        'link'  => $this->urlModel->getListUrl()\n                    ]\n                );\n                $breadcrumbsBlock->addCrumb(\n                    'author-'.$author->getId(),\n                    [\n                        'label' => $author->getName()\n                    ]\n                );\n            }\n        }\n\n        return $resultPage;\n    }\n}\n"
  },
  {
    "path": "Controller/RegistryConstants.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller;\n\nclass RegistryConstants\n{\n    /**\n     * Registry key where current author ID is stored\n     */\n    const CURRENT_AUTHOR_ID = 'current_author_id';\n}\n"
  },
  {
    "path": "Controller/Router.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Controller;\n\nuse Magento\\Framework\\App\\ActionFactory;\nuse Magento\\Framework\\App\\Action\\Forward;\nuse Magento\\Framework\\App\\Action\\Redirect;\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Framework\\App\\RequestInterface;\nuse Magento\\Framework\\App\\ResponseInterface;\nuse Magento\\Framework\\App\\RouterInterface;\nuse Magento\\Framework\\App\\State;\nuse Magento\\Framework\\DataObject;\nuse Magento\\Framework\\Event\\ManagerInterface;\nuse Magento\\Framework\\Url;\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Sample\\News\\Model\\Routing\\Entity;\n\nclass Router implements RouterInterface\n{\n    /**\n     * @var \\Magento\\Framework\\App\\ActionFactory\n     */\n    protected $actionFactory;\n\n    /**\n     * Event manager\n     * @var \\Magento\\Framework\\Event\\ManagerInterface\n     */\n    protected $eventManager;\n\n    /**\n     * Store manager\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * Author factory\n     * @var \\Sample\\News\\Model\\AuthorFactory\n     */\n    protected $authorFactory;\n\n    /**\n     * Config primary\n     * @var \\Magento\\Framework\\App\\State\n     */\n    protected $appState;\n\n    /**\n     * Url\n     * @var \\Magento\\Framework\\UrlInterface\n     */\n    protected $url;\n\n    /**\n     * Response\n     * @var \\Magento\\Framework\\App\\ResponseInterface|\\Magento\\Framework\\App\\Response\\Http\n     */\n    protected $response;\n\n    /**\n     * @var \\Magento\\Framework\\App\\Config\\ScopeConfigInterface\n     */\n    protected $scopeConfig;\n    /**\n     * @var bool\n     */\n    protected $dispatched;\n\n    /**\n     * @var \\Sample\\News\\Model\\Routing\\Entity[]\n     */\n    protected $routingEntities;\n\n    /**\n     * @param ActionFactory $actionFactory\n     * @param ManagerInterface $eventManager\n     * @param UrlInterface $url\n     * @param State $appState\n     * @param StoreManagerInterface $storeManager\n     * @param ResponseInterface $response\n     * @param ScopeConfigInterface $scopeConfig\n     * @param array $routingEntities\n     */\n    public function __construct(\n        ActionFactory $actionFactory,\n        ManagerInterface $eventManager,\n        UrlInterface $url,\n        State $appState,\n        StoreManagerInterface $storeManager,\n        ResponseInterface $response,\n        ScopeConfigInterface $scopeConfig,\n        array $routingEntities\n    ) {\n        $this->actionFactory    = $actionFactory;\n        $this->eventManager     = $eventManager;\n        $this->url              = $url;\n        $this->appState         = $appState;\n        $this->storeManager     = $storeManager;\n        $this->response         = $response;\n        $this->scopeConfig      = $scopeConfig;\n        $this->routingEntities  = $routingEntities;\n    }\n\n    /**\n     * Validate and Match News Author and modify request\n     *\n     * @param \\Magento\\Framework\\App\\RequestInterface|\\Magento\\Framework\\HTTP\\PhpEnvironment\\Request $request\n     * @return bool\n     */\n    public function match(RequestInterface $request)\n    {\n        if (!$this->dispatched) {\n            $urlKey = trim($request->getPathInfo(), '/');\n            $origUrlKey = $urlKey;\n            /** @var Object $condition */\n            $condition = new DataObject(['url_key' => $urlKey, 'continue' => true]);\n            $this->eventManager->dispatch(\n                'sample_news_controller_router_match_before',\n                ['router' => $this, 'condition' => $condition]\n            );\n            $urlKey = $condition->getUrlKey();\n            if ($condition->getRedirectUrl()) {\n                $this->response->setRedirect($condition->getRedirectUrl());\n                $request->setDispatched(true);\n                return $this->actionFactory->create(Redirect::class);\n            }\n            if (!$condition->getContinue()) {\n                return null;\n            }\n            foreach ($this->routingEntities as $entityKey => $entity) {\n                $match = $this->matchRoute($request, $entity, $urlKey, $origUrlKey);\n                if ($match === false) {\n                    continue;\n                }\n                return $match;\n            }\n        }\n        return null;\n    }\n\n    /**\n     * @param RequestInterface|\\Magento\\Framework\\HTTP\\PhpEnvironment\\Request $request\n     * @param Entity $entity\n     * @param $urlKey\n     * @param $origUrlKey\n     * @return bool|\\Magento\\Framework\\App\\ActionInterface|null\n     */\n    protected function matchRoute(RequestInterface $request, Entity $entity, $urlKey, $origUrlKey)\n    {\n        $listKey = $this->scopeConfig->getValue($entity->getListKeyConfigPath(), ScopeInterface::SCOPE_STORE);\n        if ($listKey) {\n            if ($urlKey == $listKey) {\n                $request->setModuleName('sample_news');\n                $request->setControllerName($entity->getController());\n                $request->setActionName($entity->getListAction());\n                $request->setAlias(Url::REWRITE_REQUEST_PATH_ALIAS, $urlKey);\n                $this->dispatched = true;\n                return $this->actionFactory->create(Forward::class);\n            }\n        }\n        $prefix = $this->scopeConfig->getValue($entity->getPrefixConfigPath(), ScopeInterface::SCOPE_STORE);\n        if ($prefix) {\n            $parts = explode('/', $urlKey);\n            if ($parts[0] != $prefix || count($parts) != 2) {\n                return false;\n            }\n            $urlKey = $parts[1];\n        }\n        $configSuffix = $this->scopeConfig->getValue($entity->getSuffixConfigPath(), ScopeInterface::SCOPE_STORE);\n        if ($configSuffix) {\n            $suffix = substr($urlKey, -strlen($configSuffix) - 1);\n            if ($suffix != '.'.$configSuffix) {\n                return false;\n            }\n            $urlKey = substr($urlKey, 0, -strlen($configSuffix) - 1);\n        }\n        $instance = $entity->getFactory()->create();\n        $id = $instance->checkUrlKey($urlKey, $this->storeManager->getStore()->getId());\n        if (!$id) {\n            return null;\n        }\n        $request->setModuleName('sample_news');\n        $request->setControllerName($entity->getController());\n        $request->setActionName($entity->getViewAction());\n        $request->setParam($entity->getParam(), $id);\n        $request->setAlias(Url::REWRITE_REQUEST_PATH_ALIAS, $origUrlKey);\n        $request->setDispatched(true);\n        $this->dispatched = true;\n        return $this->actionFactory->create(Forward::class);\n    }\n}\n"
  },
  {
    "path": "Helper/Image.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Helper;\n\nuse Magento\\Framework\\App\\Area;\nuse Magento\\Framework\\App\\Helper\\AbstractHelper;\nuse Magento\\Framework\\App\\Helper\\Context;\nuse Magento\\Framework\\View\\Asset\\Repository;\nuse Magento\\Framework\\View\\ConfigInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Sample\\News\\Model\\ImageFactory;\n\n/**\n * @SuppressWarnings(PHPMD.TooManyFields)\n */\nclass Image extends AbstractHelper\n{\n    /**\n     * Media config node\n     */\n    const MEDIA_TYPE_CONFIG_NODE = 'images';\n\n    /**\n     * Current model\n     *\n     * @var \\Sample\\News\\Model\\Image\n     */\n    protected $model;\n\n    /**\n     * Scheduled for resize image\n     *\n     * @var bool\n     */\n    protected $scheduleResize = true;\n\n    /**\n     * Scheduled for rotate image\n     *\n     * @var bool\n     */\n    protected $scheduleRotate = false;\n\n    /**\n     * Angle\n     *\n     * @var int\n     */\n    protected $angle;\n\n    /**\n     * Watermark file name\n     *\n     * @var string\n     */\n    protected $watermark;\n\n    /**\n     * Watermark Position\n     *\n     * @var string\n     */\n    protected $watermarkPosition;\n\n    /**\n     * Watermark Size\n     *\n     * @var string\n     */\n    protected $watermarkSize;\n\n    /**\n     * Watermark Image opacity\n     *\n     * @var int\n     */\n    protected $watermarkImageOpacity;\n\n    /**\n     * Current Product\n     *\n     * @var \\Magento\\Framework\\Model\\AbstractModel\n     */\n    protected $entity;\n\n    /**\n     * Image File\n     *\n     * @var string\n     */\n    protected $imageFile;\n\n    /**\n     * Image Placeholder\n     *\n     * @var string\n     */\n    protected $placeholder;\n\n    /**\n     * @var \\Magento\\Framework\\View\\Asset\\Repository\n     */\n    protected $assetRepo;\n\n    /**\n     * image factory\n     *\n     * @var \\Sample\\News\\Model\\ImageFactory\n     */\n    protected $imageFactory;\n\n    /**\n     * @var \\Magento\\Framework\\View\\ConfigInterface\n     */\n    protected $viewConfig;\n\n    /**\n     * @var \\Magento\\Framework\\Config\\View\n     */\n    protected $configView;\n\n    /**\n     * Image configuration attributes\n     *\n     * @var array\n     */\n    protected $attributes = [];\n\n    /**\n     * @var string\n     */\n    protected $entityCode;\n\n    /**\n     * @param Context $context\n     * @param ImageFactory $imageFactory\n     * @param Repository $assetRepo\n     * @param ConfigInterface $viewConfig\n     * @param $entityCode\n     */\n    public function __construct(\n        Context $context,\n        ImageFactory $imageFactory,\n        Repository $assetRepo,\n        ConfigInterface $viewConfig,\n        $entityCode\n    ) {\n        $this->imageFactory = $imageFactory;\n        $this->assetRepo    = $assetRepo;\n        $this->viewConfig   = $viewConfig;\n        $this->entityCode   = $entityCode;\n        parent::__construct($context);\n    }\n\n    /**\n     * Reset all previous data\n     *\n     * @return $this\n     */\n    protected function _reset()\n    {\n        $this->model                    = null;\n        $this->scheduleRotate           = false;\n        $this->angle                    = null;\n        $this->watermark                = null;\n        $this->watermarkPosition        = null;\n        $this->watermarkSize            = null;\n        $this->watermarkImageOpacity    = null;\n        $this->entity                   = null;\n        $this->imageFile                = null;\n        $this->attributes               = [];\n        return $this;\n    }\n\n    /**\n     * Initialize Helper to work with Image\n     *\n     * @param \\Magento\\Framework\\Model\\AbstractModel $entity\n     * @param string $imageId\n     * @param array $attributes\n     * @return $this\n     */\n    public function init($entity, $imageId, $attributes = [])\n    {\n        $this->_reset();\n\n        $this->attributes = array_merge(\n            $this->getConfigView()->getMediaAttributes('Sample_News', self::MEDIA_TYPE_CONFIG_NODE, $imageId),\n            $attributes\n        );\n\n        $this->setEntity($entity);\n        $this->setImageProperties();\n        $this->setWatermarkProperties();\n\n        return $this;\n    }\n\n    /**\n     * Set image properties\n     *\n     * @return $this\n     */\n    protected function setImageProperties()\n    {\n        $this->getModel()->setDestinationSubdir($this->getType());\n\n        $this->getModel()->setWidth($this->getWidth());\n        $this->getModel()->setHeight($this->getHeight());\n\n        // Set 'keep frame' flag\n        $frame = $this->getFrame();\n        if (!empty($frame)) {\n            $this->getModel()->setKeepFrame($frame);\n        }\n\n        // Set 'constrain only' flag\n        $constrain = $this->getAttribute('constrain');\n        if (!empty($constrain)) {\n            $this->getModel()->setConstrainOnly($constrain);\n        }\n\n        // Set 'keep aspect ratio' flag\n        $aspectRatio = $this->getAttribute('aspect_ratio');\n        if (!empty($aspectRatio)) {\n            $this->getModel()->setKeepAspectRatio($aspectRatio);\n        }\n\n        // Set 'transparency' flag\n        $transparency = $this->getAttribute('transparency');\n        if (!empty($transparency)) {\n            $this->getModel()->setKeepTransparency($transparency);\n        }\n\n        // Set background color\n        $background = $this->getAttribute('background');\n        if (!empty($background)) {\n            $this->getModel()->setBackgroundColor($background);\n        }\n\n        return $this;\n    }\n\n    /**\n     * Set watermark properties\n     * @return $this\n     */\n    protected function setWatermarkProperties()\n    {\n        // @codingStandardsIgnoreStart\n        //TODO: set proper watermarks paths\n        // @codingStandardsIgnoreEnd\n        $this->setWatermark(\n            $this->scopeConfig->getValue(\n                \"design/watermark/{$this->getModel()->getDestinationSubdir()}_image\",\n                ScopeInterface::SCOPE_STORE\n            )\n        );\n        $this->setWatermarkImageOpacity(\n            $this->scopeConfig->getValue(\n                \"design/watermark/{$this->getModel()->getDestinationSubdir()}_imageOpacity\",\n                ScopeInterface::SCOPE_STORE\n            )\n        );\n        $this->setWatermarkPosition(\n            $this->scopeConfig->getValue(\n                \"design/watermark/{$this->getModel()->getDestinationSubdir()}_position\",\n                ScopeInterface::SCOPE_STORE\n            )\n        );\n        $this->setWatermarkSize(\n            $this->scopeConfig->getValue(\n                \"design/watermark/{$this->getModel()->getDestinationSubdir()}_size\",\n                ScopeInterface::SCOPE_STORE\n            )\n        );\n        return $this;\n    }\n\n    /**\n     * Schedule resize of the image\n     * $width *or* $height can be null - in this case, lacking dimension will be calculated.\n     *\n     * @see \\Sample\\News\\Model\\Image\n     * @param int $width\n     * @param int $height\n     * @return $this\n     */\n    public function resize($width, $height = null)\n    {\n        $this->getModel()->setWidth($width)->setHeight($height);\n        $this->scheduleResize = true;\n        return $this;\n    }\n\n    /**\n     * Set image quality, values in percentage from 0 to 100\n     *\n     * @param int $quality\n     * @return $this\n     */\n    public function setQuality($quality)\n    {\n        $this->getModel()->setQuality($quality);\n        return $this;\n    }\n\n    /**\n     * Guarantee, that image picture width/height will not be distorted.\n     * Applicable before calling resize()\n     * It is true by default.\n     *\n     * @see \\Sample\\News\\Model\\Image\n     * @param bool $flag\n     * @return $this\n     */\n    public function keepAspectRatio($flag)\n    {\n        $this->getModel()->setKeepAspectRatio($flag);\n        return $this;\n    }\n\n    /**\n     * Guarantee, that image will have dimensions, set in $width/$height\n     * Applicable before calling resize()\n     * Not applicable, if keepAspectRatio(false)\n     *\n     * @see \\Sample\\News\\Model\\Image\n     * @param bool $flag\n     * @return $this\n     * @SuppressWarnings(PHPMD.UnusedFormalParameter)\n     */\n    public function keepFrame($flag)\n    {\n        $this->getModel()->setKeepFrame($flag);\n        return $this;\n    }\n\n    /**\n     * Guarantee, that image will not lose transparency if any.\n     * Applicable before calling resize()\n     * It is true by default.\n     *\n     * @see \\Sample\\News\\Model\\Image\n     * @param bool $flag\n     * @return $this\n     * @SuppressWarnings(PHPMD.UnusedFormalParameter)\n     */\n    public function keepTransparency($flag)\n    {\n        $this->getModel()->setKeepTransparency($flag);\n        return $this;\n    }\n\n    /**\n     * Guarantee, that image picture will not be bigger, than it was.\n     * Applicable before calling resize()\n     * It is false by default\n     *\n     * @param bool $flag\n     * @return $this\n     */\n    public function constrainOnly($flag)\n    {\n        $this->getModel()->setConstrainOnly($flag);\n        return $this;\n    }\n\n    /**\n     * Set color to fill image frame with.\n     * Applicable before calling resize()\n     * The keepTransparency(true) overrides this (if image has transparent color)\n     * It is white by default.\n     *\n     * @see \\Sample\\News\\Model\\Image\\Image\n     * @param array $colorRGB\n     * @return $this\n     */\n    public function backgroundColor($colorRGB)\n    {\n        // assume that 3 params were given instead of array\n        if (!is_array($colorRGB)) {\n            $colorRGB = func_get_args();\n        }\n        $this->getModel()->setBackgroundColor($colorRGB);\n        return $this;\n    }\n\n    /**\n     * Rotate image into specified angle\n     *\n     * @param int $angle\n     * @return $this\n     */\n    public function rotate($angle)\n    {\n        $this->setAngle($angle);\n        $this->getModel()->setAngle($angle);\n        $this->scheduleRotate = true;\n        return $this;\n    }\n\n    /**\n     * Add watermark to image\n     * size param in format 100x200\n     *\n     * @param string $fileName\n     * @param string $position\n     * @param string $size\n     * @param int $imageOpacity\n     * @return $this\n     */\n    public function watermark($fileName, $position, $size = null, $imageOpacity = null)\n    {\n        $this->setWatermark($fileName)\n            ->setWatermarkPosition($position)\n            ->setWatermarkSize($size)\n            ->setWatermarkImageOpacity($imageOpacity);\n        return $this;\n    }\n\n    /**\n     * Set placeholder\n     *\n     * @param string $fileName\n     * @return void\n     */\n    public function placeholder($fileName)\n    {\n        $this->placeholder = $fileName;\n    }\n\n    /**\n     * Get Placeholder\n     *\n     * @param null|string $placeholder\n     * @return string\n     */\n    public function getPlaceholder($placeholder = null)\n    {\n        if ($placeholder) {\n            $placeholderFullPath = 'Sample_News::images/'.$this->entityCode.'/placeholder/' . $placeholder . '.jpg';\n        } else {\n            $placeholderFullPath = $this->placeholder\n                ?: 'Sample_News::images/'.$this->entityCode.'/placeholder/' . $this->getModel()->getDestinationSubdir() . '.jpg';\n        }\n        return $placeholderFullPath;\n    }\n\n    /**\n     * Apply scheduled actions\n     *\n     * @return $this\n     * @throws \\Exception\n     */\n    protected function applyScheduledActions()\n    {\n        $this->initBaseFile();\n        if ($this->isScheduledActionsAllowed()) {\n            $model = $this->getModel();\n            if ($this->scheduleRotate) {\n                $model->rotate($this->getAngle());\n            }\n            if ($this->scheduleResize) {\n                $model->resize();\n            }\n            if ($this->getWatermark()) {\n                $model->setWatermark($this->getWatermark());\n            }\n            $model->saveFile();\n        }\n        return $this;\n    }\n\n    /**\n     * Initialize base image file\n     *\n     * @return $this\n     */\n    protected function initBaseFile()\n    {\n        $model = $this->getModel();\n        $baseFile = $model->getBaseFile();\n        if (!$baseFile) {\n            if ($this->getImageFile()) {\n                $model->setBaseFile($this->getImageFile());\n            } else {\n                $model->setBaseFile($this->getEntity()->getData($model->getDestinationSubdir()));\n            }\n        }\n        return $this;\n    }\n\n    /**\n     * Check if scheduled actions is allowed\n     *\n     * @return bool\n     */\n    protected function isScheduledActionsAllowed()\n    {\n        $model = $this->getModel();\n        if ($model->isBaseFilePlaceholder()\n            && $model->getNewFile() === true\n            || $model->isCached()\n        ) {\n            return false;\n        }\n        return true;\n    }\n\n    /**\n     * Retrieve image URL\n     *\n     * @return string\n     */\n    public function getUrl()\n    {\n        try {\n            $this->applyScheduledActions();\n            return $this->getModel()->getUrl();\n        } catch (\\Exception $e) {\n            return $this->getDefaultPlaceholderUrl();\n        }\n    }\n\n    /**\n     * @return $this\n     */\n    public function save()\n    {\n        $this->applyScheduledActions();\n        return $this;\n    }\n\n    /**\n     * Return resized image information\n     *\n     * @return array\n     */\n    public function getResizedImageInfo()\n    {\n        $this->applyScheduledActions();\n        return $this->getModel()->getResizedImageInfo();\n    }\n\n    /**\n     * @param null|string $placeholder\n     * @return string\n     */\n    public function getDefaultPlaceholderUrl($placeholder = null)\n    {\n        try {\n            $url = $this->assetRepo->getUrl($this->getPlaceholder($placeholder));\n        } catch (\\Exception $e) {\n            $this->_logger->critical($e);\n            $url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAnFBMVEUAAAAAAAAAAAAAAAC0tLS4uLi0tLT6+vrx8fHo6Ojj4OC+mpq7UE2wXlqzOTGtHwza2dnGaWeiJxDV0dGNJhari4uqeHi/W1edTkevSkWWNCOLEQiXEgbExMXbiorTgH+NT0a4RD+XIxTPFwm7BQHYAwHJAwDLd3aWcXDKV03JODOjNyunLCS6JQ6nCQO/q6viqKjFREOYQTrQIiHNANNfAAAAB3RSTlMCPiYZ3uvFTohbPwAAAURJREFUOMuVk9dygzAQRW3jeGUhikQvDtUl7uX//y0b4bGMCDPJAV64Z+5Ko9HkLxizEYynMCW/A9OXsETI8xkRSPeNNpDnOyZo5dChCe8pAUJ04Qd65bzYXilIaSiYrPhEisoEiS5YvOCVbdt8G1kDATGjbWV5QC7HiDNzKFCb2/J3wqKIVcuBEDImi60vxo5JEvYEQCFmB0/mt5sdHhNLF+CQHGS+3+Ok2k8HQprVAPf944E51JkuAMRZdrk7m7WDuZfncV9Awiz3uxzlcx5qAgHq5067kXkgzj7VBCSoz63YYX/stCKAQQNAKdrmJITTbERJJErojMA/Net1c/IDPBxK6cJ424WE7so0LXcuoauV585nk5fQh5AVgDvvBqgGBRaA+yFztcheAfWoytUIJbhd/3iDykcWuZhpl3eqYUz+wTdj6SFVkjRnJQAAAABJRU5ErkJggg==';\n        }\n        return $url;\n    }\n\n    /**\n     * Get current Image model\n     *\n     * @return \\Sample\\News\\Model\\Image\n     */\n    protected function getModel()\n    {\n        if (!$this->model) {\n            $this->model = $this->imageFactory->create(['entityCode' => 'author']);\n        }\n        return $this->model;\n    }\n\n    /**\n     * Set Rotation Angle\n     *\n     * @param int $angle\n     * @return $this\n     */\n    protected function setAngle($angle)\n    {\n        $this->angle = $angle;\n        return $this;\n    }\n\n    /**\n     * Get Rotation Angle\n     *\n     * @return int\n     */\n    protected function getAngle()\n    {\n        return $this->angle;\n    }\n\n    /**\n     * Set watermark file name\n     *\n     * @param string $watermark\n     * @return $this\n     */\n    protected function setWatermark($watermark)\n    {\n        $this->watermark = $watermark;\n        $this->getModel()->setWatermarkFile($watermark);\n        return $this;\n    }\n\n    /**\n     * Get watermark file name\n     *\n     * @return string\n     */\n    protected function getWatermark()\n    {\n        return $this->watermark;\n    }\n\n    /**\n     * Set watermark position\n     *\n     * @param string $position\n     * @return $this\n     */\n    protected function setWatermarkPosition($position)\n    {\n        $this->watermarkPosition = $position;\n        $this->getModel()->setWatermarkPosition($position);\n        return $this;\n    }\n\n    /**\n     * Get watermark position\n     *\n     * @return string\n     */\n    protected function getWatermarkPosition()\n    {\n        return $this->watermarkPosition;\n    }\n\n    /**\n     * Set watermark size\n     * param size in format 100x200\n     *\n     * @param string $size\n     * @return $this\n     */\n    public function setWatermarkSize($size)\n    {\n        $this->watermarkSize = $size;\n        $this->getModel()->setWatermarkSize($this->parseSize($size));\n        return $this;\n    }\n\n    /**\n     * Get watermark size\n     *\n     * @return string\n     */\n    protected function getWatermarkSize()\n    {\n        return $this->watermarkSize;\n    }\n\n    /**\n     * Set watermark image opacity\n     *\n     * @param int $imageOpacity\n     * @return $this\n     */\n    public function setWatermarkImageOpacity($imageOpacity)\n    {\n        $this->watermarkImageOpacity = $imageOpacity;\n        $this->getModel()->setWatermarkImageOpacity($imageOpacity);\n        return $this;\n    }\n\n    /**\n     * Get watermark image opacity\n     *\n     * @return int\n     */\n    protected function getWatermarkImageOpacity()\n    {\n        if ($this->watermarkImageOpacity) {\n            return $this->watermarkImageOpacity;\n        }\n\n        return $this->getModel()->getWatermarkImageOpacity();\n    }\n\n    /**\n     * Set current Entity\n     *\n     * @param \\Magento\\Framework\\Model\\AbstractModel\n     * @return $this\n     */\n    protected function setEntity($entity)\n    {\n        $this->entity = $entity;\n        return $this;\n    }\n\n    /**\n     * Get current Product\n     *\n     * @return \\Magento\\Framework\\Model\\AbstractModel\n     */\n    protected function getEntity()\n    {\n        return $this->entity;\n    }\n\n    /**\n     * Set Image file\n     *\n     * @param string $file\n     * @return $this\n     */\n    public function setImageFile($file)\n    {\n        $this->imageFile = $file;\n        return $this;\n    }\n\n    /**\n     * Get Image file\n     *\n     * @return string\n     */\n    protected function getImageFile()\n    {\n        return $this->imageFile;\n    }\n\n    /**\n     * Retrieve size from string\n     *\n     * @param string $string\n     * @return array|bool\n     */\n    protected function parseSize($string)\n    {\n        $size = explode('x', strtolower($string));\n        if (sizeof($size) == 2) {\n            return [\n                'width' => $size[0] > 0 ? $size[0] : null,\n                'height' => $size[1] > 0 ? $size[1] : null\n            ];\n        }\n        return false;\n    }\n\n    /**\n     * Retrieve original image width\n     *\n     * @return int|null\n     */\n    public function getOriginalWidth()\n    {\n        return $this->getModel()->getImageProcessor()->getOriginalWidth();\n    }\n\n    /**\n     * Retrieve original image height\n     *\n     * @return int|null\n     */\n    public function getOriginalHeight()\n    {\n        return $this->getModel()->getImageProcessor()->getOriginalHeight();\n    }\n\n    /**\n     * Retrieve Original image size as array\n     * 0 - width, 1 - height\n     *\n     * @return int[]\n     */\n    public function getOriginalSizeArray()\n    {\n        return [$this->getOriginalWidth(), $this->getOriginalHeight()];\n    }\n\n    /**\n     * Retrieve config view\n     *\n     * @return \\Magento\\Framework\\Config\\View\n     */\n    protected function getConfigView()\n    {\n        if (!$this->configView) {\n            $this->configView = $this->viewConfig->getViewConfig();\n        }\n        return $this->configView;\n    }\n\n    /**\n     * Retrieve image type\n     *\n     * @return string\n     */\n    public function getType()\n    {\n        return $this->getAttribute('type');\n    }\n\n    /**\n     * Retrieve image width\n     *\n     * @return string\n     */\n    public function getWidth()\n    {\n        return $this->getAttribute('width');\n    }\n\n    /**\n     * Retrieve image height\n     *\n     * @return string\n     */\n    public function getHeight()\n    {\n        return $this->getAttribute('height') ?: $this->getAttribute('width');\n    }\n\n    /**\n     * Retrieve image frame flag\n     *\n     * @return false|string\n     */\n    public function getFrame()\n    {\n        $frame = $this->getAttribute('frame');\n        if (empty($frame)) {\n            $frame = $this->getConfigView()->getVarValue('Sample_News', 'image_white_borders');\n        }\n        return $frame;\n    }\n\n    /**\n     * Retrieve image attribute\n     *\n     * @param string $name\n     * @return string\n     */\n    protected function getAttribute($name)\n    {\n        return isset($this->attributes[$name]) ? $this->attributes[$name] : null;\n    }\n\n    /**\n     * Return image label\n     *\n     * @return string\n     */\n    public function getLabel()\n    {\n        return $this->entity->getData('name');\n    }\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\r\n\r\nCopyright (c) 2016 Marius\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n"
  },
  {
    "path": "Model/Author/DataProvider.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\Author;\n\nuse Magento\\Ui\\DataProvider\\AbstractDataProvider;\nuse Magento\\Ui\\DataProvider\\Modifier\\ModifierInterface;\nuse Magento\\Ui\\DataProvider\\Modifier\\PoolInterface;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory;\n\nclass DataProvider extends AbstractDataProvider\n{\n    /**\n     * @var array\n     */\n    protected $loadedData;\n\n    /**\n     * @var PoolInterface\n     */\n    protected $pool;\n\n    /**\n     * @param string $name\n     * @param string $primaryFieldName\n     * @param string $requestFieldName\n     * @param CollectionFactory $authorCollectionFactory\n     * @param PoolInterface $pool\n     * @param array $meta\n     * @param array $data\n     */\n    public function __construct(\n        $name,\n        $primaryFieldName,\n        $requestFieldName,\n        CollectionFactory $authorCollectionFactory,\n        PoolInterface $pool,\n        array $meta = [],\n        array $data = []\n    ) {\n        $this->collection   = $authorCollectionFactory->create();\n        $this->pool         = $pool;\n        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);\n        $this->meta = $this->prepareMeta($this->meta);\n    }\n\n    /**\n     * Prepares Meta\n     *\n     * @param array $meta\n     * @return array\n     */\n    public function prepareMeta(array $meta)\n    {\n        $meta = parent::getMeta();\n\n        /** @var ModifierInterface $modifier */\n        foreach ($this->pool->getModifiersInstances() as $modifier) {\n            $meta = $modifier->modifyMeta($meta);\n        }\n        return $meta;\n    }\n\n    /**\n     * Get data\n     *\n     * @return array\n     */\n    public function getData()\n    {\n        /** @var ModifierInterface $modifier */\n        foreach ($this->pool->getModifiersInstances() as $modifier) {\n            $this->data = $modifier->modifyData($this->data);\n        }\n        return $this->data;\n    }\n}\n"
  },
  {
    "path": "Model/Author/Rss.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\Author;\n\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Magento\\Store\\Model\\StoreManagerInterface;\n\nclass Rss\n{\n    /**\n     * @var string\n     */\n    const RSS_PAGE_URL                  = 'sample_news/author/rss';\n    /**\n     * @var string\n     */\n    const AUTHOR_RSS_ACTIVE_CONFIG_PATH = 'sample_news/author/rss';\n    /**\n     * @var string\n     */\n    const GLOBAL_RSS_ACTIVE_CONFIG_PATH = 'rss/config/active';\n    /**\n     * @var ScopeConfigInterface\n     */\n    protected $scopeConfig;\n    /**\n     * @var UrlInterface\n     */\n    protected $urlBuilder;\n    /**\n     * @var StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * @param UrlInterface $urlBuilder\n     * @param ScopeConfigInterface $scopeConfig\n     * @param StoreManagerInterface $storeManager\n     */\n    public function __construct(\n        UrlInterface $urlBuilder,\n        ScopeConfigInterface $scopeConfig,\n        StoreManagerInterface $storeManager\n    ) {\n        $this->urlBuilder = $urlBuilder;\n        $this->scopeConfig = $scopeConfig;\n        $this->storeManager = $storeManager;\n    }\n\n    /**\n     * @return bool\n     */\n    public function isRssEnabled()\n    {\n        return\n            $this->scopeConfig->getValue(self::GLOBAL_RSS_ACTIVE_CONFIG_PATH, ScopeInterface::SCOPE_STORE) &&\n            $this->scopeConfig->getValue(self::AUTHOR_RSS_ACTIVE_CONFIG_PATH, ScopeInterface::SCOPE_STORE);\n    }\n\n    /**\n     * @return string\n     */\n    public function getRssLink()\n    {\n        return $this->urlBuilder->getUrl(\n            self::RSS_PAGE_URL,\n            ['store' => $this->storeManager->getStore()->getId()]\n        );\n    }\n}\n"
  },
  {
    "path": "Model/Author/Url.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\Author;\n\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Sample\\News\\Model\\Author;\n\nclass Url\n{\n    /**\n     * @var string\n     */\n    const LIST_URL_CONFIG_PATH      = 'sample_news/author/list_url';\n    /**\n     * @var string\n     */\n    const URL_PREFIX_CONFIG_PATH    = 'sample_news/author/url_prefix';\n    /**\n     * @var string\n     */\n    const URL_SUFFIX_CONFIG_PATH    = 'sample_news/author/url_suffix';\n    /**\n     * url builder\n     *\n     * @var \\Magento\\Framework\\UrlInterface\n     */\n    protected $urlBuilder;\n\n    /**\n     * @var ScopeConfigInterface\n     */\n    protected $scopeConfig;\n\n    /**\n     * @param UrlInterface $urlBuilder\n     * @param ScopeConfigInterface $scopeConfig\n     */\n    public function __construct(\n        UrlInterface $urlBuilder,\n        ScopeConfigInterface $scopeConfig\n    ) {\n        $this->urlBuilder = $urlBuilder;\n        $this->scopeConfig = $scopeConfig;\n    }\n\n    /**\n     * @return string\n     */\n    public function getListUrl()\n    {\n        $sefUrl = $this->scopeConfig->getValue(self::LIST_URL_CONFIG_PATH, ScopeInterface::SCOPE_STORE);\n        if ($sefUrl) {\n            return $this->urlBuilder->getUrl('', ['_direct' => $sefUrl]);\n        }\n        return $this->urlBuilder->getUrl('sample_news/author/index');\n    }\n\n    /**\n     * @param Author $author\n     * @return string\n     */\n    public function getAuthorUrl(Author $author)\n    {\n        if ($urlKey = $author->getUrlKey()) {\n            $prefix = $this->scopeConfig->getValue(\n                self::URL_PREFIX_CONFIG_PATH,\n                ScopeInterface::SCOPE_STORE\n            );\n            $suffix = $this->scopeConfig->getValue(\n                self::URL_SUFFIX_CONFIG_PATH,\n                ScopeInterface::SCOPE_STORE\n            );\n            $path = (($prefix) ? $prefix . '/' : '').\n                $urlKey .\n                (($suffix) ? '.'. $suffix : '');\n            return $this->urlBuilder->getUrl('', ['_direct'=>$path]);\n        }\n        return $this->urlBuilder->getUrl('sample_news/author/view', ['id' => $author->getId()]);\n    }\n}\n"
  },
  {
    "path": "Model/Author.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model;\n\nuse Magento\\Framework\\Data\\Collection\\AbstractDb;\nuse Magento\\Framework\\Data\\Collection\\Db;\nuse Magento\\Framework\\Exception\\LocalizedException;\nuse Magento\\Framework\\Filter\\FilterManager;\nuse Magento\\Framework\\Model\\AbstractModel;\nuse Magento\\Framework\\Model\\Context;\nuse Magento\\Framework\\Model\\ResourceModel\\AbstractResource;\nuse Magento\\Framework\\Registry;\nuse Sample\\News\\Api\\Data\\AuthorInterface;\nuse Sample\\News\\Model\\Author\\Url;\nuse Sample\\News\\Model\\ResourceModel\\Author as AuthorResourceModel;\nuse Sample\\News\\Model\\Routing\\RoutableInterface;\nuse Sample\\News\\Model\\Source\\AbstractSource;\n\n\n/**\n * @method AuthorResourceModel _getResource()\n * @method AuthorResourceModel getResource()\n */\nclass Author extends AbstractModel implements AuthorInterface, RoutableInterface\n{\n    /**\n     * @var int\n     */\n    const STATUS_ENABLED = 1;\n    /**\n     * @var int\n     */\n    const STATUS_DISABLED = 0;\n    /**\n     * @var Url\n     */\n    protected $urlModel;\n    /**\n     * cache tag\n     *\n     * @var string\n     */\n    const CACHE_TAG = 'sample_news_author';\n\n    /**\n     * cache tag\n     *\n     * @var string\n     */\n    protected $_cacheTag = 'sample_news_author';\n\n    /**\n     * Prefix of model events names\n     *\n     * @var string\n     */\n    protected $_eventPrefix = 'sample_news_author';\n\n    /**\n     * filter model\n     *\n     * @var \\Magento\\Framework\\Filter\\FilterManager\n     */\n    protected $filter;\n\n    /**\n     * @var UploaderPool\n     */\n    protected $uploaderPool;\n\n    /**\n     * @var \\Sample\\News\\Model\\Output\n     */\n    protected $outputProcessor;\n\n    /**\n     * @var AbstractSource[]\n     */\n    protected $optionProviders;\n\n    /**\n     * @param Context $context\n     * @param Registry $registry\n     * @param Output $outputProcessor\n     * @param UploaderPool $uploaderPool\n     * @param FilterManager $filter\n     * @param Url $urlModel\n     * @param array $optionProviders\n     * @param array $data\n     * @param AbstractResource|null $resource\n     * @param AbstractDb|null $resourceCollection\n     */\n    public function __construct(\n        Context $context,\n        Registry $registry,\n        Output $outputProcessor,\n        UploaderPool $uploaderPool,\n        FilterManager $filter,\n        Url $urlModel,\n        array $optionProviders = [],\n        array $data = [],\n        AbstractResource $resource = null,\n        AbstractDb $resourceCollection = null\n    )\n    {\n        $this->outputProcessor = $outputProcessor;\n        $this->uploaderPool    = $uploaderPool;\n        $this->filter          = $filter;\n        $this->urlModel        = $urlModel;\n        $this->optionProviders = $optionProviders;\n        parent::__construct($context, $registry, $resource, $resourceCollection, $data);\n    }\n\n    /**\n     * Initialize resource model\n     *\n     * @return void\n     */\n    protected function _construct()\n    {\n        $this->_init(AuthorResourceModel::class);\n    }\n\n    /**\n     * Get in rss\n     *\n     * @return bool|int\n     */\n    public function getInRss()\n    {\n        return $this->getData(AuthorInterface::IN_RSS);\n    }\n\n    /**\n     * Get type\n     *\n     * @return int\n     */\n    public function getType()\n    {\n        return $this->getData(AuthorInterface::TYPE);\n    }\n\n    /**\n     * Get awards\n     *\n     * @return string\n     */\n    public function getAwards()\n    {\n        return $this->getData(AuthorInterface::AWARDS);\n    }\n\n    /**\n     * Get country\n     *\n     * @return string\n     */\n    public function getCountry()\n    {\n        return $this->getData(AuthorInterface::COUNTRY);\n    }\n\n    /**\n     * set name\n     *\n     * @param $name\n     * @return AuthorInterface\n     */\n    public function setName($name)\n    {\n        return $this->setData(AuthorInterface::NAME, $name);\n    }\n\n    /**\n     * Set in rss\n     *\n     * @param $inRss\n     * @return AuthorInterface\n     */\n    public function setInRss($inRss)\n    {\n        return $this->setData(AuthorInterface::IN_RSS, $inRss);\n    }\n\n    /**\n     * Set biography\n     *\n     * @param $biography\n     * @return AuthorInterface\n     */\n    public function setBiography($biography)\n    {\n        return $this->setData(AuthorInterface::BIOGRAPHY, $biography);\n    }\n\n    /**\n     * Set DOB\n     *\n     * @param $dob\n     * @return AuthorInterface\n     */\n    public function setDob($dob)\n    {\n        return $this->setData(AuthorInterface::DOB, $dob);\n    }\n\n    /**\n     * set type\n     *\n     * @param $type\n     * @return AuthorInterface\n     */\n    public function setType($type)\n    {\n        return $this->setData(AuthorInterface::TYPE, $type);\n    }\n\n    /**\n     * set awards\n     *\n     * @param $awards\n     * @return AuthorInterface\n     */\n    public function setAwards($awards)\n    {\n        return $this->setData(AuthorInterface::AWARDS, $awards);\n    }\n\n    /**\n     * Set country\n     *\n     * @param $country\n     * @return AuthorInterface\n     */\n    public function setCountry($country)\n    {\n        return $this->setData(AuthorInterface::COUNTRY, $country);\n    }\n\n    /**\n     * Get name\n     *\n     * @return string\n     */\n    public function getName()\n    {\n        return $this->getData(AuthorInterface::NAME);\n    }\n\n    /**\n     * Get url key\n     *\n     * @return string\n     */\n    public function getUrlKey()\n    {\n        return $this->getData(AuthorInterface::URL_KEY);\n    }\n\n    /**\n     * Get is active\n     *\n     * @return bool|int\n     */\n    public function getIsActive()\n    {\n        return $this->getData(AuthorInterface::IS_ACTIVE);\n    }\n\n    /**\n     * Get biography\n     *\n     * @return string\n     */\n    public function getBiography()\n    {\n        return $this->getData(AuthorInterface::BIOGRAPHY);\n    }\n\n    /**\n     * @return mixed\n     */\n    public function getProcessedBiography()\n    {\n        return $this->outputProcessor->filterOutput($this->getBiography());\n    }\n\n    /**\n     * Get DOB\n     *\n     * @return string\n     */\n    public function getDob()\n    {\n        return $this->getData(AuthorInterface::DOB);\n    }\n\n    /**\n     * Get avatar\n     *\n     * @return string\n     */\n    public function getAvatar()\n    {\n        return $this->getData(AuthorInterface::AVATAR);\n    }\n\n    /**\n     * @return bool|string\n     * @throws LocalizedException\n     */\n    public function getAvatarUrl()\n    {\n        $url = false;\n        $avatar = $this->getAvatar();\n        if ($avatar) {\n            if (is_string($avatar)) {\n                $uploader = $this->uploaderPool->getUploader('image');\n                $url = $uploader->getBaseUrl().$uploader->getBasePath().$avatar;\n            } else {\n                throw new LocalizedException(\n                    __('Something went wrong while getting the avatar url.')\n                );\n            }\n        }\n        return $url;\n    }\n\n    /**\n     * @return bool|string\n     * @throws LocalizedException\n     */\n    public function getResumeUrl()\n    {\n        $url = false;\n        $resume = $this->getResume();\n        if ($resume) {\n            if (is_string($resume)) {\n                $uploader = $this->uploaderPool->getUploader('file');\n                $url = $uploader->getBaseUrl().$uploader->getBasePath().$resume;\n            } else {\n                throw new LocalizedException(\n                    __('Something went wrong while getting the resume url.')\n                );\n            }\n        }\n        return $url;\n    }\n\n    /**\n     * Get resume\n     *\n     * @return string\n     */\n    public function getResume()\n    {\n        return $this->getData(AuthorInterface::RESUME);\n    }\n\n    /**\n     * Get created at\n     *\n     * @return string\n     */\n    public function getCreatedAt()\n    {\n        return $this->getData(AuthorInterface::CREATED_AT);\n    }\n\n    /**\n     * Get updated at\n     *\n     * @return string\n     */\n    public function getUpdatedAt()\n    {\n        return $this->getData(AuthorInterface::UPDATED_AT);\n    }\n\n    /**\n     * set url key\n     *\n     * @param $urlKey\n     * @return AuthorInterface\n     */\n    public function setUrlKey($urlKey)\n    {\n        return $this->setData(AuthorInterface::URL_KEY, $urlKey);\n    }\n\n    /**\n     * Set is active\n     *\n     * @param $isActive\n     * @return AuthorInterface\n     */\n    public function setIsActive($isActive)\n    {\n        return $this->setData(AuthorInterface::IS_ACTIVE, $isActive);\n    }\n\n    /**\n     * set avatar\n     *\n     * @param $avatar\n     * @return AuthorInterface\n     */\n    public function setAvatar($avatar)\n    {\n        return $this->setData(AuthorInterface::AVATAR, $avatar);\n    }\n\n    /**\n     * set resume\n     *\n     * @param $resume\n     * @return AuthorInterface\n     */\n    public function setResume($resume)\n    {\n        return $this->setData(AuthorInterface::RESUME, $resume);\n    }\n\n    /**\n     * set created at\n     *\n     * @param $createdAt\n     * @return AuthorInterface\n     */\n    public function setCreatedAt($createdAt)\n    {\n        return $this->setData(AuthorInterface::CREATED_AT, $createdAt);\n    }\n\n    /**\n     * set updated at\n     *\n     * @param $updatedAt\n     * @return AuthorInterface\n     */\n    public function setUpdatedAt($updatedAt)\n    {\n        return $this->setData(AuthorInterface::UPDATED_AT, $updatedAt);\n    }\n\n\n    /**\n     * Check if author url key exists\n     * return author id if author exists\n     *\n     * @param string $urlKey\n     * @param int $storeId\n     * @return int\n     */\n    public function checkUrlKey($urlKey, $storeId)\n    {\n        return $this->_getResource()->checkUrlKey($urlKey, $storeId);\n    }\n\n    /**\n     * Get identities\n     *\n     * @return array\n     */\n    public function getIdentities()\n    {\n        return [self::CACHE_TAG . '_' . $this->getId()];\n    }\n\n    /**\n     * @param $storeId\n     * @return AuthorInterface\n     */\n    public function setStoreId($storeId)\n    {\n        $this->setData(AuthorInterface::STORE_ID, $storeId);\n        return $this;\n    }\n\n    /**\n     * @return array\n     */\n    public function getStoreId()\n    {\n        return $this->getData(AuthorInterface::STORE_ID);\n    }\n\n    /**\n     * @return string\n     */\n    public function getMetaTitle()\n    {\n        return $this->getData(AuthorInterface::META_TITLE);\n    }\n\n    /**\n     * @param $metaTitle\n     * @return AuthorInterface\n     */\n    public function setMetaTitle($metaTitle)\n    {\n        $this->setData(AuthorInterface::META_TITLE, $metaTitle);\n        return $this;\n    }\n\n    /**\n     * @return string\n     */\n    public function getMetaDescription()\n    {\n        return $this->getData(AuthorInterface::META_DESCRIPTION);\n    }\n\n    /**\n     * @param $metaDescription\n     * @return AuthorInterface\n     */\n    public function setMetaDescription($metaDescription)\n    {\n        $this->setData(AuthorInterface::META_DESCRIPTION, $metaDescription);\n        return $this;\n    }\n\n    /**\n     * @return string\n     */\n    public function getMetaKeywords()\n    {\n        return $this->getData(AuthorInterface::META_KEYWORDS);\n    }\n\n    /**\n     * @param $metaKeywords\n     * @return AuthorInterface\n     */\n    public function setMetaKeywords($metaKeywords)\n    {\n        $this->setData(AuthorInterface::META_KEYWORDS, $metaKeywords);\n        return $this;\n    }\n\n\n    /**\n     * sanitize the url key\n     *\n     * @param $string\n     * @return string\n     */\n    public function formatUrlKey($string)\n    {\n        return $this->filter->translitUrl($string);\n    }\n\n    /**\n     * @return mixed\n     */\n    public function getAuthorUrl()\n    {\n        return $this->urlModel->getAuthorUrl($this);\n    }\n\n    /**\n     * @return bool\n     */\n    public function isActive()\n    {\n        return (bool)$this->getIsActive();\n    }\n\n    /**\n     * @param $attribute\n     * @return string\n     */\n    public function getAttributeText($attribute)\n    {\n        if (!isset($this->optionProviders[$attribute])) {\n            return '';\n        }\n        if (!($this->optionProviders[$attribute] instanceof AbstractSource)) {\n            return '';\n        }\n        return $this->optionProviders[$attribute]->getOptionText($this->getData($attribute));\n    }\n}\n"
  },
  {
    "path": "Model/AuthorFactory.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model;\n\nuse Magento\\Framework\\ObjectManagerInterface;\nuse Sample\\News\\Model\\Routing\\RoutableInterface;\n\nclass AuthorFactory implements FactoryInterface\n{\n    /**\n     * Object Manager instance\n     *\n     * @var ObjectManagerInterface\n     */\n    protected $_objectManager = null;\n\n    /**\n     * Instance name to create\n     *\n     * @var string\n     */\n    protected $_instanceName = null;\n\n    /**\n     * Factory constructor\n     *\n     * @param ObjectManagerInterface $objectManager\n     * @param string $instanceName\n     */\n    public function __construct(ObjectManagerInterface $objectManager, $instanceName = Author::class)\n    {\n        $this->_objectManager = $objectManager;\n        $this->_instanceName  = $instanceName;\n    }\n\n    /**\n     * Create class instance with specified parameters\n     *\n     * @param array $data\n     * @return RoutableInterface|\\Sample\\News\\Model\\Author\n     */\n    public function create(array $data = array())\n    {\n        return $this->_objectManager->create($this->_instanceName, $data);\n    }\n}\n"
  },
  {
    "path": "Model/AuthorRepository.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model;\n\nuse Magento\\Framework\\Api\\DataObjectHelper;\nuse Magento\\Framework\\Api\\SearchCriteriaInterface;\nuse Magento\\Framework\\Api\\Search\\FilterGroup;\nuse Magento\\Framework\\Api\\SortOrder;\nuse Magento\\Framework\\Exception\\CouldNotSaveException;\nuse Magento\\Framework\\Exception\\StateException;\nuse Magento\\Framework\\Exception\\ValidatorException;\nuse Magento\\Framework\\Exception\\NoSuchEntityException;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\nuse Sample\\News\\Api\\Data;\nuse Sample\\News\\Api\\Data\\AuthorInterface;\nuse Sample\\News\\Api\\Data\\AuthorInterfaceFactory;\nuse Sample\\News\\Api\\Data\\AuthorSearchResultsInterfaceFactory;\nuse Sample\\News\\Model\\ResourceModel\\Author as ResourceAuthor;\nuse Sample\\News\\Model\\ResourceModel\\Author\\Collection;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory as AuthorCollectionFactory;\n\n/**\n * Class AuthorRepository\n * @SuppressWarnings(PHPMD.CouplingBetweenObjects)\n */\nclass AuthorRepository implements AuthorRepositoryInterface\n{\n    /**\n     * @var array\n     */\n    protected $instances = [];\n    /**\n     * @var ResourceAuthor\n     */\n    protected $resource;\n    /**\n     * @var StoreManagerInterface\n     */\n    protected $storeManager;\n    /**\n     * @var AuthorCollectionFactory\n     */\n    protected $authorCollectionFactory;\n    /**\n     * @var AuthorSearchResultsInterfaceFactory\n     */\n    protected $searchResultsFactory;\n    /**\n     * @var AuthorInterfaceFactory\n     */\n    protected $authorInterfaceFactory;\n    /**\n     * @var DataObjectHelper\n     */\n    protected $dataObjectHelper;\n\n    public function __construct(\n        ResourceAuthor $resource,\n        StoreManagerInterface $storeManager,\n        AuthorCollectionFactory $authorCollectionFactory,\n        AuthorSearchResultsInterfaceFactory $authorSearchResultsInterfaceFactory,\n        AuthorInterfaceFactory $authorInterfaceFactory,\n        DataObjectHelper $dataObjectHelper\n    ) {\n        $this->resource                 = $resource;\n        $this->storeManager             = $storeManager;\n        $this->authorCollectionFactory  = $authorCollectionFactory;\n        $this->searchResultsFactory     = $authorSearchResultsInterfaceFactory;\n        $this->authorInterfaceFactory   = $authorInterfaceFactory;\n        $this->dataObjectHelper         = $dataObjectHelper;\n    }\n    /**\n     * Save page.\n     *\n     * @param \\Sample\\News\\Api\\Data\\AuthorInterface $author\n     * @return \\Sample\\News\\Api\\Data\\AuthorInterface\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function save(AuthorInterface $author)\n    {\n        /** @var AuthorInterface|\\Magento\\Framework\\Model\\AbstractModel $author */\n        if (empty($author->getStoreId())) {\n            $storeId = $this->storeManager->getStore()->getId();\n            $author->setStoreId($storeId);\n        }\n        try {\n            $this->resource->save($author);\n        } catch (\\Exception $exception) {\n            throw new CouldNotSaveException(__(\n                'Could not save the author: %1',\n                $exception->getMessage()\n            ));\n        }\n        return $author;\n    }\n\n    /**\n     * Retrieve Author.\n     *\n     * @param int $authorId\n     * @return \\Sample\\News\\Api\\Data\\AuthorInterface\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function getById($authorId)\n    {\n        if (!isset($this->instances[$authorId])) {\n            /** @var \\Sample\\News\\Api\\Data\\AuthorInterface|\\Magento\\Framework\\Model\\AbstractModel $author */\n            $author = $this->authorInterfaceFactory->create();\n            $this->resource->load($author, $authorId);\n            if (!$author->getId()) {\n                throw new NoSuchEntityException(__('Requested author doesn\\'t exist'));\n            }\n            $this->instances[$authorId] = $author;\n        }\n        return $this->instances[$authorId];\n    }\n\n    /**\n     * Retrieve pages matching the specified criteria.\n     *\n     * @param SearchCriteriaInterface $searchCriteria\n     * @return \\Sample\\News\\Api\\Data\\AuthorSearchResultsInterface\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function getList(SearchCriteriaInterface $searchCriteria)\n    {\n        /** @var \\Sample\\News\\Api\\Data\\AuthorSearchResultsInterface $searchResults */\n        $searchResults = $this->searchResultsFactory->create();\n        $searchResults->setSearchCriteria($searchCriteria);\n\n        /** @var \\Sample\\News\\Model\\ResourceModel\\Author\\Collection $collection */\n        $collection = $this->authorCollectionFactory->create();\n\n        //Add filters from root filter group to the collection\n        /** @var FilterGroup $group */\n        foreach ($searchCriteria->getFilterGroups() as $group) {\n            $this->addFilterGroupToCollection($group, $collection);\n        }\n        $sortOrders = $searchCriteria->getSortOrders();\n        /** @var SortOrder $sortOrder */\n        if ($sortOrders) {\n            foreach ($searchCriteria->getSortOrders() as $sortOrder) {\n                $field = $sortOrder->getField();\n                $collection->addOrder(\n                    $field,\n                    ($sortOrder->getDirection() == SortOrder::SORT_ASC) ? 'ASC' : 'DESC'\n                );\n            }\n        } else {\n            // set a default sorting order since this method is used constantly in many\n            // different blocks\n            $field = 'author_id';\n            $collection->addOrder($field, 'ASC');\n        }\n        $collection->setCurPage($searchCriteria->getCurrentPage());\n        $collection->setPageSize($searchCriteria->getPageSize());\n\n        /** @var \\Sample\\News\\Api\\Data\\AuthorInterface[] $authors */\n        $authors = [];\n        /** @var \\Sample\\News\\Model\\Author $author */\n        foreach ($collection as $author) {\n            /** @var \\Sample\\News\\Api\\Data\\AuthorInterface $authorDataObject */\n            $authorDataObject = $this->authorInterfaceFactory->create();\n            $this->dataObjectHelper->populateWithArray($authorDataObject, $author->getData(), AuthorInterface::class);\n            $authors[] = $authorDataObject;\n        }\n        $searchResults->setTotalCount($collection->getSize());\n        return $searchResults->setItems($authors);\n    }\n\n    /**\n     * Delete author.\n     *\n     * @param \\Sample\\News\\Api\\Data\\AuthorInterface $author\n     * @return bool true on success\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function delete(AuthorInterface $author)\n    {\n        /** @var \\Sample\\News\\Api\\Data\\AuthorInterface|\\Magento\\Framework\\Model\\AbstractModel $author */\n        $id = $author->getId();\n        try {\n            unset($this->instances[$id]);\n            $this->resource->delete($author);\n        } catch (ValidatorException $e) {\n            throw new CouldNotSaveException(__($e->getMessage()));\n        } catch (\\Exception $e) {\n            throw new StateException(\n                __('Unable to remove author %1', $id)\n            );\n        }\n        unset($this->instances[$id]);\n        return true;\n    }\n\n    /**\n     * Delete author by ID.\n     *\n     * @param int $authorId\n     * @return bool true on success\n     * @throws \\Magento\\Framework\\Exception\\NoSuchEntityException\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function deleteById($authorId)\n    {\n        $author = $this->getById($authorId);\n        return $this->delete($author);\n    }\n\n    /**\n     * Helper function that adds a FilterGroup to the collection.\n     *\n     * @param FilterGroup $filterGroup\n     * @param Collection $collection\n     * @return $this\n     * @throws \\Magento\\Framework\\Exception\\InputException\n     */\n    protected function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)\n    {\n        $fields = [];\n        $conditions = [];\n        foreach ($filterGroup->getFilters() as $filter) {\n            $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';\n            $fields[] = $filter->getField();\n            $conditions[] = [$condition => $filter->getValue()];\n        }\n        if ($fields) {\n            $collection->addFieldToFilter($fields, $conditions);\n        }\n        return $this;\n    }\n\n}\n"
  },
  {
    "path": "Model/FactoryInterface.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model;\n\nuse Sample\\News\\Model\\Routing\\RoutableInterface;\n\ninterface FactoryInterface\n{\n    /**\n     * @return RoutableInterface\n     */\n    public function create();\n}\n"
  },
  {
    "path": "Model/Image.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n\nnamespace Sample\\News\\Model;\n\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Framework\\App\\Filesystem\\DirectoryList;\nuse Magento\\Framework\\Data\\Collection\\AbstractDb;\nuse Magento\\Framework\\Filesystem;\nuse Magento\\Framework\\Image as MagentoImage;\nuse Magento\\Framework\\Image\\Factory as MagentoImageFactory;\nuse Magento\\Framework\\Model\\AbstractModel;\nuse Magento\\Framework\\Model\\Context;\nuse Magento\\Framework\\Model\\ResourceModel\\AbstractResource;\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Framework\\View\\Asset\\Repository;\nuse Magento\\Framework\\View\\FileSystem as ViewFileSystem;\nuse Magento\\MediaStorage\\Helper\\File\\Storage\\Database;\nuse Magento\\Store\\Model\\Store;\nuse Magento\\Store\\Model\\StoreManagerInterface;\n\n/**\n * @SuppressWarnings(PHPMD.TooManyFields)\n * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)\n * @SuppressWarnings(PHPMD.CouplingBetweenObjects)\n * @method string getFile()\n * @method string getLabel()\n * @method string getPosition()\n */\nclass Image extends AbstractModel\n{\n    /**\n     * @var int\n     */\n    protected $width;\n\n    /**\n     * @var int\n     */\n    protected $height;\n\n    /**\n     * Default quality value (for JPEG images only).\n     *\n     * @var int\n     */\n    protected $quality = 80;\n\n    /**\n     * @var bool\n     */\n    protected $keepAspectRatio = true;\n\n    /**\n     * @var bool\n     */\n    protected $keepFrame = true;\n\n    /**\n     * @var bool\n     */\n    protected $keepTransparency = true;\n\n    /**\n     * @var bool\n     */\n    protected $constrainOnly = true;\n\n    /**\n     * @var int[]\n     */\n    protected $backgroundColor = [255, 255, 255];\n\n    /**\n     * @var string\n     */\n    protected $baseFile;\n\n    /**\n     * @var bool\n     */\n    protected $isBaseFilePlaceholder;\n\n    /**\n     * @var string|bool\n     */\n    protected $newFile;\n\n    /**\n     * @var MagentoImage\n     */\n    protected $processor;\n\n    /**\n     * @var string\n     */\n    protected $destinationSubdir;\n\n    /**\n     * @var int\n     */\n    protected $angle;\n\n    /**\n     * @var string\n     */\n    protected $watermarkFile;\n\n    /**\n     * @var int\n     */\n    protected $watermarkPosition;\n\n    /**\n     * @var int\n     */\n    protected $watermarkWidth;\n\n    /**\n     * @var int\n     */\n    protected $watermarkHeight;\n\n    /**\n     * @var int\n     */\n    protected $watermarkImageOpacity = 70;\n\n    /**\n     * @var \\Magento\\Framework\\Filesystem\\Directory\\WriteInterface\n     */\n    protected $mediaDirectory;\n\n    /**\n     * @var \\Magento\\Framework\\Image\\Factory\n     */\n    protected $imageFactory;\n\n    /**\n     * @var \\Magento\\Framework\\View\\Asset\\Repository\n     */\n    protected $assetRepo;\n\n    /**\n     * @var \\Magento\\Framework\\View\\FileSystem\n     */\n    protected $viewFileSystem;\n\n    /**\n     * Core file storage database\n     *\n     * @var \\Magento\\MediaStorage\\Helper\\File\\Storage\\Database\n     */\n    protected $coreFileStorageDatabase = null;\n\n    /**\n     * Core store config\n     *\n     * @var \\Magento\\Framework\\App\\Config\\ScopeConfigInterface\n     */\n    protected $scopeConfig;\n\n    /**\n     * @var Uploader\n     */\n    protected $uploader;\n\n    /**\n     * Store manager\n     *\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * @var string\n     */\n    protected $entityCode;\n\n    /**\n     * @param Context $context\n     * @param Registry $registry\n     * @param StoreManagerInterface $storeManager\n     * @param Uploader $uploader\n     * @param Database $coreFileStorageDatabase\n     * @param Filesystem $filesystem\n     * @param ImageFactory $imageFactory\n     * @param Repository $assetRepo\n     * @param ViewFileSystem $viewFileSystem\n     * @param ScopeConfigInterface $scopeConfig\n     * @param $entityCode\n     * @param AbstractResource|null $resource\n     * @param AbstractDb|null $resourceCollection\n     * @param array $data\n     */\n    public function __construct(\n        Context $context,\n        Registry $registry,\n        StoreManagerInterface $storeManager,\n        Uploader $uploader,\n        Database $coreFileStorageDatabase,\n        Filesystem $filesystem,\n        MagentoImageFactory $imageFactory,\n        Repository $assetRepo,\n        ViewFileSystem $viewFileSystem,\n        ScopeConfigInterface $scopeConfig,\n        $entityCode,\n        AbstractResource $resource = null,\n        AbstractDb $resourceCollection = null,\n        array $data = []\n    ) {\n        $this->storeManager             = $storeManager;\n        $this->uploader                 = $uploader;\n        $this->coreFileStorageDatabase  = $coreFileStorageDatabase;\n        $this->imageFactory             = $imageFactory;\n        $this->assetRepo                = $assetRepo;\n        $this->viewFileSystem           = $viewFileSystem;\n        $this->scopeConfig              = $scopeConfig;\n        $this->entityCode               = $entityCode;\n\n        parent::__construct($context, $registry, $resource, $resourceCollection, $data);\n\n        $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);\n        $this->mediaDirectory->create($this->uploader->getBasePath());\n\n    }\n\n    /**\n     * @param int $width\n     * @return $this\n     */\n    public function setWidth($width)\n    {\n        $this->width = $width;\n        return $this;\n    }\n\n    /**\n     * @return int\n     */\n    public function getWidth()\n    {\n        return $this->width;\n    }\n\n    /**\n     * @param int $height\n     * @return $this\n     */\n    public function setHeight($height)\n    {\n        $this->height = $height;\n        return $this;\n    }\n\n    /**\n     * @return int\n     */\n    public function getHeight()\n    {\n        return $this->height;\n    }\n\n    /**\n     * Set image quality, values in percentage from 0 to 100\n     *\n     * @param int $quality\n     * @return $this\n     */\n    public function setQuality($quality)\n    {\n        $this->quality = $quality;\n        return $this;\n    }\n\n    /**\n     * Get image quality\n     *\n     * @return int\n     */\n    public function getQuality()\n    {\n        return $this->quality;\n    }\n\n    /**\n     * @param bool $keep\n     * @return $this\n     */\n    public function setKeepAspectRatio($keep)\n    {\n        $this->keepAspectRatio = (bool)$keep;\n        return $this;\n    }\n\n    /**\n     * @param bool $keep\n     * @return $this\n     */\n    public function setKeepFrame($keep)\n    {\n        $this->keepFrame = (bool)$keep;\n        return $this;\n    }\n\n    /**\n     * @param bool $keep\n     * @return $this\n     */\n    public function setKeepTransparency($keep)\n    {\n        $this->keepTransparency = (bool)$keep;\n        return $this;\n    }\n\n    /**\n     * @param bool $flag\n     * @return $this\n     */\n    public function setConstrainOnly($flag)\n    {\n        $this->constrainOnly = (bool)$flag;\n        return $this;\n    }\n\n    /**\n     * @param int[] $rgbArray\n     * @return $this\n     */\n    public function setBackgroundColor(array $rgbArray)\n    {\n        $this->backgroundColor = $rgbArray;\n        return $this;\n    }\n\n    /**\n     * @param string $size\n     * @return $this\n     */\n    public function setSize($size)\n    {\n        // determine width and height from string\n        list($width, $height) = explode('x', strtolower($size), 2);\n        foreach (['width', 'height'] as $wh) {\n            ${$wh} = (int)${$wh};\n            if (empty(${$wh})) {\n                ${$wh} = null;\n            }\n        }\n\n        // set sizes\n        $this->setWidth($width)->setHeight($height);\n\n        return $this;\n    }\n\n    /**\n     * @param string|null $file\n     * @return bool\n     */\n    protected function checkMemory($file = null)\n    {\n        return $this->getMemoryLimit() > $this->getMemoryUsage() + $this->getNeedMemoryForFile(\n            $file\n        )\n        || $this->getMemoryLimit() == -1;\n    }\n\n    /**\n     * @return string\n     */\n    protected function getMemoryLimit()\n    {\n        $memoryLimit = trim(strtoupper(ini_get('memory_limit')));\n\n        if (!isset($memoryLimit[0])) {\n            $memoryLimit = \"128M\";\n        }\n\n        if (substr($memoryLimit, -1) == 'K') {\n            return substr($memoryLimit, 0, -1) * 1024;\n        }\n        if (substr($memoryLimit, -1) == 'M') {\n            return substr($memoryLimit, 0, -1) * 1024 * 1024;\n        }\n        if (substr($memoryLimit, -1) == 'G') {\n            return substr($memoryLimit, 0, -1) * 1024 * 1024 * 1024;\n        }\n        return $memoryLimit;\n    }\n\n    /**\n     * @return int\n     */\n    protected function getMemoryUsage()\n    {\n        if (function_exists('memory_get_usage')) {\n            return memory_get_usage();\n        }\n        return 0;\n    }\n\n    /**\n     * @param string|null $file\n     * @return float|int\n     * @SuppressWarnings(PHPMD.NPathComplexity)\n     */\n    protected function getNeedMemoryForFile($file = null)\n    {\n        $file = $file === null ? $this->getBaseFile() : $file;\n        if (!$file) {\n            return 0;\n        }\n\n        if (!$this->mediaDirectory->isExist($file)) {\n            return 0;\n        }\n\n        $imageInfo = getimagesize($this->mediaDirectory->getAbsolutePath($file));\n\n        if (!isset($imageInfo[0]) || !isset($imageInfo[1])) {\n            return 0;\n        }\n        if (!isset($imageInfo['channels'])) {\n            // if there is no info about this parameter lets set it for maximum\n            $imageInfo['channels'] = 4;\n        }\n        if (!isset($imageInfo['bits'])) {\n            // if there is no info about this parameter lets set it for maximum\n            $imageInfo['bits'] = 8;\n        }\n        return round(\n            ($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2, 16)) * 1.65\n        );\n    }\n\n    /**\n     * Convert array of 3 items (decimal r, g, b) to string of their hex values\n     *\n     * @param int[] $rgbArray\n     * @return string\n     */\n    protected function rgbToString($rgbArray)\n    {\n        $result = [];\n        foreach ($rgbArray as $value) {\n            if (null === $value) {\n                $result[] = 'null';\n            } else {\n                $result[] = sprintf('%02s', dechex($value));\n            }\n        }\n        return implode($result);\n    }\n\n    /**\n     * Set filenames for base file and new file\n     *\n     * @param string $file\n     * @return $this\n     * @throws \\Exception\n     * @SuppressWarnings(PHPMD.CyclomaticComplexity)\n     * @SuppressWarnings(PHPMD.NPathComplexity)\n     */\n    public function setBaseFile($file)\n    {\n        $this->isBaseFilePlaceholder = false;\n\n        if ($file && 0 !== strpos($file, '/', 0)) {\n            $file = '/' . $file;\n        }\n        $baseDir = $this->uploader->getBasePath();\n\n        if ($file) {\n            if (!$this->fileExists($baseDir . $file) || !$this->checkMemory($baseDir . $file)) {\n                $file = null;\n            }\n        }\n        if (!$file) {\n            $this->isBaseFilePlaceholder = true;\n            $this->newFile = true;\n            return $this;\n        }\n\n        $baseFile = $baseDir . $file;\n\n        if (!$file || !$this->mediaDirectory->isFile($baseFile)) {\n            throw new \\Exception(__('We can\\'t find the image file.'));\n        }\n\n        $this->baseFile = $baseFile;\n\n        // build new filename (most important params)\n        $path = [\n            $this->uploader->getBasePath(),\n            'cache',\n            $this->storeManager->getStore()->getId(),\n            $path[] = $this->getDestinationSubdir(),\n        ];\n        if (!empty($this->width) || !empty($this->height)) {\n            $path[] = \"{$this->width}x{$this->height}\";\n        }\n\n        // add misk params as a hash\n        $miscParams = [\n            ($this->keepAspectRatio ? '' : 'non') . 'proportional',\n            ($this->keepFrame ? '' : 'no') . 'frame',\n            ($this->keepTransparency ? '' : 'no') . 'transparency',\n            ($this->constrainOnly ? 'do' : 'not') . 'constrainonly',\n            $this->rgbToString($this->backgroundColor),\n            'angle' . $this->angle,\n            'quality' . $this->quality,\n        ];\n\n        // if has watermark add watermark params to hash\n        if ($this->getWatermarkFile()) {\n            $miscParams[] = $this->getWatermarkFile();\n            $miscParams[] = $this->getWatermarkImageOpacity();\n            $miscParams[] = $this->getWatermarkPosition();\n            $miscParams[] = $this->getWatermarkWidth();\n            $miscParams[] = $this->getWatermarkHeight();\n        }\n\n        $path[] = md5(implode('_', $miscParams));\n\n        // append prepared filename\n        $this->newFile = implode('/', $path) . $file;\n        // the $file contains heading slash\n\n        return $this;\n    }\n\n    /**\n     * @return string\n     */\n    public function getBaseFile()\n    {\n        return $this->baseFile;\n    }\n\n    /**\n     * @return bool|string\n     */\n    public function getNewFile()\n    {\n        return $this->newFile;\n    }\n\n    /**\n     * Retrieve 'true' if image is a base file placeholder\n     *\n     * @return bool\n     */\n    public function isBaseFilePlaceholder()\n    {\n        return (bool)$this->isBaseFilePlaceholder;\n    }\n\n    /**\n     * @param MagentoImage $processor\n     * @return $this\n     */\n    public function setImageProcessor($processor)\n    {\n        $this->processor = $processor;\n        return $this;\n    }\n\n    /**\n     * @return MagentoImage\n     */\n    public function getImageProcessor()\n    {\n        if (!$this->processor) {\n            $filename = $this->getBaseFile() ? $this->mediaDirectory->getAbsolutePath($this->getBaseFile()) : null;\n            $this->processor = $this->imageFactory->create($filename);\n        }\n        $this->processor->keepAspectRatio($this->keepAspectRatio);\n        $this->processor->keepFrame($this->keepFrame);\n        $this->processor->keepTransparency($this->keepTransparency);\n        $this->processor->constrainOnly($this->constrainOnly);\n        $this->processor->backgroundColor($this->backgroundColor);\n        $this->processor->quality($this->quality);\n        return $this->processor;\n    }\n\n    /**\n     * @see \\Magento\\Framework\\Image\\Adapter\\AbstractAdapter\n     * @return $this\n     */\n    public function resize()\n    {\n        if ($this->getWidth() === null && $this->getHeight() === null) {\n            return $this;\n        }\n        $this->getImageProcessor()->resize($this->width, $this->height);\n        return $this;\n    }\n\n    /**\n     * @param int $angle\n     * @return $this\n     */\n    public function rotate($angle)\n    {\n        $angle = intval($angle);\n        $this->getImageProcessor()->rotate($angle);\n        return $this;\n    }\n\n    /**\n     * Set angle for rotating\n     *\n     * This func actually affects only the cache filename.\n     *\n     * @param int $angle\n     * @return $this\n     */\n    public function setAngle($angle)\n    {\n        $this->angle = $angle;\n        return $this;\n    }\n\n    /**\n     * Add watermark to image\n     * size param in format 100x200\n     *\n     * @param string $file\n     * @param string $position\n     * @param array $size ['width' => int, 'height' => int]\n     * @param int $width\n     * @param int $height\n     * @param int $opacity\n     * @return $this\n     * @SuppressWarnings(PHPMD.NPathComplexity)\n     */\n    public function setWatermark(\n        $file,\n        $position = null,\n        $size = null,\n        $width = null,\n        $height = null,\n        $opacity = null\n    ) {\n        if ($this->isBaseFilePlaceholder) {\n            return $this;\n        }\n\n        if ($file) {\n            $this->setWatermarkFile($file);\n        } else {\n            return $this;\n        }\n\n        if ($position) {\n            $this->setWatermarkPosition($position);\n        }\n        if ($size) {\n            $this->setWatermarkSize($size);\n        }\n        if ($width) {\n            $this->setWatermarkWidth($width);\n        }\n        if ($height) {\n            $this->setWatermarkHeight($height);\n        }\n        if ($opacity) {\n            $this->setWatermarkImageOpacity($opacity);\n        }\n        $filePath = $this->getWatermarkFilePath();\n\n        if ($filePath) {\n            $imagePreprocessor = $this->getImageProcessor();\n            $imagePreprocessor->setWatermarkPosition($this->getWatermarkPosition());\n            $imagePreprocessor->setWatermarkImageOpacity($this->getWatermarkImageOpacity());\n            $imagePreprocessor->setWatermarkWidth($this->getWatermarkWidth());\n            $imagePreprocessor->setWatermarkHeight($this->getWatermarkHeight());\n            $imagePreprocessor->watermark($filePath);\n        }\n\n        return $this;\n    }\n\n    /**\n     * @return $this\n     */\n    public function saveFile()\n    {\n        if ($this->isBaseFilePlaceholder && $this->newFile === true) {\n            return $this;\n        }\n        $filename = $this->mediaDirectory->getAbsolutePath($this->getNewFile());\n        $this->getImageProcessor()->save($filename);\n        $this->coreFileStorageDatabase->saveFile($filename);\n        return $this;\n    }\n\n    /**\n     * @return string\n     */\n    public function getUrl()\n    {\n        if ($this->newFile === true) {\n            $url = $this->assetRepo->getUrl(\n                \"Sample_News::images/\".$this->entityCode.\"/placeholder/{$this->getDestinationSubdir()}.jpg\"\n            );\n        } else {\n            $url = $this->storeManager->getStore()->getBaseUrl(\n                    UrlInterface::URL_TYPE_MEDIA\n                ) . $this->newFile;\n        }\n\n        return $url;\n    }\n\n    /**\n     * @param string $dir\n     * @return $this\n     */\n    public function setDestinationSubdir($dir)\n    {\n        $this->destinationSubdir = $dir;\n        return $this;\n    }\n\n    /**\n     * @return string\n     */\n    public function getDestinationSubdir()\n    {\n        return $this->destinationSubdir;\n    }\n\n    /**\n     * @return bool|void\n     */\n    public function isCached()\n    {\n        if (is_string($this->newFile)) {\n            return $this->fileExists($this->newFile);\n        }\n        return false;\n    }\n\n    /**\n     * Set watermark file name\n     *\n     * @param string $file\n     * @return $this\n     */\n    public function setWatermarkFile($file)\n    {\n        $this->watermarkFile = $file;\n        return $this;\n    }\n\n    /**\n     * Get watermark file name\n     *\n     * @return string\n     */\n    public function getWatermarkFile()\n    {\n        return $this->watermarkFile;\n    }\n\n    /**\n     * Get relative watermark file path\n     * or false if file not found\n     *\n     * @return string | bool\n     */\n    protected function getWatermarkFilePath()\n    {\n        $filePath = false;\n\n        if (!($file = $this->getWatermarkFile())) {\n            return $filePath;\n        }\n        $baseDir = $this->uploader->getBasePath();\n\n        $candidates = [\n            $baseDir . '/watermark/stores/' . $this->storeManager->getStore()->getId() . $file,\n            $baseDir . '/watermark/websites/' . $this->storeManager->getWebsite()->getId() . $file,\n            $baseDir . '/watermark/default/' . $file,\n            $baseDir . '/watermark/' . $file,\n        ];\n        foreach ($candidates as $candidate) {\n            if ($this->mediaDirectory->isExist($candidate)) {\n                $filePath = $this->mediaDirectory->getAbsolutePath($candidate);\n                break;\n            }\n        }\n        if (!$filePath) {\n            $filePath = $this->viewFileSystem->getStaticFileName($file);\n        }\n\n        return $filePath;\n    }\n\n    /**\n     * Set watermark position\n     *\n     * @param string $position\n     * @return $this\n     */\n    public function setWatermarkPosition($position)\n    {\n        $this->watermarkPosition = $position;\n        return $this;\n    }\n\n    /**\n     * Get watermark position\n     *\n     * @return string\n     */\n    public function getWatermarkPosition()\n    {\n        return $this->watermarkPosition;\n    }\n\n    /**\n     * Set watermark image opacity\n     *\n     * @param int $imageOpacity\n     * @return $this\n     */\n    public function setWatermarkImageOpacity($imageOpacity)\n    {\n        $this->watermarkImageOpacity = $imageOpacity;\n        return $this;\n    }\n\n    /**\n     * Get watermark image opacity\n     *\n     * @return int\n     */\n    public function getWatermarkImageOpacity()\n    {\n        return $this->watermarkImageOpacity;\n    }\n\n    /**\n     * Set watermark size\n     *\n     * @param array $size\n     * @return $this\n     */\n    public function setWatermarkSize($size)\n    {\n        if (is_array($size)) {\n            $this->setWatermarkWidth($size['width'])->setWatermarkHeight($size['height']);\n        }\n        return $this;\n    }\n\n    /**\n     * Set watermark width\n     *\n     * @param int $width\n     * @return $this\n     */\n    public function setWatermarkWidth($width)\n    {\n        $this->watermarkWidth = $width;\n        return $this;\n    }\n\n    /**\n     * Get watermark width\n     *\n     * @return int\n     */\n    public function getWatermarkWidth()\n    {\n        return $this->watermarkWidth;\n    }\n\n    /**\n     * Set watermark height\n     *\n     * @param int $height\n     * @return $this\n     */\n    public function setWatermarkHeight($height)\n    {\n        $this->watermarkHeight = $height;\n        return $this;\n    }\n\n    /**\n     * Get watermark height\n     *\n     * @return string\n     */\n    public function getWatermarkHeight()\n    {\n        return $this->watermarkHeight;\n    }\n\n    /**\n     * @return void\n     */\n    public function clearCache()\n    {\n        $directory = $this->uploader->getBasePath() . '/cache';\n        $this->mediaDirectory->delete($directory);\n\n        $this->coreFileStorageDatabase->deleteFolder($this->mediaDirectory->getAbsolutePath($directory));\n    }\n\n    /**\n     * First check this file on FS\n     * If it doesn't exist - try to download it from DB\n     *\n     * @param string $filename\n     * @return bool\n     */\n    protected function fileExists($filename)\n    {\n        if ($this->mediaDirectory->isFile($filename)) {\n            return true;\n        } else {\n            return $this->coreFileStorageDatabase->saveFileToFilesystem(\n                $this->mediaDirectory->getAbsolutePath($filename)\n            );\n        }\n    }\n\n    /**\n     * Return resized image information\n     *\n     * @return array\n     */\n    public function getResizedImageInfo()\n    {\n        $fileInfo = null;\n        if ($this->newFile === true) {\n            $asset = $this->assetRepo->createAsset(\n                \"Sample_News::images/\".$this->entityCode.\"/placeholder/{$this->getDestinationSubdir()}.jpg\"\n            );\n            $img = $asset->getSourceFile();\n            $fileInfo = getimagesize($img);\n        } else {\n            if ($this->mediaDirectory->isFile($this->mediaDirectory->getAbsolutePath($this->newFile))) {\n                $fileInfo = getimagesize($this->mediaDirectory->getAbsolutePath($this->newFile));\n            }\n        }\n        return $fileInfo;\n    }\n}\n"
  },
  {
    "path": "Model/Output.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model;\n\nclass Output\n{\n    /**\n     * @var \\Zend_Filter_Interface\n     */\n    protected $templateProcessor;\n\n    /**\n     * @param \\Zend_Filter_Interface $templateProcessor\n     */\n    public function __construct(\n        \\Zend_Filter_Interface $templateProcessor\n    ) {\n        $this->templateProcessor = $templateProcessor;\n    }\n\n    /**\n     * @param $string\n     * @return string\n     */\n    public function filterOutput($string)\n    {\n        return $this->templateProcessor->filter($string);\n    }\n}\n"
  },
  {
    "path": "Model/ResourceModel/Author/Collection.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\ResourceModel\\Author;\n\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\Collection\\AbstractCollection;\nuse Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface;\nuse Magento\\Framework\\Data\\Collection\\EntityFactoryInterface;\nuse Magento\\Framework\\Event\\ManagerInterface;\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb;\nuse Magento\\Store\\Model\\Store;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Psr\\Log\\LoggerInterface;\nuse Sample\\News\\Model\\Author;\nuse Sample\\News\\Model\\ResourceModel\\Author as AuthorResourceModel;\n\nclass Collection extends AbstractCollection\n{\n    /**\n     * @var string\n     */\n    protected $_idFieldName = 'author_id';\n    /**\n     * Event prefix\n     *\n     * @var string\n     */\n    protected $_eventPrefix = 'sample_news_author_collection';\n\n    /**\n     * Event object\n     *\n     * @var string\n     */\n    protected $_eventObject = 'author_collection';\n\n    /**\n     * Store manager\n     *\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * @var array\n     */\n    protected $_joinedFields = [];\n\n    /**\n     * constructor\n     *\n     * @param EntityFactoryInterface $entityFactory\n     * @param LoggerInterface $logger\n     * @param FetchStrategyInterface $fetchStrategy\n     * @param ManagerInterface $eventManager\n     * @param StoreManagerInterface $storeManager\n     * @param null $connection\n     * @param AbstractDb $resource\n     */\n    public function __construct(\n        EntityFactoryInterface $entityFactory,\n        LoggerInterface $logger,\n        FetchStrategyInterface $fetchStrategy,\n        ManagerInterface $eventManager,\n        StoreManagerInterface $storeManager,\n        $connection = null,\n        AbstractDb $resource = null\n    ) {\n        $this->storeManager = $storeManager;\n        parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);\n    }\n\n    /**\n     * Define resource model\n     *\n     * @return void\n     */\n    protected function _construct()\n    {\n        $this->_init(Author::class, AuthorResourceModel::class);\n        $this->_map['fields']['author_id'] = 'main_table.author_id';\n        $this->_map['fields']['store_id'] = 'store_table.store_id';\n    }\n\n    /**\n     * after collection load\n     *\n     * @return $this\n     */\n    protected function _afterLoad()\n    {\n        $this->performAfterLoad('sample_news_author_store', 'author_id');\n        foreach ($this->getItems() as $item) {\n            /** @var \\Sample\\News\\Model\\Author $item */\n            $awards = $item->getAwards();\n            if ($awards && !is_array($awards)) {\n                $item->setAwards(explode(',', $awards));\n            }\n        }\n        return parent::_afterLoad();\n    }\n\n    public function addFieldToFilter($field, $condition = null)\n    {\n        if ($field === 'store_id') {\n            return $this->addStoreFilter($condition, false);\n        }\n\n        return parent::addFieldToFilter($field, $condition);\n    }\n\n    /**\n     * Add filter by store\n     *\n     * @param int|\\Magento\\Store\\Model\\Store $store\n     * @param bool $withAdmin\n     * @return $this\n     */\n    public function addStoreFilter($store, $withAdmin = true)\n    {\n        if (!$this->getFlag('store_filter_added')) {\n            if ($store instanceof Store) {\n                $store = [$store->getId()];\n            }\n\n            if (!is_array($store)) {\n                $store = [$store];\n            }\n\n            if ($withAdmin) {\n                $store[] = Store::DEFAULT_STORE_ID;\n            }\n\n            $this->addFilter('store_id', ['in' => $store], 'public');\n        }\n        return $this;\n    }\n\n    /**\n     * Join store relation table if there is store filter\n     *\n     * @return void\n     * @SuppressWarnings(PHPMD.Ecg.Sql.SlowQuery)\n     */\n    protected function _renderFiltersBefore()\n    {\n        if ($this->getFilter('store_id')) {\n            $this->getSelect()->join(\n                ['store_table' => $this->getTable('sample_news_author_store')],\n                'main_table.author_id = store_table.author_id',\n                []\n            )\n            // @codingStandardsIgnoreStart\n            ->group('main_table.author_id');\n            // @codingStandardsIgnoreEnd\n        }\n        parent::_renderFiltersBefore();\n    }\n\n    /**\n     * Get SQL for get record count.\n     * Extra GROUP BY strip added.\n     *\n     * @return \\Magento\\Framework\\DB\\Select\n     */\n    public function getSelectCountSql()\n    {\n        $countSelect = parent::getSelectCountSql();\n        $countSelect->reset(\\Zend_Db_Select::GROUP);\n        return $countSelect;\n    }\n\n    /**\n     * @param $tableName\n     * @param $linkField\n     */\n    protected function performAfterLoad($tableName, $linkField)\n    {\n        $linkedIds = $this->getColumnValues($linkField);\n        if (count($linkedIds)) {\n            $connection = $this->getConnection();\n            $select = $connection->select()->from(['sample_news_author_store' => $this->getTable($tableName)])\n                ->where('sample_news_author_store.' . $linkField . ' IN (?)', $linkedIds);\n            // @codingStandardsIgnoreStart\n            $result = $connection->fetchAll($select);\n            // @codingStandardsIgnoreEnd\n            if ($result) {\n                $storesData = [];\n                foreach ($result as $storeData) {\n                    $storesData[$storeData[$linkField]][] = $storeData['store_id'];\n                }\n\n                foreach ($this as $item) {\n                    $linkedId = $item->getData($linkField);\n                    if (!isset($storesData[$linkedId])) {\n                        continue;\n                    }\n                    $storeIdKey = array_search(Store::DEFAULT_STORE_ID, $storesData[$linkedId], true);\n                    if ($storeIdKey !== false) {\n                        $stores = $this->storeManager->getStores(false, true);\n                        $storeId = current($stores)->getId();\n                        $storeCode = key($stores);\n                    } else {\n                        $storeId = current($storesData[$linkedId]);\n                        $storeCode = $this->storeManager->getStore($storeId)->getCode();\n                    }\n                    $item->setData('store_id', $storesData[$linkedId]);\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Model/ResourceModel/Author/Grid/Collection.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\ResourceModel\\Author\\Grid;\n\n\nuse Magento\\Framework\\Api\\Search\\SearchResultInterface;\nuse Magento\\Framework\\Api\\Search\\AggregationInterface;\nuse Magento\\Framework\\Api\\SearchCriteriaInterface;\nuse Magento\\Framework\\Data\\Collection\\EntityFactoryInterface;\nuse Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface;\nuse Magento\\Framework\\Event\\ManagerInterface;\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb;\nuse Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\Document;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Psr\\Log\\LoggerInterface;\nuse Sample\\News\\Model\\ResourceModel\\Author\\Collection as AuthorCollection;\n\n\nclass Collection extends AuthorCollection implements SearchResultInterface\n{\n    /**\n     * @var AggregationInterface\n     */\n    protected $aggregations;\n\n    /**\n     * @param EntityFactoryInterface $entityFactory\n     * @param LoggerInterface $logger\n     * @param FetchStrategyInterface $fetchStrategy\n     * @param ManagerInterface $eventManager\n     * @param StoreManagerInterface $storeManager\n     * @param null $mainTable\n     * @param AbstractDb $eventPrefix\n     * @param $eventObject\n     * @param $resourceModel\n     * @param string $model\n     * @param null $connection\n     * @param AbstractDb|null $resource\n     * @SuppressWarnings(PHPMD.ExcessiveParameterList)\n     */\n    public function __construct(\n        EntityFactoryInterface $entityFactory,\n        LoggerInterface $logger,\n        FetchStrategyInterface $fetchStrategy,\n        ManagerInterface $eventManager,\n        StoreManagerInterface $storeManager,\n        $mainTable,\n        $eventPrefix,\n        $eventObject,\n        $resourceModel,\n        $model = Document::class,\n        $connection = null,\n        AbstractDb $resource = null\n    ) {\n        parent::__construct(\n            $entityFactory,\n            $logger,\n            $fetchStrategy,\n            $eventManager,\n            $storeManager,\n            $connection,\n            $resource\n        );\n        $this->_eventPrefix = $eventPrefix;\n        $this->_eventObject = $eventObject;\n        $this->_init($model, $resourceModel);\n        $this->setMainTable($mainTable);\n    }\n\n    /**\n     * @return AggregationInterface\n     */\n    public function getAggregations()\n    {\n        return $this->aggregations;\n    }\n\n    /**\n     * @param AggregationInterface $aggregations\n     * @return $this\n     */\n    public function setAggregations($aggregations)\n    {\n        $this->aggregations = $aggregations;\n    }\n\n    /**\n     * Get search criteria.\n     *\n     * @return \\Magento\\Framework\\Api\\SearchCriteriaInterface|null\n     */\n    public function getSearchCriteria()\n    {\n        return null;\n    }\n\n    /**\n     * Set search criteria.\n     *\n     * @param \\Magento\\Framework\\Api\\SearchCriteriaInterface $searchCriteria\n     * @return $this\n     * @SuppressWarnings(PHPMD.UnusedFormalParameter)\n     */\n    public function setSearchCriteria(SearchCriteriaInterface $searchCriteria = null)\n    {\n        return $this;\n    }\n\n    /**\n     * Get total count.\n     *\n     * @return int\n     */\n    public function getTotalCount()\n    {\n        return $this->getSize();\n    }\n\n    /**\n     * Set total count.\n     *\n     * @param int $totalCount\n     * @return $this\n     * @SuppressWarnings(PHPMD.UnusedFormalParameter)\n     */\n    public function setTotalCount($totalCount)\n    {\n        return $this;\n    }\n\n    /**\n     * Set items list.\n     *\n     * @param \\Magento\\Framework\\Api\\ExtensibleDataInterface[] $items\n     * @return $this\n     * @SuppressWarnings(PHPMD.UnusedFormalParameter)\n     */\n    public function setItems(array $items = null)\n    {\n        return $this;\n    }\n}\n"
  },
  {
    "path": "Model/ResourceModel/Author/Grid/ServiceCollection.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n// @codingStandardsIgnoreFile\nnamespace Sample\\News\\Model\\ResourceModel\\Author\\Grid;\n\nuse Magento\\Framework\\Api\\AbstractServiceCollection;\nuse Magento\\Framework\\Api\\FilterBuilder;\nuse Magento\\Framework\\Api\\SearchCriteriaBuilder;\nuse Magento\\Framework\\Api\\SimpleDataObjectConverter;\nuse Magento\\Framework\\Api\\SortOrderBuilder;\nuse Magento\\Framework\\Data\\Collection\\EntityFactory;\nuse Magento\\Framework\\DataObject;\nuse Sample\\News\\Api\\AuthorRepositoryInterface;\nuse Sample\\News\\Api\\Data\\AuthorInterface;\n\n/**\n * Author collection backed by services\n */\nclass ServiceCollection extends AbstractServiceCollection\n{\n    /**\n     * @var AuthorRepositoryInterface\n     */\n    protected $authorRepository;\n\n    /**\n     * @var SimpleDataObjectConverter\n     */\n    protected $simpleDataObjectConverter;\n\n    /**\n     * @param EntityFactory $entityFactory\n     * @param FilterBuilder $filterBuilder\n     * @param SearchCriteriaBuilder $searchCriteriaBuilder\n     * @param SortOrderBuilder $sortOrderBuilder\n     * @param AuthorRepositoryInterface $authorRepository\n     * @param SimpleDataObjectConverter $simpleDataObjectConverter\n     */\n    public function __construct(\n        EntityFactory $entityFactory,\n        FilterBuilder $filterBuilder,\n        SearchCriteriaBuilder $searchCriteriaBuilder,\n        SortOrderBuilder $sortOrderBuilder,\n        AuthorRepositoryInterface $authorRepository,\n        SimpleDataObjectConverter $simpleDataObjectConverter\n    ) {\n        $this->authorRepository          = $authorRepository;\n        $this->simpleDataObjectConverter = $simpleDataObjectConverter;\n        parent::__construct($entityFactory, $filterBuilder, $searchCriteriaBuilder, $sortOrderBuilder);\n    }\n\n    /**\n     * Load customer group collection data from service\n     *\n     * @param bool $printQuery\n     * @param bool $logQuery\n     * @return $this\n     * @SuppressWarnings(PHPMD.UnusedFormalParameter)\n     */\n    public function loadData($printQuery = false, $logQuery = false)\n    {\n        if (!$this->isLoaded()) {\n            $searchCriteria = $this->getSearchCriteria();\n            $searchResults = $this->authorRepository->getList($searchCriteria);\n            $this->_totalRecords = $searchResults->getTotalCount();\n            /** @var AuthorInterface[] $authors */\n            $authors = $searchResults->getItems();\n            foreach ($authors as $author) {\n                $authorItem = new DataObject();\n                $authorItem->addData(\n                    $this->simpleDataObjectConverter->toFlatArray($author, AuthorInterface::class)\n                );\n                $this->_addItem($authorItem);\n            }\n            $this->_setIsLoaded();\n        }\n        return $this;\n    }\n}\n"
  },
  {
    "path": "Model/ResourceModel/Author.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\ResourceModel;\n\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb;\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\Context;\nuse Magento\\Framework\\Stdlib\\DateTime\\DateTime;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Magento\\Framework\\Stdlib\\DateTime as LibDateTime;\nuse Magento\\Framework\\Model\\AbstractModel;\nuse Magento\\Store\\Model\\Store;\nuse Sample\\News\\Model\\Author as AuthorModel;\nuse Magento\\Framework\\Event\\ManagerInterface;\n\nclass Author extends AbstractDb\n{\n    /**\n     * Store model\n     *\n     * @var \\Magento\\Store\\Model\\Store\n     */\n    protected $store = null;\n\n    /**\n     * @var \\Magento\\Framework\\Stdlib\\DateTime\\DateTime\n     */\n    protected $date;\n\n    /**\n     * Store manager\n     *\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * @var \\Magento\\Framework\\Stdlib\\DateTime\n     */\n    protected $dateTime;\n\n    /**\n     * @var \\Magento\\Framework\\Event\\ManagerInterface\n     */\n    protected $eventManager;\n\n    /**\n     * @param Context $context\n     * @param DateTime $date\n     * @param StoreManagerInterface $storeManager\n     * @param LibDateTime $dateTime\n     * @param ManagerInterface $eventManager\n     */\n    public function __construct(\n        Context $context,\n        DateTime $date,\n        StoreManagerInterface $storeManager,\n        LibDateTime $dateTime,\n        ManagerInterface $eventManager\n    ) {\n        $this->date             = $date;\n        $this->storeManager     = $storeManager;\n        $this->dateTime         = $dateTime;\n        $this->eventManager     = $eventManager;\n\n        parent::__construct($context);\n    }\n\n    /**\n     * Initialize resource model\n     *\n     * @return void\n     */\n    protected function _construct()\n    {\n        $this->_init('sample_news_author', 'author_id');\n    }\n\n    /**\n     * Process author data before deleting\n     *\n     * @param \\Magento\\Framework\\Model\\AbstractModel $object\n     * @return $this\n     */\n    protected function _beforeDelete(AbstractModel $object)\n    {\n        $condition = ['author_id = ?' => (int)$object->getId()];\n        $this->getConnection()->delete($this->getTable('sample_news_author_store'), $condition);\n        return parent::_beforeDelete($object);\n    }\n\n    /**\n     * before save callback\n     *\n     * @param AbstractModel|\\Sample\\News\\Model\\Author $object\n     * @return $this\n     */\n    protected function _beforeSave(AbstractModel $object)\n    {\n        foreach (['dob'] as $field) {\n            $value = !$object->getData($field) ? null : $object->getData($field);\n            $object->setData($field, $this->dateTime->formatDate($value));\n        }\n        foreach (['awards'] as $field) {\n            if (is_array($object->getData($field))) {\n                $object->setData($field, implode(',', $object->getData($field)));\n            }\n        }\n        $object->setUpdatedAt($this->date->gmtDate());\n        if ($object->isObjectNew()) {\n            $object->setCreatedAt($this->date->gmtDate());\n        }\n        $urlKey = $object->getData('url_key');\n        if ($urlKey == '') {\n            $urlKey = $object->getName();\n        }\n        $urlKey = $object->formatUrlKey($urlKey);\n        $object->setUrlKey($urlKey);\n        $validKey = false;\n        while (!$validKey) {\n            if ($this->getIsUniqueAuthorToStores($object)) {\n                $validKey = true;\n            } else {\n                $urlKey = $this->generateNewUrlKey($urlKey);\n                $object->setData('url_key', $urlKey);\n            }\n        }\n        return parent::_beforeSave($object);\n    }\n\n    /**\n     * @param $urlKey\n     * @return string\n     */\n    protected function generateNewUrlKey($urlKey)\n    {\n        $parts = explode('-', $urlKey);\n        $last = $parts[count($parts) - 1];\n        if (!is_numeric($last)) {\n            $urlKey = $urlKey.'-1';\n        } else {\n            $suffix = '-'.($last + 1);\n            unset($parts[count($parts) - 1]);\n            $urlKey = implode('-', $parts).$suffix;\n        }\n        return $urlKey;\n    }\n\n    /**\n     * Assign author to store views\n     *\n     * @param AbstractModel|\\Sample\\News\\Model\\Author $object\n     * @return $this\n     */\n    protected function _afterSave(AbstractModel $object)\n    {\n        $this->saveStoreRelation($object);\n        return parent::_afterSave($object);\n    }\n\n    /**\n     * Perform operations after object load\n     *\n     * @param AbstractModel $object\n     * @return $this\n     */\n    protected function _afterLoad(AbstractModel $object)\n    {\n        if ($object->getId()) {\n            $stores = $this->lookupStoreIds($object->getId());\n            $object->setData('store_id', $stores);\n        }\n        $awards = $object->getData('awards');\n        if (!is_array($awards)) {\n            $awards = explode(',', $awards);\n            $object->setData('awards', $awards);\n        }\n        return parent::_afterLoad($object);\n    }\n\n    /**\n     * Retrieve select object for load object data\n     *\n     * @param string $field\n     * @param mixed $value\n     * @param \\Sample\\News\\Model\\Author $object\n     * @return \\Zend_Db_Select\n     */\n    protected function _getLoadSelect($field, $value, $object)\n    {\n        $select = parent::_getLoadSelect($field, $value, $object);\n\n        if ($object->getStoreId()) {\n            $storeIds = [\n                Store::DEFAULT_STORE_ID,\n                (int)$object->getStoreId()\n            ];\n            $select->join(\n                [\n                    'sample_news_author_store' => $this->getTable('sample_news_author_store')\n                ],\n                $this->getMainTable() . '.author_id = sample_news_author_store.author_id',\n                []\n            )\n                ->where(\n                    'sample_news_author_store.store_id IN (?)',\n                    $storeIds\n                )\n                ->order('sample_news_author_store.store_id DESC')\n                ->limit(1);\n        }\n        return $select;\n    }\n\n    /**\n     * Retrieve load select with filter by url_key, store and activity\n     *\n     * @param string $urlKey\n     * @param int|array $store\n     * @param int $isActive\n     * @return \\Magento\\Framework\\DB\\Select\n     */\n    protected function getLoadByUrlKeySelect($urlKey, $store, $isActive = null)\n    {\n        $select = $this->getConnection()\n            ->select()\n            ->from(['author' => $this->getMainTable()])\n            ->join(\n                ['author_store' => $this->getTable('sample_news_author_store')],\n                'author.author_id = author_store.author_id',\n                []\n            )\n            ->where(\n                'author.url_key = ?',\n                $urlKey\n            )\n            ->where(\n                'author_store.store_id IN (?)',\n                $store\n            );\n        if (!is_null($isActive)) {\n            $select->where('author.is_active = ?', $isActive);\n        }\n        return $select;\n    }\n\n\n    /**\n     * Check if author url_key exist\n     * return author id if author exists\n     *\n     * @param string $urlKey\n     * @param int $storeId\n     * @return int\n     */\n    public function checkUrlKey($urlKey, $storeId)\n    {\n        $stores = [Store::DEFAULT_STORE_ID, $storeId];\n        $select = $this->getLoadByUrlKeySelect($urlKey, $stores, 1);\n        $select->reset(\\Zend_Db_Select::COLUMNS)\n            ->columns('author.author_id')\n            ->order('author_store.store_id DESC')\n            ->limit(1);\n        return $this->getConnection()->fetchOne($select);\n    }\n\n    /**\n     * Get store ids to which specified item is assigned\n     *\n     * @param int $authorId\n     * @return array\n     */\n    public function lookupStoreIds($authorId)\n    {\n        $adapter = $this->getConnection();\n        $select = $adapter->select()->from(\n            $this->getTable('sample_news_author_store'),\n            'store_id'\n        )->where(\n            'author_id = ?',\n            (int)$authorId\n        );\n        return $adapter->fetchCol($select);\n    }\n\n    /**\n     * Set store model\n     *\n     * @param Store $store\n     * @return $this\n     */\n    public function setStore(Store $store)\n    {\n        $this->store = $store;\n        return $this;\n    }\n\n    /**\n     * Retrieve store model\n     *\n     * @return Store\n     */\n    public function getStore()\n    {\n        return $this->storeManager->getStore($this->store);\n    }\n\n    /**\n     * check if url key is unique\n     *\n     * @param AbstractModel|\\Sample\\News\\Model\\Author $object\n     * @return bool\n     */\n    public function getIsUniqueAuthorToStores(AbstractModel $object)\n    {\n        if ($this->storeManager->hasSingleStore() || !$object->hasStores()) {\n            $stores = [Store::DEFAULT_STORE_ID];\n        } else {\n            $stores = (array)$object->getData('stores');\n        }\n        $select = $this->getLoadByUrlKeySelect($object->getData('url_key'), $stores);\n        if ($object->getId()) {\n            $select->where('author_store.author_id <> ?', $object->getId());\n        }\n        if ($this->getConnection()->fetchRow($select)) {\n            return false;\n        }\n        return true;\n    }\n\n\n    /**\n     * @param AuthorModel $author\n     * @return $this\n     */\n    protected function saveStoreRelation(AuthorModel $author)\n    {\n        $oldStores = $this->lookupStoreIds($author->getId());\n        $newStores = (array)$author->getStoreId();\n        if (empty($newStores)) {\n            $newStores = (array)$author->getStoreId();\n        }\n        $table = $this->getTable('sample_news_author_store');\n        $insert = array_diff($newStores, $oldStores);\n        $delete = array_diff($oldStores, $newStores);\n\n        if ($delete) {\n            $where = [\n                'author_id = ?' => (int)$author->getId(),\n                'store_id IN (?)' => $delete\n            ];\n            $this->getConnection()->delete($table, $where);\n        }\n        if ($insert) {\n            $data = [];\n            foreach ($insert as $storeId) {\n                $data[] = [\n                    'author_id' => (int)$author->getId(),\n                    'store_id' => (int)$storeId\n                ];\n            }\n            $this->getConnection()->insertMultiple($table, $data);\n        }\n        return $this;\n    }\n\n    /**\n     * @param AbstractModel $object\n     * @param $attribute\n     * @return $this\n     * @throws \\Exception\n     */\n    public function saveAttribute(AbstractModel $object, $attribute)\n    {\n        if (is_string($attribute)) {\n            $attributes = [$attribute];\n        } else {\n            $attributes = $attribute;\n        }\n        if (is_array($attributes) && !empty($attributes)) {\n            $this->getConnection()->beginTransaction();\n            $data = array_intersect_key($object->getData(), array_flip($attributes));\n            try {\n                $this->beforeSaveAttribute($object, $attributes);\n                if ($object->getId() && !empty($data)) {\n                    $this->getConnection()->update(\n                        $object->getResource()->getMainTable(),\n                        $data,\n                        [$object->getResource()->getIdFieldName() . '= ?' => (int)$object->getId()]\n                    );\n                    $object->addData($data);\n                }\n                $this->afterSaveAttribute($object, $attributes);\n                $this->getConnection()->commit();\n            } catch (\\Exception $e) {\n                $this->getConnection()->rollBack();\n                throw $e;\n            }\n        }\n        return $this;\n    }\n\n    /**\n     * @param AbstractModel $object\n     * @param $attribute\n     * @return $this\n     */\n    protected function beforeSaveAttribute(AbstractModel $object, $attribute)\n    {\n        if ($object->getEventObject() && $object->getEventPrefix()) {\n            $this->eventManager->dispatch(\n                $object->getEventPrefix() . '_save_attribute_before',\n                [\n                    $object->getEventObject() => $this,\n                    'object' => $object,\n                    'attribute' => $attribute\n                ]\n            );\n        }\n        return $this;\n    }\n\n    /**\n     * After save object attribute\n     *\n     * @param AbstractModel $object\n     * @param string $attribute\n     * @return \\Magento\\Sales\\Model\\ResourceModel\\Attribute\n     */\n    protected function afterSaveAttribute(AbstractModel $object, $attribute)\n    {\n        if ($object->getEventObject() && $object->getEventPrefix()) {\n            $this->eventManager->dispatch(\n                $object->getEventPrefix() . '_save_attribute_after',\n                [\n                    $object->getEventObject() => $this,\n                    'object' => $object,\n                    'attribute' => $attribute\n                ]\n            );\n        }\n        return $this;\n    }\n}\n"
  },
  {
    "path": "Model/Routing/Entity.php",
    "content": "<?php\nnamespace Sample\\News\\Model\\Routing;\n\nuse Sample\\News\\Model\\FactoryInterface;\n\nclass Entity\n{\n    /**\n     * @var string\n     */\n    protected $prefixConfigPath;\n    /**\n     * @var string\n     */\n    protected $suffixConfigPath;\n    /**\n     * @var string\n     */\n    protected $listKeyConfigPath;\n    /**\n     * @var string\n     */\n    protected $listAction;\n    /**\n     * @var FactoryInterface\n     */\n    protected $factory;\n    /**\n     * @var string\n     */\n    protected $controller;\n    /**\n     * @var string\n     */\n    protected $viewAction;\n    /**\n     * @var string\n     */\n    protected $param;\n\n    /**\n     * @param $prefixConfigPath\n     * @param $suffixConfigPath\n     * @param $listKeyConfigPath\n     * @param FactoryInterface $factory\n     * @param $controller\n     * @param string $listAction\n     * @param string $viewAction\n     * @param string $param\n     */\n    public function __construct(\n        $prefixConfigPath,\n        $suffixConfigPath,\n        $listKeyConfigPath,\n        FactoryInterface $factory,\n        $controller,\n        $listAction = 'index',\n        $viewAction = 'view',\n        $param = 'id'\n    ) {\n        $this->prefixConfigPath     = $prefixConfigPath;\n        $this->suffixConfigPath     = $suffixConfigPath;\n        $this->listKeyConfigPath    = $listKeyConfigPath;\n        $this->factory              = $factory;\n        $this->controller           = $controller;\n        $this->listAction           = $listAction;\n        $this->viewAction           = $viewAction;\n        $this->param                = $param;\n    }\n\n    /**\n     * @return string\n     */\n    public function getPrefixConfigPath()\n    {\n        return $this->prefixConfigPath;\n    }\n\n    /**\n     * @return string\n     */\n    public function getSuffixConfigPath()\n    {\n        return $this->suffixConfigPath;\n    }\n\n    /**\n     * @return string\n     */\n    public function getListKeyConfigPath()\n    {\n        return $this->listKeyConfigPath;\n    }\n\n    /**\n     * @return string\n     */\n    public function getListAction()\n    {\n        return $this->listAction;\n    }\n\n    /**\n     * @return FactoryInterface\n     */\n    public function getFactory()\n    {\n        return $this->factory;\n    }\n\n    /**\n     * @return mixed\n     */\n    public function getController()\n    {\n        return $this->controller;\n    }\n\n    /**\n     * @return string\n     */\n    public function getViewAction()\n    {\n        return $this->viewAction;\n    }\n\n    /**\n     * @return string\n     */\n    public function getParam()\n    {\n        return $this->param;\n    }\n\n}\n"
  },
  {
    "path": "Model/Routing/RoutableInterface.php",
    "content": "<?php\nnamespace Sample\\News\\Model\\Routing;\n\ninterface RoutableInterface\n{\n    /**\n     * @param $urlKey\n     * @param $storeId\n     * @return int|null\n     */\n    public function checkUrlKey($urlKey, $storeId);\n}\n"
  },
  {
    "path": "Model/Source/AbstractSource.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\Source;\n\nuse Magento\\Framework\\Option\\ArrayInterface;\n\nabstract class AbstractSource implements ArrayInterface\n{\n    /**\n     * @var array\n     */\n    protected $options;\n\n    /**\n     * @param array $options\n     */\n    public function __construct(\n        array $options = []\n    ) {\n        $this->options = $options;\n    }\n\n    /**\n     * @return array\n     */\n    abstract public function toOptionArray();\n\n    /**\n     * @param $value\n     * @return string\n     */\n    public function getOptionText($value)\n    {\n        $options = $this->getOptions();\n        if (!is_array($value)) {\n            $value = explode(',', $value);\n        }\n        $texts = [];\n        foreach ($value as $v) {\n            if (isset($options[$v])) {\n                $texts[] = $options[$v];\n            }\n        }\n        return implode(', ', $texts);\n    }\n    /**\n     * get options as key value pair\n     *\n     * @return array\n     */\n    public function getOptions()\n    {\n        $options = [];\n        foreach ($this->toOptionArray() as $values) {\n            $options[$values['value']] = __($values['label']);\n        }\n        return $options;\n    }\n}\n"
  },
  {
    "path": "Model/Source/Country.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\Source;\n\nuse Magento\\Directory\\Model\\ResourceModel\\Country\\CollectionFactory as CountryCollectionFactory;\nuse Magento\\Framework\\Option\\ArrayInterface;\n\nclass Country extends AbstractSource implements ArrayInterface\n{\n    /**\n     * @var \\Sample\\News\\Model\\Author\n     */\n    protected $countryCollectionFactory;\n\n    /**\n     * @param CountryCollectionFactory $countryCollectionFactory\n     * @param array $options\n     */\n    public function __construct(\n        CountryCollectionFactory $countryCollectionFactory,\n        array $options = []\n    )\n    {\n        $this->countryCollectionFactory = $countryCollectionFactory;\n        parent::__construct($options);\n    }\n\n    /**\n     * get options as key value pair\n     *\n     * @return array\n     */\n    public function toOptionArray()\n    {\n        if (count($this->options) == 0) {\n            $this->options = $this->countryCollectionFactory->create()->toOptionArray(' ');\n        }\n        return $this->options;\n    }\n}\n"
  },
  {
    "path": "Model/Source/Options.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model\\Source;\n\nuse Magento\\Framework\\Option\\ArrayInterface;\n\nclass Options extends AbstractSource implements ArrayInterface\n{\n    /**\n     * get options\n     *\n     * @return array\n     */\n    public function toOptionArray()\n    {\n        $options = [];\n        foreach ($this->options as $values) {\n            $options[] = [\n                'value' => $values['value'],\n                'label' => __($values['label'])\n            ];\n        }\n        return $options;\n\n    }\n\n\n}\n"
  },
  {
    "path": "Model/Uploader.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model;\n\nuse Magento\\Framework\\App\\Filesystem\\DirectoryList;\nuse Magento\\Framework\\Exception\\LocalizedException;\nuse Magento\\Framework\\Filesystem;\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\MediaStorage\\Helper\\File\\Storage\\Database;\nuse Magento\\MediaStorage\\Model\\File\\UploaderFactory;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Psr\\Log\\LoggerInterface;\n\nclass Uploader\n{\n    /**\n     * @var string\n     */\n    const IMAGE_TMP_PATH    = 'sample_news/tmp/author/image';\n    /**\n     * @var string\n     */\n    const IMAGE_PATH        = 'sample_news/author/image';\n    /**\n     * @var string\n     */\n    const FILE_TMP_PATH     = 'sample_news/tmp/author/file';\n    /**\n     * @var string\n     */\n    const FILE_PATH         = 'sample_news/author/file';\n\n    /**\n     * Core file storage database\n     *\n     * @var \\Magento\\MediaStorage\\Helper\\File\\Storage\\Database\n     */\n    protected $coreFileStorageDatabase;\n\n    /**\n     * Media directory object (writable).\n     *\n     * @var \\Magento\\Framework\\Filesystem\\Directory\\WriteInterface\n     */\n    protected $mediaDirectory;\n\n    /**\n     * Uploader factory\n     *\n     * @var \\Magento\\MediaStorage\\Model\\File\\UploaderFactory\n     */\n    private $uploaderFactory;\n\n    /**\n     * Store manager\n     *\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * @var \\Psr\\Log\\LoggerInterface\n     */\n    protected $logger;\n\n    /**\n     * Base tmp path\n     *\n     * @var string\n     */\n    protected $baseTmpPath;\n\n    /**\n     * Base path\n     *\n     * @var string\n     */\n    protected $basePath;\n\n    /**\n     * Allowed extensions\n     *\n     * @var string\n     */\n    protected $allowedExtensions;\n\n    /**\n     * @param Database $coreFileStorageDatabase\n     * @param Filesystem $filesystem\n     * @param UploaderFactory $uploaderFactory\n     * @param StoreManagerInterface $storeManager\n     * @param LoggerInterface $logger\n     * @param array $allowedExtensions\n     * @param $baseTmpPath\n     * @param $basePath\n     */\n    public function __construct(\n        Database $coreFileStorageDatabase,\n        Filesystem $filesystem,\n        UploaderFactory $uploaderFactory,\n        StoreManagerInterface $storeManager,\n        LoggerInterface $logger,\n        $allowedExtensions = [],\n        $baseTmpPath,\n        $basePath\n\n    ) {\n        $this->coreFileStorageDatabase  = $coreFileStorageDatabase;\n        $this->mediaDirectory           = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);\n        $this->uploaderFactory          = $uploaderFactory;\n        $this->storeManager             = $storeManager;\n        $this->logger                   = $logger;\n        $this->baseTmpPath              = $baseTmpPath;\n        $this->basePath                 = $basePath;\n        $this->allowedExtensions        = $allowedExtensions;\n    }\n\n    /**\n     * Set base tmp path\n     *\n     * @param string $baseTmpPath\n     *\n     * @return void\n     */\n    public function setBaseTmpPath($baseTmpPath)\n    {\n        $this->baseTmpPath = $baseTmpPath;\n    }\n\n    /**\n     * Set base path\n     *\n     * @param string $basePath\n     *\n     * @return void\n     */\n    public function setBasePath($basePath)\n    {\n        $this->basePath = $basePath;\n    }\n\n    /**\n     * Set allowed extensions\n     *\n     * @param string[] $allowedExtensions\n     *\n     * @return void\n     */\n    public function setAllowedExtensions($allowedExtensions)\n    {\n        $this->allowedExtensions = $allowedExtensions;\n    }\n\n    /**\n     * Retrieve base tmp path\n     *\n     * @return string\n     */\n    public function getBaseTmpPath()\n    {\n        return $this->baseTmpPath;\n    }\n\n    /**\n     * Retrieve base path\n     *\n     * @return string\n     */\n    public function getBasePath()\n    {\n        return $this->basePath;\n    }\n\n    /**\n     * Retrieve base path\n     *\n     * @return string[]\n     */\n    public function getAllowedExtensions()\n    {\n        return $this->allowedExtensions;\n    }\n\n    /**\n     * Retrieve path\n     *\n     * @param string $path\n     * @param string $name\n     *\n     * @return string\n     */\n    public function getFilePath($path, $name)\n    {\n        return rtrim($path, '/') . '/' . ltrim($name, '/');\n    }\n\n    /**\n     * Checking file for moving and move it\n     *\n     * @param string $name\n     *\n     * @return string\n     *\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function moveFileFromTmp($name)\n    {\n        $baseTmpPath = $this->getBaseTmpPath();\n        $basePath = $this->getBasePath();\n\n        $baseFilePath = $this->getFilePath($basePath, $name);\n        $baseTmpFilePath = $this->getFilePath($baseTmpPath, $name);\n\n        try {\n            $this->coreFileStorageDatabase->copyFile(\n                $baseTmpFilePath,\n                $baseFilePath\n            );\n            $this->mediaDirectory->renameFile(\n                $baseTmpFilePath,\n                $baseFilePath\n            );\n        } catch (\\Exception $e) {\n            throw new LocalizedException(\n                __('Something went wrong while saving the file(s).')\n            );\n        }\n\n        return $name;\n    }\n\n    public function getBaseUrl()\n    {\n        return $this->storeManager\n            ->getStore()\n            ->getBaseUrl(\n                UrlInterface::URL_TYPE_MEDIA\n            );\n    }\n    /**\n     * Checking file for save and save it to tmp dir\n     *\n     * @param string $fileId\n     *\n     * @return string[]\n     *\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function saveFileToTmpDir($fileId)\n    {\n        $baseTmpPath = $this->getBaseTmpPath();\n\n        $uploader = $this->uploaderFactory->create(['fileId' => $fileId]);\n        $uploader->setAllowedExtensions($this->getAllowedExtensions());\n        $uploader->setAllowRenameFiles(true);\n        $uploader->setFilesDispersion(true);\n\n        $result = $uploader->save($this->mediaDirectory->getAbsolutePath($baseTmpPath));\n\n        if (!$result) {\n            throw new LocalizedException(\n                __('File can not be saved to the destination folder.')\n            );\n        }\n        /**\n         * Workaround for prototype 1.7 methods \"isJSON\", \"evalJSON\" on Windows OS\n         */\n        $result['tmp_name'] = str_replace('\\\\', '/', $result['tmp_name']);\n        $result['path'] = str_replace('\\\\', '/', $result['path']);\n        $result['url'] =  $this->getBaseUrl() . $this->getFilePath($baseTmpPath, $result['file']);\n\n        if (isset($result['file'])) {\n            try {\n                $relativePath = rtrim($baseTmpPath, '/') . '/' . ltrim($result['file'], '/');\n                $this->coreFileStorageDatabase->saveFile($relativePath);\n            } catch (\\Exception $e) {\n                $this->logger->critical($e);\n                throw new LocalizedException(\n                    __('Something went wrong while saving the file(s).')\n                );\n            }\n        }\n\n        return $result;\n    }\n\n    /**\n     * @param $input\n     * @param $data\n     * @return string\n     */\n    public function uploadFileAndGetName($input, $data)\n    {\n        if (!isset($data[$input])) {\n            return '';\n        }\n        if (is_array($data[$input]) && !empty($data[$input]['delete'])) {\n            return '';\n        }\n\n        if (isset($data[$input][0]['name']) && isset($data[$input][0]['tmp_name'])) {\n            try {\n                $result = $this->moveFileFromTmp($data[$input][0]['file']);\n                return $result;\n            } catch (\\Exception $e) {\n                return '';\n            }\n        } elseif (isset($data[$input][0]['name'])) {\n            return $data[$input][0]['name'];\n        }\n        return '';\n    }\n}\n"
  },
  {
    "path": "Model/UploaderPool.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Model;\n\nuse Magento\\Framework\\ObjectManagerInterface;\n\nclass UploaderPool\n{\n    /**\n     * @var ObjectManagerInterface\n     */\n    protected $objectManager;\n    /**\n     * @var array\n     */\n    protected $uploaders;\n\n    /**\n     * @param ObjectManagerInterface $objectManager\n     * @param array $uploaders\n     */\n    public function __construct(\n        ObjectManagerInterface $objectManager,\n        array $uploaders = []\n    ) {\n        $this->objectManager = $objectManager;\n        $this->uploaders     = $uploaders;\n    }\n\n    /**\n     * @param $type\n     * @return Uploader\n     * @throws \\Exception\n     */\n    public function getUploader($type)\n    {\n        if (!isset($this->uploaders[$type])) {\n            throw new \\Exception(\"Uploader not found for type: \".$type);\n        }\n        if (!is_object($this->uploaders[$type])) {\n            $this->uploaders[$type] = $this->objectManager->create($this->uploaders[$type]);\n\n        }\n        $uploader = $this->uploaders[$type];\n        if (!($uploader instanceof Uploader)) {\n            throw new \\Exception(\"Uploader for type {$type} not instance of \". Uploader::class);\n        }\n        return $uploader;\n    }\n}\n"
  },
  {
    "path": "Plugin/Block/Topmenu.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Plugin\\Block;\n\nuse Magento\\Framework\\App\\Request\\Http;\nuse Magento\\Framework\\Data\\Tree\\Node;\nuse Magento\\Theme\\Block\\Html\\Topmenu as TopmenuBlock;\nuse Sample\\News\\Model\\Author\\Url;\n\nclass Topmenu\n{\n    /**\n     * @var Url\n     */\n    protected $url;\n    /**\n     * @var Http\n     */\n    protected $request;\n\n    /**\n     * @param Url $url\n     * @param Http $request\n     */\n    public function __construct(\n        Url $url,\n        Http $request\n    ) {\n        $this->url      = $url;\n        $this->request  = $request;\n    }\n\n    /**\n     * @param TopmenuBlock $subject\n     * @param string $outermostClass\n     * @param string $childrenWrapClass\n     * @param int $limit\n     * @SuppressWarnings(\"PMD.UnusedFormalParameter\")\n     */\n    // @codingStandardsIgnoreStart\n    public function beforeGetHtml(\n        TopmenuBlock $subject,\n        $outermostClass = '',\n        $childrenWrapClass = '',\n        $limit = 0\n    ) {\n        // @codingStandardsIgnoreEnd\n        $node = new Node(\n            $this->getNodeAsArray(),\n            'id',\n            $subject->getMenu()->getTree(),\n            $subject->getMenu()\n        );\n        $subject->getMenu()->addChild($node);\n    }\n\n    /**\n     * @return array\n     */\n    protected function getNodeAsArray()\n    {\n        return [\n            'name' => __('Authors'),\n            'id' => 'authors-node',\n            'url' => $this->url->getListUrl(),\n            'has_active' => false,\n            'is_active' => in_array($this->request->getFullActionName(), $this->getActiveHandles())\n        ];\n    }\n\n    /**\n     * @return array\n     */\n    protected function getActiveHandles()\n    {\n        return [\n            'sample_news_author_index',\n            'sample_news_author_view'\n        ];\n    }\n}\n"
  },
  {
    "path": "README.md",
    "content": "Magento 2.0 Sample Module\n====================\n\nLast tested on Magento2 version 2.1\n\n\n![Magento 2 Sample Module](http://i.imgur.com/Ma6v2gs.jpg)\n\nWhat I got so far:\n----------\n\n - One custom entity Author. flat and related to store views\n - Backend section for the entity mentioned above\n - Frontend list and view for the entity mentioned above\n - List on Author view page on frontend\n - Rss feeds for author list.\n - Breadcrumbs support for list and view pages.\n\nThe other types of entities and features listed in **the purpose** will follow.\nDon't put many hopes in this. Based on the comments on the magento 2 repo the grid system will be changed...A LOT.\n\nThe purpose\n----------\n\n....of this repository is to hold a sample CRUD module for Magento 2.0.\nThis module should contain the following:\n\n * 4 Entities.\n  * 1 Flat - with a store selector. Similar to CMS pages\n  * 1 Flat but behaving as a tree - with a store selector. Similar to categories but non EAV\n  * 1 EAV - similar to products\n  * 1 EAV but behaving as tree - Similar to categories.\n * Backend files for managing the entities mentioned above\n * Frontend files for list and view each of the entities mentioned above\n * RSS feeds for each entity mentioned above\n * SOAP & REST API files for the entities mentioned above\n * URL rewrites filed for frontend for the entities above\n * Files needed for a many to many relation between the entities above and products\n * Files needed for a many to many relation between the entities above and categories\n * Files needed for a many to many relation between the entities above (among themselves)\n * Each entity must support different attribute types:\n  * Text\n  * Textarea (with and without WYSIWYG editor)\n  * Date\n  * Yes/No\n  * Dropdown (with different source models)\n  * Multi-select (with different source models)\n  * File\n  * Image\n  * Decimal\n  * Integer (signed and unsigned)\n  * Color\n * Each entity should have fronend links to the list page in one of the menu/link areas provided by the default theme\n * Each entity must have SEO attributes (meta-title, meta-description, meta-keywords)\n * Would be nice to have unit tests for every class in the code - but that's low priority.\n * Each entity type must have widgets for frontend (link, short view).\n * Each entity must support customer comments.\n * Each EAV entity must have a section for managing attributes (similar to product attributes).\n\nAfter this is complete (or almost) it will become the base source for the Ultimate Module Creator 2.0 which will be a version for Magento 2.0 of the [Ultimate Module Creator for Magento 1.7](https://github.com/tzyganu/UMC1.9).\n\nAny other ideas and pieces of code are welcomed even encouraged.\n\nInstall\n-----\n\nManually:\nTo install this module copy the code from this repo to `app/code` folder of your Magento 2 instance,\nIf you do this after installing Magento 2 you need to run `php bin/magento setup:upgrade`\n\nVia composer\n\n - composer config repositories.sample-module-news git git@github.com:tzyganu/Magento2SampleModule.git\n - sudo composer require sample/module-news:dev-master\n - php bin/magento setup:upgrade\n\n\nUninstall\n--------\n\nIf you installed it manually:\n - remove the folder `app/code/Sample/News`\n - drop the tables `sample_news_author_store` and `sample_news_author` (in this order)\n - remove the config settings.  `DELETE FROM core_config_data WHERE path LIKE 'sample_news/%'`\n - remove the module `Sample_News` from `app/etc/config.php`\n - remove the module `Sample_News` from table `setup_module`: `DELETE FROM setup_module WHERE module='Sample_News'`\n\nIf you installed it via composer:\n - run this in console  `bin/magento module:uninstall -r Sample_News`. You might have some problems while uninstalling. See more [details here](http://magento.stackexchange.com/q/123544/146):\n"
  },
  {
    "path": "Setup/InstallSchema.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Setup;\n\nuse Magento\\Framework\\DB\\Ddl\\Table;\nuse Magento\\Framework\\DB\\Adapter\\AdapterInterface;\nuse Magento\\Framework\\Setup\\InstallSchemaInterface;\nuse Magento\\Framework\\Setup\\ModuleContextInterface;\nuse Magento\\Framework\\Setup\\SchemaSetupInterface;\n\n\nclass InstallSchema implements InstallSchemaInterface\n{\n    /**\n     * {@inheritdoc}\n     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)\n     * @SuppressWarnings(PHPMD.Generic.CodeAnalysis.UnusedFunctionParameter)\n     */\n    // @codingStandardsIgnoreStart\n    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)\n    // @codingStandardsIgnoreEnd\n    {\n        $installer = $setup;\n\n        $installer->startSetup();\n\n        if (!$installer->tableExists('sample_news_author')) {\n            $table = $installer->getConnection()\n                ->newTable($installer->getTable('sample_news_author'));\n            $table->addColumn(\n                    'author_id',\n                    Table::TYPE_INTEGER,\n                    null,\n                    [\n                        'identity' => true,\n                        'unsigned' => true,\n                        'nullable' => false,\n                        'primary' => true\n                    ],\n                    'Author ID'\n                )\n                ->addColumn(\n                    'name',\n                    Table::TYPE_TEXT,\n                    255,\n                    ['nullable'  => false,],\n                    'Author Name'\n                )\n                ->addColumn(\n                    'url_key',\n                    Table::TYPE_TEXT,\n                    255,\n                    ['nullable'  => false,],\n                    'Author Url Key'\n                )\n                ->addColumn(\n                    'biography',\n                    Table::TYPE_TEXT,\n                    '2M',\n                    [],\n                    'Author Biography'\n                )\n                ->addColumn(\n                    'dob',\n                    Table::TYPE_DATE,\n                    null,\n                    [],\n                    'Author Birth date'\n                )\n                ->addColumn(\n                    'awards',\n                    Table::TYPE_TEXT,\n                    '2M',\n                    [],\n                    'Author Awards'\n                )\n                ->addColumn(\n                    'type',\n                    Table::TYPE_INTEGER,\n                    null,\n                    [],\n                    'Author Type'\n                )\n                ->addColumn(\n                    'avatar',\n                    Table::TYPE_TEXT,\n                    255,\n                    [],\n                    'Author Avatar'\n                )\n                ->addColumn(\n                    'resume',\n                    Table::TYPE_TEXT,\n                    255,\n                    [],\n                    'Author Resume'\n                )\n                ->addColumn(\n                    'country',\n                    Table::TYPE_TEXT,\n                    2,\n                    [],\n                    'Author Country'\n                )\n                ->addColumn(\n                    'meta_title',\n                    Table::TYPE_TEXT,\n                    255,\n                    [],\n                    'Author Meta Title'\n                )\n                ->addColumn(\n                    'meta_description',\n                    Table::TYPE_TEXT,\n                    '2M',\n                    [],\n                    'Author Meta Description'\n                )\n                ->addColumn(\n                    'meta_keywords',\n                    Table::TYPE_TEXT,\n                    '2M',\n                    [],\n                    'Author Meta Keywords'\n                )\n                ->addColumn(\n                    'is_active',\n                    Table::TYPE_INTEGER,\n                    null,\n                    [\n                        'nullable'  => false,\n                        'default'   => '1',\n                    ],\n                    'Is Author Active'\n                )\n                ->addColumn(\n                    'in_rss',\n                    Table::TYPE_INTEGER,\n                    null,\n                    [\n                        'nullable'  => false,\n                        'default'   => '1',\n                    ],\n                    'Show in rss'\n                )\n                ->addColumn(\n                    'updated_at',\n                    Table::TYPE_TIMESTAMP,\n                    null,\n                    [],\n                    'Update at'\n                )\n                ->addColumn(\n                    'created_at',\n                    Table::TYPE_TIMESTAMP,\n                    null,\n                    [],\n                    'Creation Time'\n                )\n                ->setComment('News authors');\n            $installer->getConnection()->createTable($table);\n\n            $installer->getConnection()->addIndex(\n                $installer->getTable('sample_news_author'),\n                $setup->getIdxName(\n                    $installer->getTable('sample_news_author'),\n                    ['name','photo'],\n                    AdapterInterface::INDEX_TYPE_FULLTEXT\n                ),\n                [\n                    'name',\n                    'biography',\n                    'url_key',\n                    'resume',\n                    'country',\n                    'meta_title',\n                    'meta_keywords',\n                    'meta_description'\n                ],\n                AdapterInterface::INDEX_TYPE_FULLTEXT\n            );\n        }\n\n        //Create Authors to Store table\n        if (!$installer->tableExists('sample_news_author_store')) {\n            $table = $installer->getConnection()\n                ->newTable($installer->getTable('sample_news_author_store'));\n            $table->addColumn(\n                    'author_id',\n                    Table::TYPE_INTEGER,\n                    null,\n                    [\n                        'unsigned' => true,\n                        'nullable' => false,\n                        'primary'   => true,\n                    ],\n                    'Author ID'\n                )\n                ->addColumn(\n                    'store_id',\n                    Table::TYPE_SMALLINT,\n                    null,\n                    [\n                        'unsigned'  => true,\n                        'nullable'  => false,\n                        'primary'   => true,\n                    ],\n                    'Store ID'\n                )\n                ->addIndex(\n                    $installer->getIdxName('sample_news_author_store', ['store_id']),\n                    ['store_id']\n                )\n                ->addForeignKey(\n                    $installer->getFkName('sample_news_author_store', 'author_id', 'sample_news_author', 'author_id'),\n                    'author_id',\n                    $installer->getTable('sample_news_author'),\n                    'author_id',\n                    Table::ACTION_CASCADE\n                )\n                ->addForeignKey(\n                    $installer->getFkName('sample_news_author_store', 'store_id', 'store', 'store_id'),\n                    'store_id',\n                    $installer->getTable('store'),\n                    'store_id',\n                    Table::ACTION_CASCADE\n                )\n                ->setComment('Author To Store Link Table');\n            $installer->getConnection()->createTable($table);\n        }\n\n    }\n}\n"
  },
  {
    "path": "Setup/Uninstall.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Setup;\n\nuse Magento\\Framework\\Model\\AbstractModel;\nuse Magento\\Framework\\Setup\\ModuleContextInterface;\nuse Magento\\Framework\\Setup\\SchemaSetupInterface;\nuse Magento\\Framework\\Setup\\UninstallInterface;\nuse Magento\\Config\\Model\\ResourceModel\\Config\\Data;\nuse Magento\\Config\\Model\\ResourceModel\\Config\\Data\\CollectionFactory;\n\n\n/**\n * @codeCoverageIgnore\n */\nclass Uninstall implements UninstallInterface\n{\n    /**\n     * @var CollectionFactory\n     */\n    protected $collectionFactory;\n    /**\n     * @var Data\n     */\n    protected $configResource;\n\n    /**\n     * @param CollectionFactory $collectionFactory\n     * @param Data $configResource\n     */\n    public function __construct(\n        CollectionFactory $collectionFactory,\n        Data $configResource\n    )\n    {\n        $this->collectionFactory = $collectionFactory;\n        $this->configResource    = $configResource;\n    }\n\n    /**\n     * {@inheritdoc}\n     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)\n     * @SuppressWarnings(PHPMD.Generic.CodeAnalysis.UnusedFunctionParameter)\n     */\n    // @codingStandardsIgnoreStart\n    public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)\n    // @codingStandardsIgnoreEnd\n    {\n        //remove tables\n        if ($setup->tableExists('sample_news_author_store')) {\n            $setup->getConnection()->dropTable('sample_news_author_store');\n        }\n        if ($setup->tableExists('sample_news_author')) {\n            $setup->getConnection()->dropTable('sample_news_author');\n        }\n        //remove config settings if any\n        $collection = $this->collectionFactory->create()\n            ->addPathFilter('sample_news');\n        foreach ($collection as $config) {\n            $this->deleteConfig($config);\n        }\n    }\n\n    /**\n     * @param AbstractModel $config\n     * @throws \\Exception\n     */\n    protected function deleteConfig(AbstractModel $config)\n    {\n        $this->configResource->delete($config);\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Model/Author/DataProviderTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Model\\Author;\n\nuse Magento\\Ui\\DataProvider\\Modifier\\ModifierInterface;\nuse Magento\\Ui\\DataProvider\\Modifier\\PoolInterface;\nuse Sample\\News\\Model\\Author\\DataProvider;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory;\n\nclass DataProviderTest extends \\PHPUnit_Framework_TestCase\n{\n\n    /**\n     * @var DataProvider\n     */\n    protected $dataProvider;\n\n    /**\n     * set up tests\n     */\n    protected function setUp()\n    {\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|PoolInterface  $poolMock */\n        $poolMock = $this->getMockBuilder(PoolInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|ModifierInterface $modifierMock */\n        $modifierMock = $this->getMockBuilder(ModifierInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $modifierMock->method('modifyMeta')->willReturn($this->getDummyMeta());\n        $modifierMock->method('modifyData')->willReturn($this->getDummyData());\n        $poolMock->method('getModifiersInstances')->willReturn([$modifierMock]);\n\n        /** @var ModifierInterface|CollectionFactory $collectionFactoryMock */\n        $collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        $this->dataProvider = new DataProvider(\n            'dummy',\n            'dummy_id',\n            'dummy_id',\n            $collectionFactoryMock,\n            $poolMock,\n            [],\n            []\n        );\n    }\n\n    /**\n     * @return array\n     */\n    protected function getDummyMeta()\n    {\n        return ['dummy_meta_key'=>'dummy_meta_value'];\n    }\n\n    /**\n     * @return array\n     */\n    protected function getDummyData()\n    {\n        return ['dummy_data_key'=>'dummy_data_value'];\n    }\n\n    /**\n     * tests DataProvider::prepareMeta()\n     */\n    public function testPrepareMeta()\n    {\n        $this->assertEquals($this->getDummyMeta(), $this->dataProvider->prepareMeta([]));\n    }\n\n    /**\n     * tests DataProvider::getData()\n     */\n    public function testGetData()\n    {\n        $this->assertEquals($this->getDummyData(), $this->dataProvider->getData());\n    }\n\n}\n"
  },
  {
    "path": "Test/Unit/Model/Author/RssTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Model\\Author;\n\n\n\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Store\\Api\\Data\\StoreInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Sample\\News\\Model\\Author\\Rss;\n\nclass RssTest extends \\PHPUnit_Framework_TestCase\n{\n    const STORE_ID = 1;\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|UrlInterface\n     */\n    protected $urlMockBuilder;\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|ScopeConfigInterface\n     */\n    protected $scopeConfigMock;\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|StoreManagerInterface\n     */\n    protected $storeManagerMock;\n    /**\n     * @var Rss\n     */\n    protected $rss;\n\n    /**\n     * setup tests\n     */\n    protected function setUp()\n    {\n        $this->urlMockBuilder = $this->getMockBuilder(UrlInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $this->urlMockBuilder\n            ->expects($this->any())\n            ->method('getUrl')\n            ->willReturnMap(\n                [\n                    [\n                        'sample_news/author/rss',\n                        [\n                            'store' => self::STORE_ID\n                        ],\n                        'some/url/here'\n                    ]\n                ]\n            );\n        $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        $storeMock = $this->getMockBuilder(StoreInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $storeMock->expects($this->any())->method('getId')->willReturn(self::STORE_ID);\n        $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock);\n\n        $this->rss = new Rss(\n            $this->urlMockBuilder,\n            $this->scopeConfigMock,\n            $this->storeManagerMock\n        );\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Rss::isRssEnabled()\n     *\n     * with global rss setting disabled\n     * and author rss disabled\n     */\n    public function testIsRssEnabledGlobalFalseAuthorFalse()\n    {\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        'rss/config/active',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        false\n                    ],\n                    [\n                        'sample_news/author/rss',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        false\n                    ],\n                ]\n            );\n        $this->assertFalse($this->rss->isRssEnabled());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Rss::isRssEnabled()\n     *\n     * with global rss setting enabled\n     * and author rss disabled\n     */\n    public function testIsRssEnabledGlobalTrueAuthorFalse()\n    {\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        'rss/config/active',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        true\n                    ],\n                    [\n                        'sample_news/author/rss',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        false\n                    ],\n                ]\n            );\n        $this->assertFalse($this->rss->isRssEnabled());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Rss::isRssEnabled()\n     *\n     * with global rss setting disabled\n     * and author rss enabled\n     */\n    public function testIsRssEnabledGlobalFalseAuthorTrue()\n    {\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        'rss/config/active',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        false\n                    ],\n                    [\n                        'sample_news/author/rss',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        true\n                    ],\n                ]\n            );\n        $this->assertFalse($this->rss->isRssEnabled());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Rss::isRssEnabled()\n     *\n     * with global rss setting enabled\n     * and author rss enabled\n     */\n    public function testIsRssEnabledGlobalTrueAuthorTrue()\n    {\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        'rss/config/active',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        true\n                    ],\n                    [\n                        'sample_news/author/rss',\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        true\n                    ],\n                ]\n            );\n        $this->assertTrue($this->rss->isRssEnabled());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Rss::isRssEnabled()\n     */\n    public function testGetRssLink()\n    {\n        $this->assertEquals('some/url/here', $this->rss->getRssLink());\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Model/Author/UrlTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Model\\Author;\n\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\nuse Sample\\News\\Model\\Author;\nuse Sample\\News\\Model\\Author\\Url;\n\nclass UrlTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @var string\n     *\n     * dummy list url key\n     */\n    const LIST_URL_KEY = 'authors.html';\n    /**\n     * @var string\n     *\n     * dummy author view page url keu\n     */\n    const ITEM_URL_KEY = 'author';\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|UrlInterface\n     */\n    protected $urlMockBuilder;\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|ScopeConfigInterface\n     */\n    protected $scopeConfigMock;\n    /**\n     * @var \\Sample\\News\\Model\\Author\\Url\n     */\n    protected $urlModel;\n\n    /**\n     * setup tests\n     */\n    public function setUp()\n    {\n        $this->urlMockBuilder = $this->getMockBuilder(UrlInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $this->urlMockBuilder->expects($this->any())\n            ->method('getUrl')\n            ->willReturnMap(\n                [\n                    [\n                        '',\n                        [\n                            '_direct' => self::LIST_URL_KEY\n                        ],\n                        'http://example.com/'.self::LIST_URL_KEY,\n                    ],\n                    [\n                        'sample_news/author/index',\n                        null,\n                        'http://example.com/sample_news/author/index'\n                    ],\n                    [\n                        'sample_news/author/view',\n                        ['id' => 1],\n                        'http://example.com/sample_news/author/view/id/1'\n                    ],\n                    [\n                        '',\n                        [\n                            '_direct' => self::ITEM_URL_KEY\n                        ],\n                        'http://example.com/'.self::ITEM_URL_KEY,\n                    ],\n                    [\n                        '',\n                        [\n                            '_direct' => 'author/'.self::ITEM_URL_KEY\n                        ],\n                        'http://example.com/author/'.self::ITEM_URL_KEY,\n                    ],\n                    [\n                        '',\n                        [\n                            '_direct' => 'author/'.self::ITEM_URL_KEY.'.html'\n                        ],\n                        'http://example.com/author/'.self::ITEM_URL_KEY.'.html',\n                    ],\n                    [\n                        '',\n                        [\n                            '_direct' => self::ITEM_URL_KEY.'.html'\n                        ],\n                        'http://example.com/'.self::ITEM_URL_KEY.'.html',\n                    ],\n                ]\n            );\n        $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        $this->urlModel = new Url($this->urlMockBuilder, $this->scopeConfigMock);\n    }\n\n    /**\n     * @param bool $withUrlKey\n     * @return \\PHPUnit_Framework_MockObject_MockObject|\\Sample\\News\\Model\\Author\n     */\n    protected function setUpAuthor($withUrlKey)\n    {\n        $author = $this->getMockBuilder(Author::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $author->expects($this->any())->method('getId')->willReturn(1);\n        if ($withUrlKey) {\n            $author->expects($this->any())->method('getUrlKey')->willReturn(self::ITEM_URL_KEY);\n        }\n        return $author;\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Url::getListUrl()\n     *\n     * with SEF url key\n     */\n    public function testGetListUrlWithSef()\n    {\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturn(self::LIST_URL_KEY);\n        $this->assertEquals('http://example.com/'.self::LIST_URL_KEY, $this->urlModel->getListUrl());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Url::getListUrl()\n     *\n     * without SEF url key\n     */\n    public function testGetListUrlWithoutSef()\n    {\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturn('');\n        $this->assertEquals('http://example.com/sample_news/author/index', $this->urlModel->getListUrl());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Url::getAuthorUrl()\n     *\n     * without SEF url key\n     */\n    public function testGetAuthorUrlWithoutSef()\n    {\n        $author = $this->setUpAuthor(false);\n        $author->expects($this->any())->method('getUrlKey')->willReturn('');\n        $this->assertEquals('http://example.com/sample_news/author/view/id/1', $this->urlModel->getAuthorUrl($author));\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Url::getAuthorUrl()\n     *\n     * with SEF url key: no prefix and no suffix\n     */\n    public function testGetAuthorUrlWithSefNoSuffixNoPrefix()\n    {\n        $author = $this->setUpAuthor(true);\n\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        Url::URL_PREFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        ''\n                    ],\n                    [\n                        Url::URL_SUFFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        ''\n                    ],\n                ]\n            );\n        $this->assertEquals('http://example.com/' . self::ITEM_URL_KEY, $this->urlModel->getAuthorUrl($author));\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Url::getAuthorUrl()\n     *\n     * with SEF url key: with prefix and no suffix\n     */\n    public function testGetAuthorUrlWithSefNoSuffixWithPrefix()\n    {\n        $author = $this->setUpAuthor(true);\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        Url::URL_PREFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        'author'\n                    ],\n                    [\n                        Url::URL_SUFFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        ''\n                    ],\n                ]\n            );\n        $this->assertEquals('http://example.com/author/' . self::ITEM_URL_KEY, $this->urlModel->getAuthorUrl($author));\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Url::getAuthorUrl()\n     *\n     * with SEF url key: no prefix and with suffix\n     */\n    public function testGetAuthorUrlWithSefWithSuffixNoPrefix()\n    {\n        $author = $this->setUpAuthor(true);\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        Url::URL_PREFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        ''\n                    ],\n                    [\n                        Url::URL_SUFFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        'html'\n                    ],\n                ]\n            );\n        $this->assertEquals('http://example.com/' . self::ITEM_URL_KEY . '.html', $this->urlModel->getAuthorUrl($author));\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author\\Url::getAuthorUrl()\n     *\n     * with SEF url key: with prefix and with suffix\n     */\n    public function testGetAuthorUrlWithSefWithSuffixWithPrefix()\n    {\n        $author = $this->setUpAuthor(true);\n        $this->scopeConfigMock->expects($this->any())\n            ->method('getValue')\n            ->willReturnMap(\n                [\n                    [\n                        Url::URL_PREFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        'author'\n                    ],\n                    [\n                        Url::URL_SUFFIX_CONFIG_PATH,\n                        ScopeInterface::SCOPE_STORE,\n                        null,\n                        'html'\n                    ],\n                ]\n            );\n        $this->assertEquals('http://example.com/author/' . self::ITEM_URL_KEY . '.html', $this->urlModel->getAuthorUrl($author));\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Model/AuthorTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Model;\n\nuse Magento\\Framework\\Filter\\FilterManager;\nuse Magento\\Framework\\Model\\Context;\nuse Magento\\Framework\\Registry;\nuse Magento\\Framework\\TestFramework\\Unit\\Helper\\ObjectManager;\nuse Sample\\News\\Model\\Author;\nuse Sample\\News\\Model\\Author\\Url;\nuse Sample\\News\\Model\\Output;\nuse Sample\\News\\Model\\Uploader;\nuse Sample\\News\\Model\\UploaderPool;\n\nclass AuthorTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @var ObjectManager\n     */\n    protected $objectManager;\n    /**\n     * @var Author\n     */\n    protected $authorModel;\n\n    /**\n     * setup mocks\n     */\n    protected function setUp()\n    {\n        $this->objectManager = new ObjectManager($this);\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Output $outputMock */\n        $outputMock = $this->getMockBuilder(Output::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject||UploaderPool $uploaderPoolMock */\n        $uploaderPoolMock = $this->getMockBuilder(UploaderPool::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Uploader $uploaderMock */\n        $uploaderMock = $this->getMockBuilder(Uploader::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        $uploaderMock->method('getBaseUrl')->willReturn('http://example/com/');\n        $uploaderMock->method('getBasePath')->willReturn('base/path');\n        $uploaderPoolMock->method('getUploader')->willReturn($uploaderMock);\n\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Context $contextMock */\n        $contextMock = $this->getMockBuilder(Context::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Registry $registryMock */\n        $registryMock = $this->getMockBuilder(Registry::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|FilterManager $filterManagerMock */\n        $filterManagerMock = $this->getMockBuilder(FilterManager::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $filterManagerMock->method('translitUrl')->willReturn('dummy');\n        /** @var \\PHPUnit_Framework_MockObject_MockObject||Url $urlMock */\n        $urlMock = $this->getMockBuilder(Url::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $urlMock->method('getUrl')->willReturn('http://example.com/dummy');\n\n        $this->authorModel = $this->objectManager->getObject(\n            Author::class,\n            [\n                'context' => $contextMock,\n                'registry' => $registryMock,\n                'output' => $outputMock,\n                'uploaderPool' => $uploaderPoolMock,\n                'filterManager' => $filterManagerMock,\n                'url' => $urlMock\n            ]\n        );\n        $data = $this->getAuthorData();\n        $this->authorModel->setData($data);\n    }\n\n    /**\n     * @return array\n     */\n    protected function getAuthorData()\n    {\n        $data = [\n            'name' => 'John Doe',\n            'type' => '1',\n            'awards' => [1, 2],\n            'in_rss' => 1,\n            'is_active' => 1,\n            'country' => 'RO',\n            'biography' => '<p>Some biography</p>',\n            'dob' => '1983-08-18',\n            'url_key' => 'john-doe',\n            'avatar' => '/path/to/avatar.jpg',\n            'resume' => 'path/to/resume.pdf',\n            'created_at' => '2016-06-06 00:12:34',\n            'updated_at' => '2016-06-08 12:34:56',\n            'author_id' => 1,\n            'meta_title' => 'dummy meta title',\n            'meta_description' => 'dummy meta description',\n            'meta_keywords' => 'dummy meta keywords',\n            'store_id' => [0],\n        ];\n        return $data;\n    }\n\n    /**\n     * @test class getters\n     */\n    public function testGetters()\n    {\n        $data = $this->getAuthorData();\n        $this->assertEquals($data['name'], $this->authorModel->getName());\n        $this->assertEquals($data['awards'], $this->authorModel->getAwards());\n        $this->assertEquals($data['in_rss'], $this->authorModel->getInRss());\n        $this->assertEquals($data['is_active'], $this->authorModel->getIsActive());\n        $this->assertEquals($data['is_active'], $this->authorModel->isActive());\n        $this->assertEquals($data['country'], $this->authorModel->getCountry());\n        $this->assertEquals($data['biography'], $this->authorModel->getBiography());\n        $this->assertEquals($data['dob'], $this->authorModel->getDob());\n        $this->assertEquals($data['url_key'], $this->authorModel->getUrlKey());\n        $this->assertEquals($data['avatar'], $this->authorModel->getAvatar());\n        $this->assertEquals($data['resume'], $this->authorModel->getResume());\n        $this->assertEquals($data['created_at'], $this->authorModel->getCreatedAt());\n        $this->assertEquals($data['updated_at'], $this->authorModel->getUpdatedAt());\n        $this->assertEquals($data['meta_title'], $this->authorModel->getMetaTitle());\n        $this->assertEquals($data['meta_description'], $this->authorModel->getMetaDescription());\n        $this->assertEquals($data['meta_keywords'], $this->authorModel->getMetaKeywords());\n        $this->assertEquals($data['store_id'], $this->authorModel->getStoreId());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author::getAvatarUrl()\n     *\n     * with null avatar\n     */\n    public function testGetAvatarUrlWithNull()\n    {\n        $this->authorModel->setAvatar(null);\n        $this->assertFalse($this->authorModel->getAvatarUrl());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author::getAvatarUrl()\n     *\n     * with string avatar\n     */\n    public function testGetAvatarUrlWithString()\n    {\n        $this->authorModel->setAvatar('/avatar.jpg');\n        $this->assertEquals('http://example/com/base/path/avatar.jpg', $this->authorModel->getAvatarUrl());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author::getAvatarUrl()\n     *\n     * with exception\n     */\n    public function testGetAvatarUrlWithException()\n    {\n        $this->authorModel->setAvatar(['dummy']);\n        $this->setExpectedException('\\Exception', __('Something went wrong while getting the avatar url.'));\n        $this->authorModel->getAvatarUrl();\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author::getResumeUrl()\n     *\n     * with null resume\n     */\n    public function testGetResumeUrlWithNull()\n    {\n        $this->authorModel->setResume(null);\n        $this->assertFalse($this->authorModel->getResumeUrl());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author::getResumeUrl()\n     *\n     * with string resume\n     */\n    public function testGetResumeUrlWithString()\n    {\n        $this->authorModel->setResume('/resume.jpg');\n        $this->assertEquals('http://example/com/base/path/resume.jpg', $this->authorModel->getResumeUrl());\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Author::getResumeUrl()\n     *\n     * with exception\n     */\n    public function testGetResumeUrlWithException()\n    {\n        $this->authorModel->setResume(['dummy']);\n        $this->setExpectedException('\\Exception', __('Something went wrong while getting the resume url.'));\n        $this->authorModel->getResumeUrl();\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Model/Source/CountryTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Model\\Source;\n\nuse Magento\\Directory\\Model\\Country as CountryModel;\nuse Magento\\Directory\\Model\\ResourceModel\\Country\\Collection;\nuse Magento\\Directory\\Model\\ResourceModel\\Country\\CollectionFactory;\nuse Magento\\Framework\\TestFramework\\Unit\\Helper\\ObjectManager;\nuse Sample\\News\\Model\\Source\\Country;\n\nclass CountryTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @var ObjectManager\n     */\n    protected $objectManager;\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|CollectionFactory\n     */\n    protected $countryCollectionFactoryMock;\n    /**\n     * @var Country\n     */\n    protected $countryList;\n\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|Collection\n     */\n    protected $countryCollection;\n\n    /**\n     * setup tests\n     */\n    protected function setUp()\n    {\n        $this->objectManager = new ObjectManager($this);\n        $this->countryCollectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $countryMock = $this->getMockBuilder(CountryModel::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $this->countryCollection = $this->objectManager->getCollectionMock(Collection::class, [$countryMock]);\n        $this->countryCollectionFactoryMock->method('create')->willReturn($this->countryCollection);\n\n        $this->countryList = new Country($this->countryCollectionFactoryMock);\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\Source\\Country::toOptionArray result is memoized\n     */\n    public function testMemoizedOptionArray()\n    {\n        $this->countryCollection->method('toOptionArray')->willReturn(['baz' => 'qux']);\n        $this->countryCollection->expects($this->once())->method('toOptionArray');\n        $result1 = $this->countryList->toOptionArray();\n        $result2 = $this->countryList->toOptionArray();\n        $this->assertSame($result1, $result2);\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Model/UploaderPoolTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Model;\n\nuse Magento\\Framework\\DataObject;\nuse Magento\\Framework\\ObjectManagerInterface;\nuse Magento\\Framework\\TestFramework\\Unit\\Helper\\ObjectManager;\nuse Sample\\News\\Model\\Uploader;\nuse Sample\\News\\Model\\UploaderPool;\n\nclass UploaderPoolTest extends \\PHPUnit_Framework_TestCase\n{\n    protected $objectManager;\n    /**\n     * @var UploaderPool\n     */\n    protected $uploaderPool;\n\n    /**\n     * setup tests\n     */\n    protected function setUp()\n    {\n        $this->objectManager = new ObjectManager($this);\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|ObjectManagerInterface $objectManagerMock */\n        $objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Uploader $uploaderMock */\n        $uploaderMock = $this->getMockBuilder(Uploader::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $objectManagerMock->expects($this->any())->method('create')->willReturn($uploaderMock);\n\n        $dataObject = new DataObject();\n\n        $this->uploaderPool = new UploaderPool(\n            $objectManagerMock,\n            [\n                'uploader1' => Uploader::class,\n                'uploader2' => $uploaderMock,\n                'uploader3' => $dataObject\n            ]\n        );\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\UploaderPool::getUploader() when uploader is not found\n     * @throws \\Exception\n     */\n    public function testGetUploaderNotFound()\n    {\n        $type = 'test';\n        $this->setExpectedException('\\Exception', \"Uploader not found for type: \".$type);\n        $this->uploaderPool->getUploader($type);\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\UploaderPool::getUploader() when instantiation is needed\n     * @throws \\Exception\n     */\n    public function testGetUploaderInstantiationNeeded()\n    {\n        $type = 'uploader1';\n        $this->assertInstanceOf(Uploader::class, $this->uploaderPool->getUploader($type));\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\UploaderPool::getUploader() when instantiation is not needed\n     * @throws \\Exception\n     */\n    public function testGetUploaderInstantiationNotNeeded()\n    {\n        $type = 'uploader2';\n        $this->assertInstanceOf(Uploader::class, $this->uploaderPool->getUploader($type));\n    }\n\n    /**\n     * @test \\Sample\\News\\Model\\UploaderPool::getUploader() with wrong type returned\n     * @throws \\Exception\n     */\n    public function testGetUploaderWrongType()\n    {\n        $type = 'uploader3';\n        $this->setExpectedException('\\Exception', \"Uploader for type {$type} not instance of \".Uploader::class);\n        $this->uploaderPool->getUploader($type);\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Model/UploaderTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Model;\n\n\nuse Magento\\Framework\\Filesystem;\nuse Magento\\Framework\\Filesystem\\Directory\\WriteInterface;\nuse Magento\\MediaStorage\\Helper\\File\\Storage\\Database;\nuse Magento\\MediaStorage\\Model\\File\\Uploader;\nuse Magento\\MediaStorage\\Model\\File\\UploaderFactory;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Magento\\Store\\Model\\Store;\nuse Psr\\Log\\LoggerInterface;\nuse Sample\\News\\Model\\Uploader as UploaderModel;\n\nclass UploaderTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @var string\n     *\n     * dummy base path\n     */\n    const BASE_PATH = 'base/path';\n\n    /**\n     * @var string\n     *\n     * dummy base tmp path\n     */\n    const BASE_TMP_PATH = 'base/tmp/path';\n\n    /**\n     * @var \\Sample\\News\\Model\\Uploader\n     */\n    protected $uploader;\n\n    /**\n     * setup tests\n     */\n    protected function setUp()\n    {\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Database $coreFileStorageDatabaseMock */\n        $coreFileStorageDatabaseMock = $this->getMockBuilder(Database::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $coreFileStorageDatabaseMock->method('copyFile')->willReturn($coreFileStorageDatabaseMock);\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Filesystem $fileSystemMock */\n        $fileSystemMock = $this->getMockBuilder(Filesystem::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|WriteInterface $writeInterfaceMock */\n        $writeInterfaceMock = $this->getMockBuilder(WriteInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $writeInterfaceMock->method('renameFile')->willReturn($writeInterfaceMock);\n        $fileSystemMock->method('getDirectoryWrite')->willReturn($writeInterfaceMock);\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|UploaderFactory $uploaderFactoryMock */\n        $uploaderFactoryMock = $this->getMockBuilder(UploaderFactory::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Uploader $uploaderMock */\n        $uploaderMock = $this->getMockBuilder(Uploader::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $uploaderMock->method('save')->willReturn([\n            'file' => 'file.ext',\n            'tmp_name' => 'file.ext',\n            'path' => 'path'\n        ]);\n\n        $uploaderFactoryMock->method('create')->willReturn($uploaderMock);\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|StoreManagerInterface $storeManagerMock */\n        $storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Store $storeMock */\n        $storeMock = $this->getMockBuilder(Store::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $storeMock->method('getBaseUrl')->willReturn('http://example.com/');\n        $storeManagerMock->method('getStore')->willReturn($storeMock);\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|LoggerInterface $loggerMock */\n        $loggerMock = $this->getMockBuilder(LoggerInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        $this->uploader = new UploaderModel(\n            $coreFileStorageDatabaseMock,\n            $fileSystemMock,\n            $uploaderFactoryMock,\n            $storeManagerMock,\n            $loggerMock,\n            [],\n            self::BASE_TMP_PATH,\n            self::BASE_PATH\n        );\n    }\n\n    /**\n     * @test Sample\\News\\Model\\Uploader::getBaseTmpPath()\n     */\n    public function testGetBaseTmpPath()\n    {\n        $this->assertEquals(self::BASE_TMP_PATH, $this->uploader->getBaseTmpPath());\n    }\n\n    /**\n     * @test Sample\\News\\Model\\Uploader::getBasePath\n     */\n    public function testGetBasePath()\n    {\n        $this->assertEquals(self::BASE_PATH, $this->uploader->getBasePath());\n    }\n\n    /**\n     * @test Sample\\News\\Model\\Uploader::getAllowedExtensions\n     */\n    public function testGetAllowedExtensions()\n    {\n        $this->assertEquals([], $this->uploader->getAllowedExtensions());\n        $this->uploader->setAllowedExtensions(['ext']);\n        $this->assertEquals(['ext'], $this->uploader->getAllowedExtensions());\n    }\n\n    /**\n     * @test Sample\\News\\Model\\Uploader::getFilePath\n     */\n    public function testGetFilePath()\n    {\n        $this->assertEquals('path/here/file.ext', $this->uploader->getFilePath('path/here/', '/file.ext'));\n        $this->assertEquals('path/here/file.ext', $this->uploader->getFilePath('path/here', '/file.ext'));\n        $this->assertEquals('path/here/file.ext', $this->uploader->getFilePath('path/here/', 'file.ext'));\n        $this->assertEquals('path/here/file.ext', $this->uploader->getFilePath('path/here', 'file.ext'));\n    }\n\n    /**\n     * @test Sample\\News\\Model\\Uploader::moveFileFromTmp\n     */\n    public function testMoveFileFromTmp()\n    {\n        $this->assertEquals('dummy', $this->uploader->moveFileFromTmp('dummy'));\n    }\n\n    /**\n     * @test Sample\\News\\Model\\Uploader::saveFileToTmpDir\n     */\n    public function testSaveFileToTmpDir()\n    {\n        $expected = [\n            'file' => 'file.ext',\n            'tmp_name' => 'file.ext',\n            'path' => 'path',\n            'url' => 'http://example.com/base/tmp/path/file.ext'\n        ];\n        $this->assertEquals($expected, $this->uploader->saveFileToTmpDir('dummy'));\n    }\n\n    /**\n     * @test Sample\\News\\Model\\Uploader::uploadFileAndGetName\n     */\n    public function testUploadFileAndGetName()\n    {\n        $data = [];\n        $this->assertEmpty($this->uploader->uploadFileAndGetName('dummy', $data));\n        $data = [\n            'dummy' => [\n                'delete' => 1,\n                'dummy1' => [\n                    'data1', 'data2'\n                ]\n            ]\n        ];\n        $this->assertEmpty($this->uploader->uploadFileAndGetName('dummy', $data));\n        $data = [\n            'dummy' => [\n                [\n                    'name' => 'file.ext',\n                    'tmp_name' => 'dummy',\n                    'file' => 'file.ext'\n                ]\n            ]\n        ];\n        $this->assertEquals('file.ext', $this->uploader->uploadFileAndGetName('dummy', $data));\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Ui/Component/Listing/Column/AuthorActionsTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Ui\\Component\\Listing\\Column;\n\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Framework\\View\\Element\\UiComponentFactory;\nuse Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface;\nuse Magento\\Framework\\View\\Element\\UiComponent\\Processor;\nuse Sample\\News\\Ui\\Component\\Listing\\Column\\AuthorActions;\n\nclass AuthorActionsTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @test Sample\\News\\Ui\\Component\\Listing\\Column\\AuthorActions::prepareDataSource()\n     */\n    public function testPrepareDataSource()\n    {\n        $authorId = 1;\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|UrlInterface $urlBuilderMock */\n        $urlBuilderMock = $this->getMockBuilder(UrlInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|ContextInterface $contextMock */\n        $contextMock = $this->getMockBuilder(ContextInterface::class)\n            ->getMockForAbstractClass();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Processor $processor */\n        $processor = $this->getMockBuilder(Processor::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor);\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|UiComponentFactory $uiComponentFactoryMock */\n        $uiComponentFactoryMock = $this->getMockBuilder(UiComponentFactory::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        /** @var \\Sample\\News\\Ui\\Component\\Listing\\Column\\AuthorActions $actions */\n        $actions = new AuthorActions($contextMock, $uiComponentFactoryMock, $urlBuilderMock);\n        // Define test input and expectations\n        $items = [\n            'data' => [\n                'items' => [\n                    [\n                        'author_id' => $authorId\n                    ]\n                ]\n            ]\n        ];\n        $name = 'item_name';\n        $expectedItems = [\n            [\n                'author_id' => $authorId,\n                $name => [\n                    'edit' => [\n                        'href' => 'some/url/edit',\n                        'label' => __('Edit'),\n                    ],\n                    'delete' => [\n                        'href' => 'some/url/delete',\n                        'label' => __('Delete'),\n                        'confirm' => [\n                            'title' => __('Delete \"${ $.$data.name }\"'),\n                            'message' => __('Are you sure you wan\\'t to delete the Author \"${ $.$data.name }\" ?')\n                        ],\n                    ]\n                ],\n            ]\n        ];\n\n        // Configure mocks and object data\n        $urlBuilderMock->expects($this->any())\n            ->method('getUrl')\n            ->willReturnMap(\n                [\n                    [\n                        AuthorActions::URL_PATH_EDIT,\n                        [\n                            'author_id' => $authorId\n                        ],\n                        'some/url/edit',\n                    ],\n                    [\n                        AuthorActions::URL_PATH_DELETE,\n                        [\n                            'author_id' => $authorId\n                        ],\n                        'some/url/delete',\n                    ],\n                ]\n            );\n\n        $actions->setName($name);\n        $items = $actions->prepareDataSource($items);\n        // Run test\n        $this->assertEquals($expectedItems, $items['data']['items']);\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Ui/Component/Listing/Column/AvatarTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n\nnamespace Sample\\News\\Test\\Unit\\Ui\\Component\\Listing\\Column;\n\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Framework\\View\\Element\\UiComponentFactory;\nuse Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface;\nuse Magento\\Framework\\View\\Element\\UiComponent\\Processor;\nuse Sample\\News\\Model\\Uploader;\nuse Sample\\News\\Ui\\Component\\Listing\\Column\\AuthorActions;\nuse Sample\\News\\Ui\\Component\\Listing\\Column\\Avatar;\n\nclass AvatarTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @test \\Sample\\News\\Ui\\Component\\Listing\\Column\\Avatar::prepareDataSource()\n     */\n    public function testPrepareDataSource()\n    {\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|ContextInterface $contextMock */\n        $contextMock = $this->getMockBuilder(ContextInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|UiComponentFactory $uiComponentFactoryMock */\n        $uiComponentFactoryMock = $this->getMockBuilder(UiComponentFactory::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|UrlInterface $urlBuilderMock */\n        $urlBuilderMock = $this->getMockBuilder(UrlInterface::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        /** @var \\PHPUnit_Framework_MockObject_MockObject|Uploader $uploaderMock */\n        $uploaderMock = $this->getMockBuilder(Uploader::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $uploaderMock->method('getBasePath')->willReturn('/base/path');\n        $uploaderMock->method('getBaseUrl')->willReturn('http://example.com');\n        $processor = $this->getMockBuilder(Processor::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $contextMock->expects($this->any())->method('getProcessor')->willReturn($processor);\n\n        /** @var \\Sample\\News\\Ui\\Component\\Listing\\Column\\Avatar $avatarModel */\n        $avatarModel = new Avatar($contextMock, $uiComponentFactoryMock, $urlBuilderMock, $uploaderMock, [], []);\n        $authorId = 1;\n        $urlBuilderMock\n            ->method('getUrl')\n            ->willReturnMap(\n                [\n                    [\n                        AuthorActions::URL_PATH_EDIT,\n                        [\n                            'author_id' => $authorId\n                        ],\n                        'some/url/here',\n                    ],\n                ]\n            );\n        $fieldName = 'avatar';\n        $avatarModel->setName($fieldName);\n        $items = [\n            'data' => [\n                'items' => [\n                    [\n                        'author_id' => $authorId,\n                        $fieldName => '/some/image.jpg',\n                        'name' => 'test name',\n                    ]\n                ]\n            ]\n        ];\n        $expectedResult = [\n            'data' => [\n                'items' => [\n                    [\n                        'author_id' => $authorId,\n                        $fieldName => '/some/image.jpg',\n                        'name' => 'test name',\n                        $fieldName . '_src' => 'http://example.com/base/path/some/image.jpg',\n                        $fieldName . '_alt' => 'test name',\n                        $fieldName . '_link' => 'some/url/here',\n                        $fieldName . '_orig_src' => 'http://example.com/base/path/some/image.jpg'\n                    ]\n                ]\n            ]\n        ];\n        $items = $avatarModel->prepareDataSource($items);\n        $this->assertEquals($expectedResult, $items);\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Ui/Component/Listing/Column/Store/OptionsTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Ui\\Component\\Listing\\Column\\Store;\n\nuse Magento\\Framework\\Escaper;\nuse Magento\\Store\\Model\\Group;\nuse Magento\\Store\\Model\\Store as StoreModel;\nuse Magento\\Store\\Model\\System\\Store;\nuse Magento\\Store\\Model\\Website;\nuse Sample\\News\\Ui\\Component\\Listing\\Column\\Store\\Options;\n\nclass OptionsTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|Options\n     */\n    protected $options;\n\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|Store\n     */\n    protected $systemStoreMock;\n\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|Website\n     */\n    protected $websiteMock;\n\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|Group\n     */\n    protected $groupMock;\n\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|StoreModel\n     */\n    protected $storeMock;\n\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|Escaper\n     */\n    protected $escaperMock;\n\n    /**\n     * setup tests\n     */\n    protected function setUp()\n    {\n\n        $this->systemStoreMock = $this->getMockBuilder(Store::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n        $this->websiteMock = $this->getMock(\n            Website::class,\n            ['getId', 'getName'],\n            [],\n            '',\n            false\n        );\n        $this->groupMock = $this->getMock(Group::class, [], [], '', false);\n        $this->storeMock = $this->getMock(StoreModel::class, [], [], '', false);\n        $this->escaperMock = $this->getMock(Escaper::class, [], [], '', false);\n        $this->options = new Options($this->systemStoreMock, $this->escaperMock);\n    }\n\n    /**\n     * @test Sample\\News\\Ui\\Component\\Listing\\Column\\Store\\Options::toOptionArray()\n     */\n    public function testToOptionArray()\n    {\n        $websiteCollection = [$this->websiteMock];\n        $groupCollection = [$this->groupMock];\n        $storeCollection = [$this->storeMock];\n\n        $expectedOptions = [\n            [\n                'label' => __('All Store Views'),\n                'value' => '0'\n            ],\n            [\n                'label' => 'Main Website',\n                'value' => [\n                    [\n                        'label' => '    Main Website Store',\n                        'value' => [\n                            [\n                                'label' => '        Default Store View',\n                                'value' => '1'\n                            ]\n                        ]\n                    ]\n                ]\n            ]\n        ];\n\n        $this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn($websiteCollection);\n        $this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn($groupCollection);\n        $this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn($storeCollection);\n\n        $this->websiteMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');\n        $this->websiteMock->expects($this->any())->method('getName')->willReturn('Main Website');\n\n        $this->groupMock->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn('1');\n        $this->groupMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');\n        $this->groupMock->expects($this->atLeastOnce())->method('getName')->willReturn('Main Website Store');\n\n        $this->storeMock->expects($this->atLeastOnce())->method('getGroupId')->willReturn('1');\n        $this->storeMock->expects($this->atLeastOnce())->method('getName')->willReturn('Default Store View');\n        $this->storeMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');\n\n        $this->escaperMock->expects($this->atLeastOnce())->method('escapeHtml')->willReturnMap(\n            [\n                ['Default Store View', null, 'Default Store View'],\n                ['Main Website Store', null, 'Main Website Store'],\n                ['Main Website', null, 'Main Website']\n            ]\n        );\n\n        $this->assertEquals($expectedOptions, $this->options->toOptionArray());\n    }\n}\n"
  },
  {
    "path": "Test/Unit/Ui/DataProvider/Author/Form/Modifier/AuthorDataTest.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Test\\Unit\\Ui\\DataProvider\\Author\\Form\\Modifier;\n\nuse Magento\\Framework\\TestFramework\\Unit\\Helper\\ObjectManager;\nuse Sample\\News\\Model\\Author;\nuse Sample\\News\\Model\\ResourceModel\\Author\\Collection;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory;\nuse Sample\\News\\Ui\\DataProvider\\Author\\Form\\Modifier\\AuthorData;\n\nclass AuthorDataTest extends \\PHPUnit_Framework_TestCase\n{\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|CollectionFactory\n     */\n    protected $collectionFactoryMock;\n    /**\n     * @var \\PHPUnit_Framework_MockObject_MockObject|AuthorData\n     */\n    protected $authorDataModifier;\n    /**\n     * @var ObjectManager\n     */\n    protected $objectManager;\n\n    /**\n     * set up tests\n     */\n    protected function setUp()\n    {\n        $this->objectManager = new ObjectManager($this);\n        $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)\n            ->disableOriginalConstructor()\n            ->getMock();\n\n        $authorData = [\n            'author_id' => 1,\n            'name' => 'test',\n            'avatar' => '/some/image.jpg',\n            'resume' => '/some/file.txt'\n        ];\n\n        $mockAuthor = $this->getMock(\n            Author::class,\n            [],\n            [],\n            '',\n            false\n        );\n        $mockAuthor->method('getData')->willReturn($authorData);\n        $mockAuthor->method('getId')->willReturn($authorData['author_id']);\n        $mockAuthor->method('getAvatarUrl')->willReturn('http://example.com'.$authorData['avatar']);\n        $mockAuthor->method('getAvatar')->willReturn($authorData['avatar']);\n        $mockAuthor->method('getResumeUrl')->willReturn('http://example.com'.$authorData['resume']);\n        $mockAuthor->method('getResume')->willReturn($authorData['resume']);\n\n        $collectionMock = $this->objectManager->getCollectionMock(\n            Collection::class,\n            [$mockAuthor]\n        );\n        $collectionMock->method('getItems')->willReturn([$mockAuthor]);\n        $this->collectionFactoryMock->method('create')->willReturn($collectionMock);\n        $this->authorDataModifier = new AuthorData($this->collectionFactoryMock);\n    }\n\n    /**\n     * @test Sample\\News\\Ui\\DataProvider\\Author\\Form\\Modifier\\AuthorData::AuthorData::modfyMeta()\n     */\n    public function testModifyMeta()\n    {\n        $this->assertEquals(\n            $this->getSampleData(),\n            $this->authorDataModifier->modifyMeta($this->getSampleData())\n        );\n    }\n\n    /**\n     * @test modifyData method\n     */\n    public function testModifiyData()\n    {\n        $expected = [\n            'key' => 'value',\n            '1' => [\n                'author_id' => 1,\n                'name' => 'test',\n                'avatar' => [\n                    0 => [\n                        'name' => '/some/image.jpg',\n                        'url' => 'http://example.com/some/image.jpg'\n                    ]\n                ],\n                'resume' => [\n                    0 => [\n                        'name' => '/some/file.txt',\n                        'url' => 'http://example.com/some/file.txt'\n                    ]\n                ]\n            ]\n        ];\n        $data = $this->authorDataModifier->modifyData($this->getSampleData());\n        $this->assertEquals($expected, $data);\n    }\n\n    /**\n     * @return array\n     */\n    protected function getSampleData()\n    {\n        return ['key' => 'value'];\n    }\n}\n"
  },
  {
    "path": "Ui/Component/Listing/Column/AuthorActions.php",
    "content": "<?php\n/**\n * Sample_News extension\n * NOTICE OF LICENSE\n * \n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE.txt.\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n * \n * @category  Sample\n * @package   Sample_News\n * @copyright Copyright (c) 2015\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n */\nnamespace Sample\\News\\Ui\\Component\\Listing\\Column;\n\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Framework\\View\\Element\\UiComponentFactory;\nuse Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface;\nuse Magento\\Ui\\Component\\Listing\\Columns\\Column;\n\n/**\n * @method AuthorActions setName($name)\n */\nclass AuthorActions extends Column\n{\n    /**\n     * Url path  to edit\n     * \n     * @var string\n     */\n    const URL_PATH_EDIT = 'sample_news/author/edit';\n\n    /**\n     * Url path  to delete\n     * \n     * @var string\n     */\n    const URL_PATH_DELETE = 'sample_news/author/delete';\n\n    /**\n     * URL builder\n     * \n     * @var \\Magento\\Framework\\UrlInterface\n     */\n    protected $_urlBuilder;\n\n    /**\n     * @param ContextInterface $context\n     * @param UiComponentFactory $uiComponentFactory\n     * @param UrlInterface $urlBuilder\n     * @param array $components\n     * @param array $data\n     */\n    public function __construct(\n        ContextInterface $context,\n        UiComponentFactory $uiComponentFactory,\n        UrlInterface $urlBuilder,\n        array $components = [],\n        array $data = []\n    )\n    {\n        $this->_urlBuilder = $urlBuilder;\n        parent::__construct($context, $uiComponentFactory, $components, $data);\n    }\n\n\n    /**\n     * Prepare Data Source\n     *\n     * @param array $dataSource\n     * @return array\n     */\n    public function prepareDataSource(array $dataSource)\n    {\n        if (isset($dataSource['data']['items'])) {\n            foreach ($dataSource['data']['items'] as & $item) {\n                if (isset($item['author_id'])) {\n                    $item[$this->getData('name')] = [\n                        'edit' => [\n                            'href' => $this->_urlBuilder->getUrl(\n                                static::URL_PATH_EDIT,\n                                [\n                                    'author_id' => $item['author_id']\n                                ]\n                            ),\n                            'label' => __('Edit')\n                        ],\n                        'delete' => [\n                            'href' => $this->_urlBuilder->getUrl(\n                                static::URL_PATH_DELETE,\n                                [\n                                    'author_id' => $item['author_id']\n                                ]\n                            ),\n                            'label' => __('Delete'),\n                            'confirm' => [\n                                'title' => __('Delete \"${ $.$data.name }\"'),\n                                'message' => __('Are you sure you wan\\'t to delete the Author \"${ $.$data.name }\" ?')\n                            ]\n                        ]\n                    ];\n                }\n            }\n        }\n        return $dataSource;\n    }\n}\n"
  },
  {
    "path": "Ui/Component/Listing/Column/Avatar.php",
    "content": "<?php\nnamespace Sample\\News\\Ui\\Component\\Listing\\Column;\n\nuse Magento\\Framework\\UrlInterface;\nuse Magento\\Framework\\View\\Element\\UiComponentFactory;\nuse Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface;\nuse Magento\\Store\\Model\\StoreManagerInterface;\nuse Magento\\Ui\\Component\\Listing\\Columns\\Column;\nuse Sample\\News\\Model\\Uploader;\n\n/**\n * @method Avatar setName($name)\n */\nclass Avatar extends Column\n{\n    const ALT_FIELD = 'name';\n\n    /**\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     */\n    protected $storeManager;\n\n    /**\n     * @var \\Sample\\News\\Model\\Uploader\n     */\n    protected $imageModel;\n\n    /**\n     * @param ContextInterface $context\n     * @param UiComponentFactory $uiComponentFactory\n     * @param UrlInterface $urlBuilder\n     * @param \\Sample\\News\\Model\\Uploader $imageModel\n     * @param array $components\n     * @param array $data\n     */\n    public function __construct(\n        ContextInterface $context,\n        UiComponentFactory $uiComponentFactory,\n        UrlInterface $urlBuilder,\n        Uploader $imageModel,\n        array $components = [],\n        array $data = []\n    ) {\n        $this->imageModel = $imageModel;\n        $this->urlBuilder = $urlBuilder;\n        parent::__construct($context, $uiComponentFactory, $components, $data);\n    }\n\n    /**\n     * Prepare Data Source\n     *\n     * @param array $dataSource\n     * @return array\n     */\n    public function prepareDataSource(array $dataSource)\n    {\n        if(isset($dataSource['data']['items'])) {\n            $fieldName = $this->getData('name');\n            foreach($dataSource['data']['items'] as & $item) {\n                $url = '';\n                if($item[$fieldName] != '') {\n                    $url = $this->imageModel->getBaseUrl().$this->imageModel->getBasePath().$item[$fieldName];\n                }\n                $item[$fieldName . '_src'] = $url;\n                $item[$fieldName . '_alt'] = $this->getAlt($item) ?: '';\n                $item[$fieldName . '_link'] = $this->urlBuilder->getUrl(\n                    'sample_news/author/edit',\n                    ['author_id' => $item['author_id']]\n                );\n                $item[$fieldName . '_orig_src'] = $url;\n            }\n        }\n\n        return $dataSource;\n    }\n\n    /**\n     * @param array $row\n     *\n     * @return null|string\n     */\n    protected function getAlt($row)\n    {\n        $altField = $this->getData('config/altField') ?: self::ALT_FIELD;\n        return isset($row[$altField]) ? $row[$altField] : null;\n    }\n}\n"
  },
  {
    "path": "Ui/Component/Listing/Column/Store/Options.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\nnamespace Sample\\News\\Ui\\Component\\Listing\\Column\\Store;\n\nuse Magento\\Store\\Ui\\Component\\Listing\\Column\\Store\\Options as StoreOptions;\n\nclass Options extends StoreOptions\n{\n    /**\n     * All Store Views value\n     */\n    const ALL_STORE_VIEWS = '0';\n\n    /**\n     * Get options\n     *\n     * @return array\n     */\n    public function toOptionArray()\n    {\n        if ($this->options !== null) {\n            return $this->options;\n        }\n\n        $this->currentOptions['All Store Views']['label'] = __('All Store Views');\n        $this->currentOptions['All Store Views']['value'] = self::ALL_STORE_VIEWS;\n\n        $this->generateCurrentOptions();\n\n        $this->options = array_values($this->currentOptions);\n\n        return $this->options;\n    }\n}\n"
  },
  {
    "path": "Ui/DataProvider/Author/Form/Modifier/AuthorData.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n\nnamespace Sample\\News\\Ui\\DataProvider\\Author\\Form\\Modifier;\n\nuse Magento\\Ui\\DataProvider\\Modifier\\ModifierInterface;\nuse Sample\\News\\Model\\ResourceModel\\Author\\CollectionFactory;\n\nclass AuthorData implements ModifierInterface\n{\n    /**\n     * @var \\Sample\\News\\Model\\ResourceModel\\Author\\Collection\n     */\n    protected $collection;\n\n    /**\n     * @param CollectionFactory $authorCollectionFactory\n     */\n    public function __construct(\n        CollectionFactory $authorCollectionFactory\n    ) {\n        $this->collection = $authorCollectionFactory->create();\n    }\n\n    /**\n     * @param array $meta\n     * @return array\n     */\n    public function modifyMeta(array $meta)\n    {\n        return $meta;\n    }\n\n    /**\n     * @param array $data\n     * @return array|mixed\n     * @throws \\Magento\\Framework\\Exception\\LocalizedException\n     */\n    public function modifyData(array $data)\n    {\n        $items = $this->collection->getItems();\n        /** @var $author \\Sample\\News\\Model\\Author */\n        foreach ($items as $author) {\n            $_data = $author->getData();\n            if (isset($_data['avatar'])) {\n                $avatar = [];\n                $avatar[0]['name'] = $author->getAvatar();\n                $avatar[0]['url'] = $author->getAvatarUrl();\n                $_data['avatar'] = $avatar;\n            }\n            if (isset($_data['resume'])) {\n                $resume = [];\n                $resume[0]['name'] = $author->getResume();\n                $resume[0]['url'] = $author->getResumeUrl();\n                $_data['resume'] = $resume;\n            }\n            $author->setData($_data);\n            $data[$author->getId()] = $_data;\n        }\n        return $data;\n    }\n}\n"
  },
  {
    "path": "composer.json",
    "content": "{\n  \"name\": \"sample/module-news\",\n  \"description\": \"Magento 2 Sample crud module\",\n  \"version\": \"2.0.0\",\n  \"license\": \"MIT\",\n  \"require\": {\n    \"php\": \"~5.6.0|7.0.2|~7.0.6\",\n    \"magento/module-backend\": \"100.1.*\",\n    \"magento/module-cms\": \"101.0.*\",\n    \"magento/module-ui\": \"100.1.*\",\n    \"magento/module-store\": \"100.1.*\",\n    \"magento/framework\": \"100.1.*\",\n    \"magento/module-media-storage\": \"100.1.*\",\n    \"magento/module-directory\": \"100.1.*\",\n    \"magento/module-customer\": \"100.1.*\",\n    \"magento/module-rss\": \"100.1.*\"\n  },\n  \"type\": \"magento2-module\",\n  \"repositories\": [\n    {\n      \"type\": \"git\",\n      \"url\": \"https://github.com/tzyganu/Magento2SampleModule\"\n    }\n  ],\n  \"autoload\": {\n    \"files\": [\n      \"registration.php\"\n    ],\n    \"psr-4\": {\n      \"Sample\\\\News\\\\\": \"\"\n    }\n  }\n}\n"
  },
  {
    "path": "etc/acl.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Acl/etc/acl.xsd\">\n    <acl>\n        <resources>\n            <resource id=\"Magento_Backend::admin\">\n                <resource id=\"Sample_News::news\" title=\"News\" sortOrder=\"100\">\n                    <resource id=\"Sample_News::author\" title=\"Authors\" sortOrder=\"10\" />\n                </resource>\n                <resource id=\"Magento_Backend::stores\">\n                    <resource id=\"Magento_Backend::stores_settings\">\n                        <resource id=\"Magento_Config::config\">\n                            <resource id=\"Sample_News::news_config\" title=\"News Section\" />\n                        </resource>\n                    </resource>\n                </resource>\n            </resource>\n        </resources>\n    </acl>\n</config>\n"
  },
  {
    "path": "etc/adminhtml/di.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager/etc/config.xsd\">\n    <virtualType name=\"SampleNewsUiDataProviderAuthorFormModifierPool\" type=\"Magento\\Ui\\DataProvider\\Modifier\\Pool\">\n        <arguments>\n            <argument name=\"modifiers\" xsi:type=\"array\">\n                <item name=\"author_data\" xsi:type=\"array\">\n                    <item name=\"class\" xsi:type=\"string\">Sample\\News\\Ui\\DataProvider\\Author\\Form\\Modifier\\AuthorData</item>\n                    <item name=\"sortOrder\" xsi:type=\"number\">10</item>\n                </item>\n            </argument>\n        </arguments>\n    </virtualType>\n    <type name=\"Sample\\News\\Model\\Author\\DataProvider\">\n        <arguments>\n            <argument name=\"pool\" xsi:type=\"object\">SampleNewsUiDataProviderAuthorFormModifierPool</argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Controller\\Adminhtml\\Author\\MassDelete\">\n        <arguments>\n            <argument name=\"successMessage\" xsi:type=\"string\" translate=\"true\">A total of %1 record(s) have been deleted.</argument>\n            <argument name=\"errorMessage\" xsi:type=\"string\" translate=\"true\">An error occurred while deleting record(s).</argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Controller\\Adminhtml\\Author\\MassDisable\">\n        <arguments>\n            <argument name=\"successMessage\" xsi:type=\"string\" translate=\"true\">A total of %1 authors have been disabled.</argument>\n            <argument name=\"errorMessage\" xsi:type=\"string\" translate=\"true\">An error occurred while disabling authors.</argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Controller\\Adminhtml\\Author\\MassEnable\">\n        <arguments>\n            <argument name=\"successMessage\" xsi:type=\"string\" translate=\"true\">A total of %1 authors have been enabled.</argument>\n            <argument name=\"errorMessage\" xsi:type=\"string\" translate=\"true\">An error occurred while enabling authors.</argument>\n        </arguments>\n    </type>\n</config>\n"
  },
  {
    "path": "etc/adminhtml/menu.xml",
    "content": "<?xml version=\"1.0\"?>\r\n<!--\r\n/**\r\n * Sample_News extension\r\n *\r\n * NOTICE OF LICENSE\r\n *\r\n * This source file is subject to the MIT License\r\n * that is bundled with this package in the file LICENSE\r\n * It is also available through the world-wide-web at this URL:\r\n * http://opensource.org/licenses/mit-license.php\r\n *\r\n * @category  Sample\r\n * @package   Sample_News\r\n * @copyright 2016 Marius Strajeru\r\n * @license   http://opensource.org/licenses/mit-license.php MIT License\r\n * @author    Marius Strajeru\r\n */\r\n-->\r\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Backend:etc/menu.xsd\">\r\n    <menu>\r\n        <add id=\"Sample_News::news\" title=\"News\" module=\"Sample_News\" sortOrder=\"65\" resource=\"Sample_News::news\"/>\r\n        <add id=\"Sample_News::author\" title=\"Authors\" module=\"Sample_News\" sortOrder=\"10\"\r\n             action=\"sample_news/author\" resource=\"Sample_News::author\" parent=\"Sample_News::news\" />\r\n    </menu>\r\n</config>\r\n"
  },
  {
    "path": "etc/adminhtml/routes.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:App/etc/routes.xsd\">\n    <router id=\"admin\">\n        <route id=\"sample_news\" frontName=\"sample_news\">\n            <module name=\"Sample_News\" before=\"Magento_Backend\" />\n        </route>\n    </router>\n</config>\n"
  },
  {
    "path": "etc/adminhtml/system.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Config:etc/system_file.xsd\">\n    <system>\n        <tab id=\"sample_news\" sortOrder=\"2000\">\n            <label>News</label>\n        </tab>\n        <section id=\"sample_news\" type=\"text\" sortOrder=\"10\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\">\n            <label>News</label>\n            <tab>sample_news</tab>\n            <resource>Sample_News::news</resource>\n            <group id=\"author\" type=\"text\" sortOrder=\"10\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\">\n                <label>Authors</label>\n                <field id=\"breadcrumbs\" type=\"select\" sortOrder=\"10\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Enable Breadcrumbs</label>\n                    <source_model>Magento\\Config\\Model\\Config\\Source\\Yesno</source_model>\n                </field>\n                <field id=\"meta_title\" type=\"text\" sortOrder=\"20\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Author list meta title</label>\n                </field>\n                <field id=\"meta_description\" type=\"textarea\" sortOrder=\"30\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Author list meta description</label>\n                </field>\n                <field id=\"meta_keywords\" type=\"textarea\" sortOrder=\"40\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Author list meta keywords</label>\n                </field>\n                <field id=\"list_url\" type=\"text\" sortOrder=\"50\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Author list url</label>\n                </field>\n                <field id=\"url_prefix\" type=\"text\" sortOrder=\"60\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Author url prefix</label>\n                </field>\n                <field id=\"url_suffix\" type=\"text\" sortOrder=\"70\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Author url suffix</label>\n                </field>\n                <field id=\"rss\" type=\"select\" sortOrder=\"80\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>Enable RSS</label>\n                    <source_model>Magento\\Config\\Model\\Config\\Source\\Yesno</source_model>\n                </field>\n                <field id=\"rss_cache\" type=\"text\" sortOrder=\"90\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\" canRestore=\"1\">\n                    <label>RSS Cache Lifetime</label>\n                    <comment>in seconds</comment>\n                </field>\n            </group>\n        </section>\n    </system>\n</config>\n"
  },
  {
    "path": "etc/config.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Store:etc/config.xsd\">\n    <default>\n        <sample_news>\n            <author>\n                <breadcrumbs>1</breadcrumbs>\n                <meta_title>Authors</meta_title>\n                <meta_description>Authors Description Here</meta_description>\n                <meta_keywords>Authors Keywords Here</meta_keywords>\n                <list_url>authors.html</list_url>\n                <url_prefix>author</url_prefix>\n                <url_suffix>html</url_suffix>\n                <rss>1</rss>\n                <rss_cache>600</rss_cache>\n            </author>\n        </sample_news>\n    </default>\n</config>\n"
  },
  {
    "path": "etc/di.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager/etc/config.xsd\">\n    <preference for=\"Sample\\News\\Api\\AuthorRepositoryInterface\" type=\"Sample\\News\\Model\\AuthorRepository\" />\n    <preference for=\"Sample\\News\\Api\\Data\\AuthorInterface\" type=\"Sample\\News\\Model\\Author\" />\n    <type name=\"Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\CollectionFactory\">\n        <arguments>\n            <argument name=\"collections\" xsi:type=\"array\">\n                <item name=\"sample_news_author_listing_data_source\" xsi:type=\"string\">Sample\\News\\Model\\ResourceModel\\Author\\Grid\\Collection</item>\n            </argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Model\\ResourceModel\\Author\\Grid\\Collection\">\n        <arguments>\n            <argument name=\"mainTable\" xsi:type=\"string\">sample_news_author</argument>\n            <argument name=\"eventPrefix\" xsi:type=\"string\">sample_news_author_grid_collection</argument>\n            <argument name=\"eventObject\" xsi:type=\"string\">author_grid_collection</argument>\n            <argument name=\"resourceModel\" xsi:type=\"string\">Sample\\News\\Model\\ResourceModel\\Author</argument>\n        </arguments>\n    </type>\n    <virtualType name=\"SampleNewsAuthorImageUploader\" type=\"Sample\\News\\Model\\Uploader\">\n        <arguments>\n            <argument name=\"baseTmpPath\" xsi:type=\"const\">Sample\\News\\Model\\Uploader::IMAGE_TMP_PATH</argument>\n            <argument name=\"basePath\" xsi:type=\"const\">Sample\\News\\Model\\Uploader::IMAGE_PATH</argument>\n            <argument name=\"allowedExtensions\" xsi:type=\"array\">\n                <item name=\"jpg\" xsi:type=\"string\">jpg</item>\n                <item name=\"jpeg\" xsi:type=\"string\">jpeg</item>\n                <item name=\"gif\" xsi:type=\"string\">gif</item>\n                <item name=\"png\" xsi:type=\"string\">png</item>\n            </argument>\n        </arguments>\n    </virtualType>\n    <type name=\"Sample\\News\\Controller\\Adminhtml\\Author\\Image\\Upload\">\n        <arguments>\n            <argument name=\"uploader\" xsi:type=\"object\">SampleNewsAuthorImageUploader</argument>\n        </arguments>\n    </type>\n    <virtualType name=\"SampleNewsAuthorFileUploader\" type=\"Sample\\News\\Model\\Uploader\">\n        <arguments>\n            <argument name=\"baseTmpPath\" xsi:type=\"const\">Sample\\News\\Model\\Uploader::FILE_TMP_PATH</argument>\n            <argument name=\"basePath\" xsi:type=\"const\">Sample\\News\\Model\\Uploader::FILE_PATH</argument>\n            <argument name=\"allowedExtensions\" xsi:type=\"array\" />\n        </arguments>\n    </virtualType>\n    <type name=\"Sample\\News\\Controller\\Adminhtml\\Author\\File\\Upload\">\n        <arguments>\n            <argument name=\"uploader\" xsi:type=\"object\">SampleNewsAuthorFileUploader</argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Model\\UploaderPool\">\n        <arguments>\n            <argument name=\"uploaders\" xsi:type=\"array\">\n                <item name=\"image\" xsi:type=\"string\">SampleNewsAuthorImageUploader</item>\n                <item name=\"file\" xsi:type=\"string\">SampleNewsAuthorFileUploader</item>\n            </argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Controller\\Adminhtml\\Author\\Save\">\n        <arguments>\n            <argument name=\"uploaderPool\" xsi:type=\"object\">Sample\\News\\Model\\UploaderPool</argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Model\\Author\">\n        <arguments>\n            <argument name=\"uploaderPool\" xsi:type=\"object\">Sample\\News\\Model\\UploaderPool</argument>\n            <argument name=\"optionProviders\" xsi:type=\"array\">\n                <item name=\"awards\" xsi:type=\"object\">SampleNewsModelAuthorSourceAward</item>\n                <item name=\"type\" xsi:type=\"object\">SampleNewsModelAuthorSourceType</item>\n                <item name=\"country\" xsi:type=\"object\">Sample\\News\\Model\\Source\\Country</item>\n            </argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Ui\\Component\\Listing\\Column\\Avatar\">\n        <arguments>\n            <argument name=\"imageModel\" xsi:type=\"object\">SampleNewsAuthorImageUploader</argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Model\\Output\">\n        <arguments>\n            <argument name=\"templateProcessor\" xsi:type=\"object\">Magento\\Widget\\Model\\Template\\Filter</argument>\n        </arguments>\n    </type>\n    <virtualType name=\"SampleNewsModelAuthorSourceAward\" type=\"Sample\\News\\Model\\Source\\Options\">\n        <arguments>\n            <argument name=\"options\" xsi:type=\"array\">\n                <item name=\"1\" xsi:type=\"array\">\n                    <item name=\"value\" xsi:type=\"number\">1</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Award 1</item>\n                </item>\n                <item name=\"2\" xsi:type=\"array\">\n                    <item name=\"value\" xsi:type=\"number\">2</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Award 2</item>\n                </item>\n                <item name=\"3\" xsi:type=\"array\">\n                    <item name=\"value\" xsi:type=\"number\">3</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Award 3</item>\n                </item>\n            </argument>\n        </arguments>\n    </virtualType>\n    <virtualType name=\"SampleNewsModelAuthorSourceType\" type=\"Sample\\News\\Model\\Source\\Options\">\n        <arguments>\n            <argument name=\"options\" xsi:type=\"array\">\n                <item name=\"1\" xsi:type=\"array\">\n                    <item name=\"value\" xsi:type=\"number\">1</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Collaborator</item>\n                </item>\n                <item name=\"2\" xsi:type=\"array\">\n                    <item name=\"value\" xsi:type=\"number\">2</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Employee</item>\n                </item>\n            </argument>\n        </arguments>\n    </virtualType>\n\n    <virtualType name=\"SampleNewsModelAuthorSourceIsActive\" type=\"Sample\\News\\Model\\Source\\Options\">\n        <arguments>\n            <argument name=\"options\" xsi:type=\"array\">\n                <item name=\"1\" xsi:type=\"array\">\n                    <item name=\"value\" xsi:type=\"const\">Sample\\News\\Model\\Author::STATUS_ENABLED</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Yes</item>\n                </item>\n                <item name=\"2\" xsi:type=\"array\">\n                    <item name=\"value\" xsi:type=\"const\">Sample\\News\\Model\\Author::STATUS_DISABLED</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">No</item>\n                </item>\n            </argument>\n        </arguments>\n    </virtualType>\n    <type name=\"Magento\\Framework\\App\\Rss\\RssManagerInterface\">\n        <arguments>\n            <argument name=\"dataProviders\" xsi:type=\"array\">\n                <item name=\"authors\" xsi:type=\"string\">Sample\\News\\Block\\Author\\ListAuthor\\Rss</item>\n            </argument>\n        </arguments>\n    </type>\n    <type name=\"Sample\\News\\Model\\Image\">\n        <arguments>\n            <argument name=\"uploader\" xsi:type=\"object\">SampleNewsAuthorImageUploader</argument>\n        </arguments>\n    </type>\n    <virtualType name=\"SampleNewsBlockAuthorImageBuilder\" type=\"Sample\\News\\Block\\ImageBuilder\">\n        <arguments>\n            <argument name=\"entityCode\" xsi:type=\"string\">author</argument>\n        </arguments>\n    </virtualType>\n    <type name=\"Sample\\News\\Block\\Author\\ViewAuthor\">\n        <arguments>\n            <argument name=\"imageBuilder\" xsi:type=\"object\">SampleNewsBlockAuthorImageBuilder</argument>\n        </arguments>\n    </type>\n</config>\n"
  },
  {
    "path": "etc/frontend/di.xml",
    "content": "<?xml version=\"1.0\"?>\r\n<!--\r\n/**\r\n * Sample_News extension\r\n *\r\n * NOTICE OF LICENSE\r\n *\r\n * This source file is subject to the MIT License\r\n * that is bundled with this package in the file LICENSE\r\n * It is also available through the world-wide-web at this URL:\r\n * http://opensource.org/licenses/mit-license.php\r\n *\r\n * @category  Sample\r\n * @package   Sample_News\r\n * @copyright 2016 Marius Strajeru\r\n * @license   http://opensource.org/licenses/mit-license.php MIT License\r\n * @author    Marius Strajeru\r\n */\r\n-->\r\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager/etc/config.xsd\">\r\n    <type name=\"Magento\\Framework\\App\\RouterList\">\r\n        <arguments>\r\n            <argument name=\"routerList\" xsi:type=\"array\">\r\n                <item name=\"sample_news\" xsi:type=\"array\">\r\n                    <item name=\"class\" xsi:type=\"string\">Sample\\News\\Controller\\Router</item>\r\n                    <item name=\"disable\" xsi:type=\"boolean\">false</item>\r\n                    <item name=\"sortOrder\" xsi:type=\"string\">10</item>\r\n                </item>\r\n            </argument>\r\n        </arguments>\r\n    </type>\r\n    <virtualType name=\"SampleNewsRoutingEntityAuthor\" type=\"Sample\\News\\Model\\Routing\\Entity\">\r\n        <arguments>\r\n            <argument name=\"prefixConfigPath\" xsi:type=\"const\">Sample\\News\\Model\\Author\\Url::URL_PREFIX_CONFIG_PATH</argument>\r\n            <argument name=\"suffixConfigPath\" xsi:type=\"const\">Sample\\News\\Model\\Author\\Url::URL_SUFFIX_CONFIG_PATH</argument>\r\n            <argument name=\"listKeyConfigPath\" xsi:type=\"const\">Sample\\News\\Model\\Author\\Url::LIST_URL_CONFIG_PATH</argument>\r\n            <argument name=\"factory\" xsi:type=\"object\">Sample\\News\\Model\\AuthorFactory</argument>\r\n            <argument name=\"controller\" xsi:type=\"string\">author</argument>\r\n        </arguments>\r\n    </virtualType>\r\n    <type name=\"Sample\\News\\Controller\\Router\">\r\n        <arguments>\r\n            <argument name=\"routingEntities\" xsi:type=\"array\">\r\n                <item name=\"author\" xsi:type=\"object\">SampleNewsRoutingEntityAuthor</item>\r\n            </argument>\r\n        </arguments>\r\n    </type>\r\n    <type name=\"Magento\\Theme\\Block\\Html\\Topmenu\">\r\n        <plugin name=\"authorTopmenu\" type=\"Sample\\News\\Plugin\\Block\\Topmenu\" />\r\n    </type>\r\n</config>\r\n"
  },
  {
    "path": "etc/frontend/routes.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:App/etc/routes.xsd\">\n    <router id=\"standard\">\n        <route id=\"sample_news\" frontName=\"sample_news\">\n            <module name=\"Sample_News\" />\n        </route>\n    </router>\n</config>\n"
  },
  {
    "path": "etc/module.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n-->\n<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Module/etc/module.xsd\">\n    <module name=\"Sample_News\" setup_version=\"2.0.0\">\n        <sequence>\n            <module name=\"Magento_Backend\"/>\n            <module name=\"Magento_Ui\" />\n            <module name=\"Magento_Store\" />\n            <module name=\"Magento_Theme\" />\n            <module name=\"Magento_Customer\" />\n            <module name=\"Magento_Rss\" />\n        </sequence>\n    </module>\n</config>\n"
  },
  {
    "path": "i18l/en_US.csv",
    "content": "\"A total of %1 authors have been disabled.\",\"A total of %1 authors have been disabled.\"\n\"A total of %1 record(s) have been deleted.\",\"A total of %1 record(s) have been deleted.\"\n\"A total of %1 authors have been enabled.\",\"A total of %1 authors have been enabled.\"\n\"Add New Author\",\"Add New Author\"\n\"All Store Views\",\"All Store Views\"\n\"An error occurred while deleting record(s).\",\"An error occurred while deleting record(s).\"\n\"An error occurred while disabling authors.\",\"An error occurred while disabling authors.\"\n\"An error occurred while enabling authors.\",\"An error occurred while enabling authors.\"\n\"Are you sure you want to delete selected items?\",\"Are you sure you want to delete selected items?\"\n\"Are you sure you want to delete the Author \"\"${ $.$data.name }\"\" ?\",\"Are you sure you want to delete the Author \"\"${ $.$data.name }\"\" ?\"\n\"Are you sure you want to do this?\",\"Are you sure you want to do this?\"\n\"Author in Store views\",\"Author in Store views\"\n\"Author Information\",\"Author Information\"\nAuthors,Authors\nAvatar,Avatar\n\"Award 1\",\"Award 1\"\n\"Award 2\",\"Award 2\"\n\"Award 3\",\"Award 3\"\nAwards,Awards\nBack,Back\nBiography,Biography\nCollaborator,Collaborator\n\"Could not save the author: %1\",\"Could not save the author: %1\"\nCountry,Country\n\"Created At\",\"Created At\"\n\"Date of birth\",\"Date of birth\"\nDelete,Delete\n\"Delete Author\",\"Delete Author\"\n\"Delete items\",\"Delete items\"\n\"Delete \"\"${ $.$data.name }\"\"\",\"Delete \"\"${ $.$data.name }\"\"\"\nDisable,Disable\nDOB,DOB\nEdit,Edit\n\"Edit Author\",\"Edit Author\"\nEmployee,Employee\nEnable,Enable\n\"Enter full name here\",\"Enter full name here\"\n\"File can not be saved to the destination folder.\",\"File can not be saved to the destination folder.\"\nHome,Home\nID,ID\n\"In RSS\",\"In RSS\"\n\"Is Active\",\"Is Active\"\nlabel,label\n\"Meta Description\",\"Meta Description\"\n\"Meta Keywords\",\"Meta Keywords\"\n\"Meta Title\",\"Meta Title\"\nName,Name\n\"New Author\",\"New Author\"\nNews,News\nNo,No\n\"Please correct the data sent.\",\"Please correct the data sent.\"\n\"Requested author doesn't exist\",\"Requested author doesn't exist\"\nReset,Reset\nResume,Resume\n\"Save Author\",\"Save Author\"\n\"Save and Continue Edit\",\"Save and Continue Edit\"\n\"Show In RSS\",\"Show In RSS\"\n\"Something went wrong while getting the avatar url.\",\"Something went wrong while getting the avatar url.\"\n\"Something went wrong while getting the resume url.\",\"Something went wrong while getting the resume url.\"\n\"Something went wrong while saving the author.\",\"Something went wrong while saving the author.\"\n\"Something went wrong while saving the file(s).\",\"Something went wrong while saving the file(s).\"\n\"Store View\",\"Store View\"\n\"Subscribe to RSS Feed\",\"Subscribe to RSS Feed\"\n\"There are no authors at this moment\",\"There are no authors at this moment\"\n\"The author has been deleted.\",\"The author has been deleted.\"\n\"The author no longer exists.\",\"The author no longer exists.\"\n\"There was a problem deleting the author\",\"There was a problem deleting the author\"\n\"There was a problem saving the author\",\"There was a problem saving the author\"\nType,Type\n\"Unable to remove author %1\",\"Unable to remove author %1\"\n\"Updated At\",\"Updated At\"\n\"URL Key\",\"URL Key\"\n\"Url Key\",\"Url Key\"\n\"We can't find a author to delete.\",\"We can't find a author to delete.\"\nYes,Yes\n\"You saved the author\",\"You saved the author\"\n"
  },
  {
    "path": "registration.php",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n\\Magento\\Framework\\Component\\ComponentRegistrar::register(\n    \\Magento\\Framework\\Component\\ComponentRegistrar::MODULE,\n    'Sample_News',\n    __DIR__\n);\n"
  },
  {
    "path": "view/adminhtml/layout/sample_news_author_edit.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n\n-->\n<page xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" layout=\"admin-1column\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View/Layout/etc/page_configuration.xsd\">\n    <head>\n        <css src=\"jquery/fileUploader/css/jquery.fileupload-ui.css\"/>\n    </head>\n    <body>\n        <referenceContainer name=\"content\">\n            <uiComponent name=\"sample_news_author_form\"/>\n        </referenceContainer>\n    </body>\n</page>\n"
  },
  {
    "path": "view/adminhtml/layout/sample_news_author_index.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n\n-->\n<page xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View/Layout/etc/page_configuration.xsd\">\n    <update handle=\"styles\"/>\n    <body>\n        <referenceBlock name=\"menu\">\n            <action method=\"setActive\">\n                <argument name=\"itemId\" xsi:type=\"string\">Sample_News::authors</argument>\n            </action>\n        </referenceBlock>\n        <referenceBlock name=\"page.title\">\n            <action method=\"setTitleClass\">\n                <argument name=\"class\" xsi:type=\"string\">complex</argument>\n            </action>\n        </referenceBlock>\n        <referenceContainer name=\"content\">\n            <uiComponent name=\"sample_news_author_listing\"/>\n        </referenceContainer>\n    </body>\n</page>\n"
  },
  {
    "path": "view/adminhtml/ui_component/sample_news_author_form.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<form xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc/ui_configuration.xsd\">\n    <argument name=\"data\" xsi:type=\"array\">\n        <item name=\"js_config\" xsi:type=\"array\">\n            <item name=\"provider\" xsi:type=\"string\">sample_news_author_form.author_form_data_source</item>\n            <item name=\"deps\" xsi:type=\"string\">sample_news_author_form.author_form_data_source</item>\n        </item>\n        <item name=\"label\" xsi:type=\"string\" translate=\"true\">Author Information</item>\n        <item name=\"config\" xsi:type=\"array\">\n            <item name=\"dataScope\" xsi:type=\"string\">data</item>\n            <item name=\"namespace\" xsi:type=\"string\">sample_news_author_form</item>\n        </item>\n        <item name=\"template\" xsi:type=\"string\">templates/form/collapsible</item>\n        <item name=\"buttons\" xsi:type=\"array\">\n            <item name=\"back\" xsi:type=\"string\">Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons\\Back</item>\n            <item name=\"delete\" xsi:type=\"string\">Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons\\Delete</item>\n            <item name=\"reset\" xsi:type=\"string\">Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons\\Reset</item>\n            <item name=\"save\" xsi:type=\"string\">Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons\\Save</item>\n            <item name=\"save_and_continue\" xsi:type=\"string\">Sample\\News\\Block\\Adminhtml\\Author\\Edit\\Buttons\\SaveAndContinue</item>\n        </item>\n    </argument>\n    <dataSource name=\"author_form_data_source\">\n        <argument name=\"dataProvider\" xsi:type=\"configurableObject\">\n            <argument name=\"class\" xsi:type=\"string\">Sample\\News\\Model\\Author\\DataProvider</argument>\n            <argument name=\"name\" xsi:type=\"string\">author_form_data_source</argument>\n            <argument name=\"primaryFieldName\" xsi:type=\"string\">author_id</argument>\n            <argument name=\"requestFieldName\" xsi:type=\"string\">author_id</argument>\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"submit_url\" xsi:type=\"url\" path=\"sample_news/author/save\"/>\n                </item>\n            </argument>\n        </argument>\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"js_config\" xsi:type=\"array\">\n                <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/form/provider</item>\n            </item>\n        </argument>\n    </dataSource>\n    <fieldset name=\"author_main\">\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"config\" xsi:type=\"array\">\n                <item name=\"label\" xsi:type=\"string\"/>\n            </item>\n        </argument>\n        <field name=\"author_id\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"visible\" xsi:type=\"boolean\">false</item>\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"formElement\" xsi:type=\"string\">input</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">author_id</item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"name\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Name</item>\n                    <item name=\"formElement\" xsi:type=\"string\">input</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"sortOrder\" xsi:type=\"number\">10</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">name</item>\n                    <item name=\"notice\" xsi:type=\"string\" translate=\"true\">Enter full name here</item>\n                    <item name=\"validation\" xsi:type=\"array\">\n                        <item name=\"required-entry\" xsi:type=\"boolean\">true</item>\n                    </item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"is_active\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">boolean</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Is Active</item>\n                    <item name=\"formElement\" xsi:type=\"string\">checkbox</item>\n                    <item name=\"prefer\" xsi:type=\"string\">toggle</item>\n                    <item name=\"source\" xsi:type=\"string\">page</item>\n                    <item name=\"sortOrder\" xsi:type=\"number\">30</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">is_active</item>\n                    <item name=\"valueMap\" xsi:type=\"array\">\n                        <item name=\"true\" xsi:type=\"number\">1</item>\n                        <item name=\"false\" xsi:type=\"number\">0</item>\n                    </item>\n                    <item name=\"default\" xsi:type=\"number\">1</item>\n                </item>\n            </argument>\n        </field>\n    </fieldset>\n    <fieldset name=\"author\">\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"config\" xsi:type=\"array\">\n                <item name=\"label\" xsi:type=\"string\">Author Information</item>\n                <item name=\"collapsible\" xsi:type=\"boolean\">true</item>\n            </item>\n        </argument>\n        <field name=\"url_key\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">URL Key</item>\n                    <item name=\"formElement\" xsi:type=\"string\">input</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"sortOrder\" xsi:type=\"number\">20</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">url_key</item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"in_rss\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">boolean</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Show In RSS</item>\n                    <item name=\"formElement\" xsi:type=\"string\">checkbox</item>\n                    <item name=\"prefer\" xsi:type=\"string\">toggle</item>\n                    <item name=\"source\" xsi:type=\"string\">page</item>\n                    <item name=\"sortOrder\" xsi:type=\"number\">30</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">in_rss</item>\n                    <item name=\"valueMap\" xsi:type=\"array\">\n                        <item name=\"true\" xsi:type=\"number\">1</item>\n                        <item name=\"false\" xsi:type=\"number\">0</item>\n                    </item>\n                    <item name=\"default\" xsi:type=\"number\">1</item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"biography\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"label\" xsi:type=\"string\"/>\n                    <item name=\"formElement\" xsi:type=\"string\">wysiwyg</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"wysiwyg\" xsi:type=\"boolean\">true</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">biography</item>\n                    <item name=\"additionalClasses\" xsi:type=\"string\">admin__field-wide</item>\n                    <item name=\"validation\" xsi:type=\"array\">\n                        <item name=\"required-entry\" xsi:type=\"boolean\">true</item>\n                    </item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"dob\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">DOB</item>\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"formElement\" xsi:type=\"string\">date</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">dob</item>\n                    <item name=\"validation\" xsi:type=\"array\">\n                        <item name=\"validate-date\" xsi:type=\"boolean\">true</item>\n                    </item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"type\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">SampleNewsModelAuthorSourceType</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Type</item>\n                    <item name=\"formElement\" xsi:type=\"string\">select</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">type</item>\n                    <item name=\"validation\" xsi:type=\"array\">\n                        <item name=\"required-entry\" xsi:type=\"boolean\">true</item>\n                    </item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"awards\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">SampleNewsModelAuthorSourceAward</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Awards</item>\n                    <item name=\"formElement\" xsi:type=\"string\">multiselect</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">awards</item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"avatar\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">string</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Avatar</item>\n                    <item name=\"visible\" xsi:type=\"boolean\">true</item>\n                    <item name=\"formElement\" xsi:type=\"string\">fileUploader</item>\n                    <item name=\"elementTmpl\" xsi:type=\"string\">ui/form/element/uploader/uploader</item>\n                    <item name=\"previewTmpl\" xsi:type=\"string\">Sample_News/image-preview</item>\n                    <item name=\"required\" xsi:type=\"boolean\">false</item>\n                    <item name=\"uploaderConfig\" xsi:type=\"array\">\n                        <item name=\"url\" xsi:type=\"url\" path=\"sample_news/author_image/upload/field/avatar\"/>\n                    </item>\n                </item>\n            </argument>\n        </field>\n\n        <field name=\"resume\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">string</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Resume</item>\n                    <item name=\"visible\" xsi:type=\"boolean\">true</item>\n                    <item name=\"formElement\" xsi:type=\"string\">fileUploader</item>\n                    <item name=\"elementTmpl\" xsi:type=\"string\">ui/form/element/uploader/uploader</item>\n                    <item name=\"previewTmpl\" xsi:type=\"string\">Sample_News/file-preview</item>\n                    <item name=\"required\" xsi:type=\"boolean\">false</item>\n                    <item name=\"uploaderConfig\" xsi:type=\"array\">\n                        <item name=\"url\" xsi:type=\"url\" path=\"sample_news/author_file/upload/field/resume\"/>\n                    </item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"country\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">Sample\\News\\Model\\Source\\Country</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Country</item>\n                    <item name=\"formElement\" xsi:type=\"string\">select</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">country</item>\n                </item>\n            </argument>\n        </field>\n    </fieldset>\n    <fieldset name=\"websites\" class=\"Magento\\Store\\Ui\\Component\\Form\\Fieldset\\Websites\">\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"config\" xsi:type=\"array\">\n                <item name=\"collapsible\" xsi:type=\"boolean\">true</item>\n                <item name=\"label\" xsi:type=\"string\" translate=\"true\">Author in Store views</item>\n                <item name=\"sortOrder\" xsi:type=\"number\">30</item>\n            </item>\n        </argument>\n        <field name=\"storeviews\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">Sample\\News\\Ui\\Component\\Listing\\Column\\Store\\Options</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">int</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Store View</item>\n                    <item name=\"formElement\" xsi:type=\"string\">multiselect</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">store_id</item>\n                    <item name=\"default\" xsi:type=\"string\">0</item>\n                    <item name=\"validation\" xsi:type=\"array\">\n                        <item name=\"required-entry\" xsi:type=\"boolean\">true</item>\n                    </item>\n                </item>\n            </argument>\n        </field>\n    </fieldset>\n    <fieldset name=\"meta\">\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"config\" xsi:type=\"array\">\n                <item name=\"label\" xsi:type=\"string\">Meta</item>\n                <item name=\"collapsible\" xsi:type=\"boolean\">true</item>\n            </item>\n        </argument>\n        <field name=\"meta_title\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Meta Title</item>\n                    <item name=\"formElement\" xsi:type=\"string\">input</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"sortOrder\" xsi:type=\"number\">10</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">meta_title</item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"meta_description\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Meta Description</item>\n                    <item name=\"formElement\" xsi:type=\"string\">textarea</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">meta_description</item>\n                </item>\n            </argument>\n        </field>\n        <field name=\"meta_keywords\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Meta Keywords</item>\n                    <item name=\"formElement\" xsi:type=\"string\">textarea</item>\n                    <item name=\"source\" xsi:type=\"string\">author</item>\n                    <item name=\"dataScope\" xsi:type=\"string\">meta_keywords</item>\n                </item>\n            </argument>\n        </field>\n    </fieldset>\n</form>\n"
  },
  {
    "path": "view/adminhtml/ui_component/sample_news_author_listing.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--\n/**\n * Sample_News extension\n * NOTICE OF LICENSE\n * \n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE.\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n * \n * @category  Sample\n * @package   Sample_News\n * @copyright Copyright (c) 2015\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n */\n-->\n<listing xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc/ui_configuration.xsd\">\n    <argument name=\"data\" xsi:type=\"array\">\n        <item name=\"js_config\" xsi:type=\"array\">\n            <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing_data_source</item>\n            <item name=\"deps\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing_data_source</item>\n        </item>\n        <item name=\"spinner\" xsi:type=\"string\">sample_news_author_columns</item>\n        <item name=\"buttons\" xsi:type=\"array\">\n            <item name=\"add\" xsi:type=\"array\">\n                <item name=\"name\" xsi:type=\"string\">add</item>\n                <item name=\"label\" xsi:type=\"string\" translate=\"true\">Add New Author</item>\n                <item name=\"class\" xsi:type=\"string\">primary</item>\n                <item name=\"url\" xsi:type=\"string\">*/*/new</item>\n            </item>\n        </item>\n    </argument>\n    <dataSource name=\"sample_news_author_listing_data_source\">\n        <argument name=\"dataProvider\" xsi:type=\"configurableObject\">\n            <argument name=\"class\" xsi:type=\"string\">Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProvider</argument>\n            <argument name=\"name\" xsi:type=\"string\">sample_news_author_listing_data_source</argument>\n            <argument name=\"primaryFieldName\" xsi:type=\"string\">author_id</argument>\n            <argument name=\"requestFieldName\" xsi:type=\"string\">author_id</argument>\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/provider</item>\n                    <item name=\"update_url\" xsi:type=\"url\" path=\"mui/index/render\"/>\n                    <item name=\"storageConfig\" xsi:type=\"array\">\n                        <item name=\"indexField\" xsi:type=\"string\">author_id</item>\n                    </item>\n                </item>\n            </argument>\n        </argument>\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"js_config\" xsi:type=\"array\">\n                <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/provider</item>\n            </item>\n        </argument>\n    </dataSource>\n    <container name=\"listing_top\">\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"config\" xsi:type=\"array\">\n                <item name=\"template\" xsi:type=\"string\">ui/grid/toolbar</item>\n                <item name=\"stickyTmpl\" xsi:type=\"string\">ui/grid/sticky/toolbar</item>\n            </item>\n        </argument>\n        <bookmark name=\"bookmarks\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"storageConfig\" xsi:type=\"array\">\n                        <item name=\"namespace\" xsi:type=\"string\">sample_news_author_listing</item>\n                    </item>\n                </item>\n            </argument>\n        </bookmark>\n        <component name=\"columns_controls\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"columnsData\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns</item>\n                    </item>\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/controls/columns</item>\n                    <item name=\"displayArea\" xsi:type=\"string\">dataGridActions</item>\n                </item>\n            </argument>\n        </component>\n        <filterSearch name=\"fulltext\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing_data_source</item>\n                    <item name=\"chipsProvider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.listing_top.listing_filters_chips</item>\n                    <item name=\"storageConfig\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.listing_top.bookmarks</item>\n                        <item name=\"namespace\" xsi:type=\"string\">current.search</item>\n                    </item>\n                </item>\n            </argument>\n        </filterSearch>\n        <filters name=\"listing_filters\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"columnsProvider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns</item>\n                    <item name=\"storageConfig\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.listing_top.bookmarks</item>\n                        <item name=\"namespace\" xsi:type=\"string\">current.filters</item>\n                    </item>\n                    <item name=\"templates\" xsi:type=\"array\">\n                        <item name=\"filters\" xsi:type=\"array\">\n                            <item name=\"select\" xsi:type=\"array\">\n                                <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/form/element/ui-select</item>\n                                <item name=\"template\" xsi:type=\"string\">ui/grid/filters/elements/ui-select</item>\n                            </item>\n                        </item>\n                    </item>\n                    <item name=\"childDefaults\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.listing_top.listing_filters</item>\n                        <item name=\"imports\" xsi:type=\"array\">\n                            <item name=\"visible\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns.${ $.index }:visible</item>\n                        </item>\n                    </item>\n                </item>\n                <item name=\"observers\" xsi:type=\"array\">\n                    <item name=\"column\" xsi:type=\"string\">column</item>\n                </item>\n            </argument>\n            <filterSelect name=\"store_id\">\n                <argument name=\"optionsProvider\" xsi:type=\"configurableObject\">\n                    <argument name=\"class\" xsi:type=\"string\">Sample\\News\\Ui\\Component\\Listing\\Column\\Store\\Options</argument>\n                </argument>\n                <argument name=\"data\" xsi:type=\"array\">\n                    <item name=\"config\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">${ $.parentName }</item>\n                        <item name=\"imports\" xsi:type=\"array\">\n                            <item name=\"visible\" xsi:type=\"string\">componentType = column, index = ${ $.index }:visible</item>\n                        </item>\n                        <item name=\"dataScope\" xsi:type=\"string\">store_id</item>\n                        <item name=\"label\" xsi:type=\"string\" translate=\"true\">Store View</item>\n                        <item name=\"captionValue\" xsi:type=\"string\">0</item>\n                    </item>\n                </argument>\n            </filterSelect>\n        </filters>\n        <massaction name=\"listing_massaction\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"selectProvider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns.ids</item>\n                    <item name=\"indexField\" xsi:type=\"string\">author_id</item>\n                </item>\n            </argument>\n            <action name=\"delete\">\n                <argument name=\"data\" xsi:type=\"array\">\n                    <item name=\"config\" xsi:type=\"array\">\n                        <item name=\"type\" xsi:type=\"string\">delete</item>\n                        <item name=\"label\" xsi:type=\"string\" translate=\"true\">Delete</item>\n                        <item name=\"url\" xsi:type=\"url\" path=\"sample_news/author/massDelete\"/>\n                        <item name=\"confirm\" xsi:type=\"array\">\n                            <item name=\"title\" xsi:type=\"string\" translate=\"true\">Delete items</item>\n                            <item name=\"message\" xsi:type=\"string\" translate=\"true\">Are you sure you want to delete selected items?</item>\n                        </item>\n                    </item>\n                </argument>\n            </action>\n            <action name=\"disable\">\n                <argument name=\"data\" xsi:type=\"array\">\n                    <item name=\"config\" xsi:type=\"array\">\n                        <item name=\"type\" xsi:type=\"string\">disable</item>\n                        <item name=\"label\" xsi:type=\"string\" translate=\"true\">Disable</item>\n                        <item name=\"url\" xsi:type=\"url\" path=\"sample_news/author/massDisable\"/>\n                    </item>\n                </argument>\n            </action>\n            <action name=\"enable\">\n                <argument name=\"data\" xsi:type=\"array\">\n                    <item name=\"config\" xsi:type=\"array\">\n                        <item name=\"type\" xsi:type=\"string\">enable</item>\n                        <item name=\"label\" xsi:type=\"string\" translate=\"true\">Enable</item>\n                        <item name=\"url\" xsi:type=\"url\" path=\"sample_news/author/massEnable\"/>\n                    </item>\n                </argument>\n            </action>\n            <action name=\"edit\">\n                <argument name=\"data\" xsi:type=\"array\">\n                    <item name=\"config\" xsi:type=\"array\">\n                        <item name=\"type\" xsi:type=\"string\">edit</item>\n                        <item name=\"label\" xsi:type=\"string\" translate=\"true\">Edit</item>\n                        <item name=\"callback\" xsi:type=\"array\">\n                            <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns_editor</item>\n                            <item name=\"target\" xsi:type=\"string\">editSelected</item>\n                        </item>\n                    </item>\n                </argument>\n            </action>\n        </massaction>\n        <paging name=\"listing_paging\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"storageConfig\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.listing_top.bookmarks</item>\n                        <item name=\"namespace\" xsi:type=\"string\">current.paging</item>\n                    </item>\n                    <item name=\"selectProvider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns.ids</item>\n                </item>\n            </argument>\n        </paging>\n    </container>\n    <columns name=\"sample_news_author_columns\">\n        <argument name=\"data\" xsi:type=\"array\">\n            <item name=\"config\" xsi:type=\"array\">\n                <item name=\"storageConfig\" xsi:type=\"array\">\n                    <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.listing_top.bookmarks</item>\n                    <item name=\"namespace\" xsi:type=\"string\">current</item>\n                </item>\n                <item name=\"editorConfig\" xsi:type=\"array\">\n                    <item name=\"selectProvider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns.ids</item>\n                    <item name=\"enabled\" xsi:type=\"boolean\">true</item>\n                    <item name=\"indexField\" xsi:type=\"string\">author_id</item>\n                    <item name=\"clientConfig\" xsi:type=\"array\">\n                        <item name=\"saveUrl\" xsi:type=\"url\" path=\"sample_news/author/inlineEdit\"/>\n                        <item name=\"validateBeforeSave\" xsi:type=\"boolean\">false</item>\n                    </item>\n                </item>\n                <item name=\"childDefaults\" xsi:type=\"array\">\n                    <item name=\"fieldAction\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.sample_news_author_columns_editor</item>\n                        <item name=\"target\" xsi:type=\"string\">startEdit</item>\n                        <item name=\"params\" xsi:type=\"array\">\n                            <item name=\"0\" xsi:type=\"string\">${ $.$data.rowIndex }</item>\n                            <item name=\"1\" xsi:type=\"boolean\">true</item>\n                        </item>\n                    </item>\n                    <item name=\"storageConfig\" xsi:type=\"array\">\n                        <item name=\"provider\" xsi:type=\"string\">sample_news_author_listing.sample_news_author_listing.listing_top.bookmarks</item>\n                        <item name=\"root\" xsi:type=\"string\">columns.${ $.index }</item>\n                        <item name=\"namespace\" xsi:type=\"string\">current.${ $.storageConfig.root}</item>\n                    </item>\n                </item>\n            </item>\n        </argument>\n        <selectionsColumn name=\"ids\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"resizeEnabled\" xsi:type=\"boolean\">false</item>\n                    <item name=\"resizeDefaultWidth\" xsi:type=\"string\">55</item>\n                    <item name=\"indexField\" xsi:type=\"string\">author_id</item>\n                </item>\n            </argument>\n        </selectionsColumn>\n        <column name=\"author_id\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"js_config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/column</item>\n                </item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"filter\" xsi:type=\"string\">textRange</item>\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"sorting\" xsi:type=\"string\">asc</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">ID</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"name\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"js_config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/column</item>\n                </item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"editor\" xsi:type=\"array\">\n                        <item name=\"editorType\" xsi:type=\"string\">text</item>\n                        <item name=\"validation\" xsi:type=\"array\">\n                            <item name=\"required-entry\" xsi:type=\"boolean\">true</item>\n                        </item>\n                    </item>\n                    <item name=\"filter\" xsi:type=\"string\">text</item>\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Name</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"url_key\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"js_config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/column</item>\n                </item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"editor\" xsi:type=\"string\">text</item>\n                    <item name=\"filter\" xsi:type=\"string\">text</item>\n                    <item name=\"dataType\" xsi:type=\"string\">text</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Url Key</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"store_id\" class=\"Magento\\Store\\Ui\\Component\\Listing\\Column\\Store\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"bodyTmpl\" xsi:type=\"string\">ui/grid/cells/html</item>\n                    <item name=\"sortable\" xsi:type=\"boolean\">false</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Store View</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"dob\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"js_config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/date</item>\n                </item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"editor\" xsi:type=\"string\">date</item>\n                    <item name=\"filter\" xsi:type=\"string\">dateRange</item>\n                    <item name=\"dataType\" xsi:type=\"string\">date</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">DOB</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"type\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">SampleNewsModelAuthorSourceType</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"editor\" xsi:type=\"string\">select</item>\n                    <item name=\"filter\" xsi:type=\"string\">select</item>\n                    <item name=\"dataType\" xsi:type=\"string\">select</item>\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/select</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Type</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"country\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">Sample\\News\\Model\\Source\\Country</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"editor\" xsi:type=\"string\">select</item>\n                    <item name=\"filter\" xsi:type=\"string\">select</item>\n                    <item name=\"dataType\" xsi:type=\"string\">select</item>\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/select</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Country</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"is_active\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">SampleNewsModelAuthorSourceIsActive</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"filter\" xsi:type=\"string\">select</item>\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/select</item>\n                    <item name=\"editor\" xsi:type=\"string\">select</item>\n                    <item name=\"dataType\" xsi:type=\"string\">select</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Is Active</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"in_rss\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"options\" xsi:type=\"object\">Magento\\Config\\Model\\Config\\Source\\Yesno</item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"editor\" xsi:type=\"string\">select</item>\n                    <item name=\"filter\" xsi:type=\"string\">select</item>\n                    <item name=\"dataType\" xsi:type=\"string\">select</item>\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/select</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">In RSS</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"avatar\" class=\"Sample\\News\\Ui\\Component\\Listing\\Column\\Avatar\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/thumbnail</item>\n                    <item name=\"sortable\" xsi:type=\"boolean\">false</item>\n                    <item name=\"altField\" xsi:type=\"string\">name</item>\n                    <item name=\"has_preview\" xsi:type=\"string\">1</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Avatar</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"created_at\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"js_config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/date</item>\n                </item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"filter\" xsi:type=\"string\">dateRange</item>\n                    <item name=\"dataType\" xsi:type=\"string\">date</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Created At</item>\n                </item>\n            </argument>\n        </column>\n        <column name=\"updated_at\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"js_config\" xsi:type=\"array\">\n                    <item name=\"component\" xsi:type=\"string\">Magento_Ui/js/grid/columns/date</item>\n                </item>\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"filter\" xsi:type=\"string\">dateRange</item>\n                    <item name=\"dataType\" xsi:type=\"string\">date</item>\n                    <item name=\"align\" xsi:type=\"string\">left</item>\n                    <item name=\"label\" xsi:type=\"string\" translate=\"true\">Updated At</item>\n                </item>\n            </argument>\n        </column>\n        <actionsColumn name=\"actions\" class=\"Sample\\News\\Ui\\Component\\Listing\\Column\\AuthorActions\">\n            <argument name=\"data\" xsi:type=\"array\">\n                <item name=\"config\" xsi:type=\"array\">\n                    <item name=\"indexField\" xsi:type=\"string\">author_id</item>\n                    <item name=\"urlEntityParamName\" xsi:type=\"string\">author_id</item>\n                </item>\n            </argument>\n        </actionsColumn>\n    </columns>\n</listing>\n"
  },
  {
    "path": "view/adminhtml/web/template/file-preview.html",
    "content": "<div class=\"file-uploader-summary\">\n    <a attr=\"href: $parent.getFilePreview($file)\" target=\"_blank\" text=\"$file.name\"></a>\n    <div class=\"actions\">\n        <button\n            type=\"button\"\n            class=\"action-remove\"\n            data-role=\"delete-button\"\n            attr=\"title: $t('Delete file')\"\n            click=\"$parent.removeFile.bind($parent, $file)\">\n            <span translate=\"'Delete file'\"/>\n        </button>\n    </div>\n    <div class=\"file-uploader-filename\" />\n</div>\n"
  },
  {
    "path": "view/adminhtml/web/template/image-preview.html",
    "content": "<div class=\"file-uploader-summary\">\n    <div class=\"file-uploader-preview\">\n        <a attr=\"href: $parent.getFilePreview($file)\" target=\"_blank\">\n            <img\n                class=\"preview-image\"\n                tabindex=\"0\"\n                event=\"load: $parent.onPreviewLoad.bind($parent)\"\n                attr=\"\n                    src: $parent.getFilePreview($file),\n                    alt: $file.name\">\n        </a>\n\n        <div class=\"actions\">\n            <button\n                type=\"button\"\n                class=\"action-remove\"\n                data-role=\"delete-button\"\n                attr=\"title: $t('Delete image')\"\n                click=\"$parent.removeFile.bind($parent, $file)\">\n                <span translate=\"'Delete image'\"/>\n            </button>\n        </div>\n    </div>\n\n    <div class=\"file-uploader-filename\" text=\"$file.name\"/>\n    <div class=\"file-uploader-meta\">\n        <text args=\"$file.previewWidth\"/>x<text args=\"$file.previewHeight\"/>\n    </div>\n</div>\n"
  },
  {
    "path": "view/frontend/layout/sample_news_author_index.xml",
    "content": "<?xml version=\"1.0\"?>\r\n<!--\r\n/**\r\n * Sample_News extension\r\n *\r\n * NOTICE OF LICENSE\r\n *\r\n * This source file is subject to the MIT License\r\n * that is bundled with this package in the file LICENSE\r\n * It is also available through the world-wide-web at this URL:\r\n * http://opensource.org/licenses/mit-license.php\r\n *\r\n * @category  Sample\r\n * @package   Sample_News\r\n * @copyright 2016 Marius Strajeru\r\n * @license   http://opensource.org/licenses/mit-license.php MIT License\r\n * @author    Marius Strajeru\r\n */\r\n\r\n-->\r\n<page layout=\"2columns-left\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View/Layout/etc/page_configuration.xsd\">\r\n    <body>\r\n        <referenceContainer name=\"content\">\r\n            <block class=\"Sample\\News\\Block\\Author\\ListAuthor\" template=\"Sample_News::author/list.phtml\" />\r\n        </referenceContainer>\r\n        <referenceBlock name=\"page.main.title\">\r\n            <block class=\"Sample\\News\\Block\\Author\\ListAuthor\\Rss\\Link\" name=\"author.rss.link\" template=\"Sample_News::rss/link.phtml\"/>\r\n        </referenceBlock>\r\n    </body>\r\n\r\n</page>\r\n"
  },
  {
    "path": "view/frontend/layout/sample_news_author_view.xml",
    "content": "<?xml version=\"1.0\"?>\r\n<!--\r\n/**\r\n * Sample_News extension\r\n *\r\n * NOTICE OF LICENSE\r\n *\r\n * This source file is subject to the MIT License\r\n * that is bundled with this package in the file LICENSE\r\n * It is also available through the world-wide-web at this URL:\r\n * http://opensource.org/licenses/mit-license.php\r\n *\r\n * @category  Sample\r\n * @package   Sample_News\r\n * @copyright 2016 Marius Strajeru\r\n * @license   http://opensource.org/licenses/mit-license.php MIT License\r\n * @author    Marius Strajeru\r\n */\r\n-->\r\n<page xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" layout=\"2columns-right\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View/Layout/etc/page_configuration.xsd\">\r\n    <body>\r\n        <referenceBlock name=\"content\">\r\n            <block class=\"Sample\\News\\Block\\Author\\ViewAuthor\" name=\"sample_news.author.view\" template=\"Sample_News::author/view.phtml\" />\r\n        </referenceBlock>\r\n    </body>\r\n</page>\r\n"
  },
  {
    "path": "view/frontend/templates/author/list.phtml",
    "content": "<?php\r\n/**\r\n * Sample_News extension\r\n *\r\n * NOTICE OF LICENSE\r\n *\r\n * This source file is subject to the MIT License\r\n * that is bundled with this package in the file LICENSE\r\n * It is also available through the world-wide-web at this URL:\r\n * http://opensource.org/licenses/mit-license.php\r\n *\r\n * @category  Sample\r\n * @package   Sample_News\r\n * @copyright 2016 Marius Strajeru\r\n * @license   http://opensource.org/licenses/mit-license.php MIT License\r\n * @author    Marius Strajeru\r\n */\r\n?>\r\n<?php /** @var Sample\\News\\Block\\Author\\ListAuthor $block */ ?>\r\n<?php $_authors = $block->getAuthors(); ?>\r\n<div class=\"authors\">\r\n    <?php if ($_authors->getSize() > 0) :?>\r\n        <div class=\"sample-news-authors-toolbar toolbar top\"><?php echo $block->getPagerHtml(); ?></div>\r\n        <div class=\"sample-news-authors-list-container\">\r\n            <?php foreach ($_authors as $_author) : ?>\r\n                <?php /** @var Sample\\News\\Model\\Author $_author */ ?>\r\n                <div class=\"sample-news-author-list-item\">\r\n                    <a href=\"<?php /* @escapeNotVerified */ echo $_author->getAuthorUrl();?>\">\r\n                        <?php echo /* @escapeNotVerified */ $_author->getName();?>\r\n                    </a>\r\n                </div>\r\n            <?php endforeach;?>\r\n        </div>\r\n        <div class=\"sample-news-authors-toolbar toolbar bottom\"><?php echo $block->getPagerHtml(); ?></div>\r\n    <?php else : ?>\r\n        <?php /* @escapeNotVerified */ echo __('There are no authors at this moment');?>\r\n    <?php endif;?>\r\n</div>\r\n"
  },
  {
    "path": "view/frontend/templates/author/view.phtml",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n?>\n<?php /** @var \\Sample\\News\\Block\\Author\\ViewAuthor $block */?>\n<?php $_author = $block->getCurrentAuthor();?>\n<div class=\"author-view\">\n    <div class=\"author-name\">\n        <strong><?php /* @escapeNotVerified */ echo __('Name') ?></strong>: <?php /* @escapeNotVerified */ echo $_author->getName();?>\n    </div>\n    <?php if ($type = $_author->getAttributeText('type')) :?>\n    <div class=\"author-type\">\n        <strong><?php /* @escapeNotVerified */ echo __('Type') ?></strong>: <?php /* @escapeNotVerified */ echo $type;?>\n    </div>\n    <?php endif;?>\n    <?php if ($biography = $_author->getProcessedBiography()) :?>\n    <div class=\"author-biography\">\n        <strong><?php /* @escapeNotVerified */ echo __('Biography') ?></strong>: <?php /* @escapeNotVerified */ echo $biography;?>\n    </div>\n    <?php endif;?>\n    <?php if ($dob = $_author->getDob()) :?>\n    <div class=\"author-dob\">\n        <strong><?php /* @escapeNotVerified */ echo __('Date of birth') ?></strong>: <?php /* @escapeNotVerified */ echo $block->formatDate($dob, \\IntlDateFormatter::LONG);?>\n    </div>\n    <?php endif;?>\n    <?php if ($awards = $_author->getAttributeText('awards')) :?>\n    <div class=\"author-awards\">\n        <strong><?php /* @escapeNotVerified */ echo __('Awards') ?></strong>: <?php /* @escapeNotVerified */ echo $awards;?>\n    </div>\n    <?php endif;?>\n    <?php if ($country = $_author->getAttributeText('country')) :?>\n    <div class=\"author-country\">\n        <strong><?php /* @escapeNotVerified */ echo __('Country') ?></strong>: <?php /* @escapeNotVerified */ echo $country;?>\n    </div>\n    <?php endif;?>\n    <?php if ($resume = $_author->getResume()) :?>\n    <div class=\"author-resume\">\n        <a href=\"<?php /* @escapeNotVerified */ echo $_author->getResumeUrl();?>\"><?php /* @escapeNotVerified */ echo __('Resume') ?></a>\n    </div>\n    <?php endif;?>\n    <div class=\"author-avatar\">\n        <?php /* @escapeNotVerified */  echo $block->getImage($_author, 'author_view', ['width' => 100, 'height' => 100, 'type' => 'avatar'])->toHtml(); ?>\n    </div>\n</div>\n"
  },
  {
    "path": "view/frontend/templates/image.phtml",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n?>\n<?php /** @var $block \\Sample\\News\\Block\\Image */ ?>\n\n<img class=\"photo image\"\n     <?php /* @escapeNotVerified */ echo $block->getCustomAttributes(); ?>\n     src=\"<?php /* @escapeNotVerified */ echo $block->getImageUrl(); ?>\"\n     width=\"<?php /* @escapeNotVerified */ echo $block->getWidth(); ?>\"\n     height=\"<?php /* @escapeNotVerified */ echo $block->getHeight(); ?>\"\n     alt=\"<?php /* @escapeNotVerified */ echo $block->stripTags($block->getLabel(), null, true); ?>\" />\n"
  },
  {
    "path": "view/frontend/templates/image_with_borders.phtml",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n?>\n<?php /** @var $block \\Sample\\News\\Block\\Image */ ?>\n\n<span class=\"image-container\"\n      style=\"width:<?php /* @escapeNotVerified */ echo $block->getWidth()?>px;\">\n    <span class=\"image-wrapper\"\n          style=\"padding-bottom: <?php /* @escapeNotVerified */ echo ($block->getRatio() * 100); ?>%;\">\n        <img class=\"image-photo\"\n             <?php /* @escapeNotVerified */ echo $block->getCustomAttributes(); ?>\n             src=\"<?php /* @escapeNotVerified */ echo $block->getImageUrl(); ?>\"\n             width=\"<?php /* @escapeNotVerified */ echo $block->getResizedImageWidth(); ?>\"\n             height=\"<?php /* @escapeNotVerified */ echo $block->getResizedImageHeight(); ?>\"\n             alt=\"<?php /* @escapeNotVerified */ echo $block->stripTags($block->getLabel(), null, true); ?>\"/></span>\n</span>\n"
  },
  {
    "path": "view/frontend/templates/rss/link.phtml",
    "content": "<?php\n/**\n * Sample_News extension\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the MIT License\n * that is bundled with this package in the file LICENSE\n * It is also available through the world-wide-web at this URL:\n * http://opensource.org/licenses/mit-license.php\n *\n * @category  Sample\n * @package   Sample_News\n * @copyright 2016 Marius Strajeru\n * @license   http://opensource.org/licenses/mit-license.php MIT License\n * @author    Marius Strajeru\n */\n?>\n<?php /** @var \\Sample\\News\\Block\\Author\\ListAuthor\\Rss\\Link $block */?>\n<?php if ($block->isRssEnabled()) : ?>\n    <a href=\"<?php /* @escapeNotVerified */ echo $block->getLink() ?>\" class=\"action link rss\">\n        <span><?php /* @escapeNotVerified */ echo __('Subscribe to RSS Feed') ?></span>\n    </a>\n<?php endif; ?>\n"
  }
]