Skip to content

Commit e8c8a50

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/develop' into MAGETWO-31968-Logger-Fatal-Error
2 parents b2bcbba + b68900d commit e8c8a50

File tree

346 files changed

+29367
-945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+29367
-945
lines changed

CONTRIBUTING.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
# Contribution Guide
1+
# Contributing to Magento 2 code
22

3-
The Magento 2 development team will review all issues and contributions submitted by the community of developers. Contributions can take the form of new components/features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations or just good suggestions. To assist in the expediency of the review process, we strongly encourage you to follow all the proper requirements stated below in Definition of Done, before submitting any code for consideration.
3+
Contributions to the Magento 2 codebase are done using the fork & pull model.
4+
This contribution model has contributors maintaining their own copy of the forked codebase (which can easily be synced with the main copy). The forked repository is then used to submit a request to the base repository to “pull” a set of changes (hence the phrase “pull request”).
45

5-
## Contribution Process
6+
Contributions can take the form of new components/features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations or just good suggestions.
67

7-
If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free). By doing that, you will be able to collaborate with the Magento 2 development team, “fork” the Magento 2 project and be able to easily send “pull requests”.
8-
9-
1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
10-
2. Review the [Contributor License Agreement](https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html) if this is your first time contributing.
11-
3. Create and test your work.
12-
4. Fork the Magento 2 repository according to [github's Fork A Repo instructions](https://help.github.com/articles/fork-a-repo) and when you are ready to send us a Pull Request – follow [github's Using Pull Requests instructions](https://help.github.com/articles/using-pull-requests).
13-
5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution.
8+
The Magento 2 development team will review all issues and contributions submitted by the community of developers in the first in, first out order. During the review we might require clarifications from the contributor. If there is no response from the contributor for two weeks, the issue is closed.
149

15-
### Contribution Acceptance Criteria
1610

17-
1. Code changes must be covered with automated tests and supplied along with the patch (or fork). Author chooses the best approach for testing as deemed necessary. See [Magento Automated Testing Standard](https://github.com/magento/magento2/wiki/Magento-Automated-Testing-Standard) for additional guidance.
18-
2. New features or proposals must be supplied with documentation -- functional (how a feature works) or technical (how it is implemented/designed), or both.
11+
## Contribution requirements
1912

20-
## Frequently Asked Questions
13+
1. Contributions must adhere to [Magento coding standards](http://devdocs.magento.com/guides/v1.0/coding-standards/bk-coding-standards.html).
14+
2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request to be merged quickly and without additional clarification requests.
15+
3. Commits must be accompanied by meaningful commit messages.
16+
4. PRs which include bug fixing, must be accompanied with step-by-step description of how to reproduce the bug.
17+
3. PRs which include new logic or new features must be submitted along with:
18+
* Unit/integration test coverage (we will be releasing more information on writing test coverage in the near future).
19+
* Proposed [documentation](http://devdocs.magento.com) update. Documentation contributions can be submitted [here](https://github.com/magento/devdocs).
20+
4. For large features or changes, please [open an issue](https://github.com/magento/magento2/issues) and discuss first. This may prevent duplicate or unnecessary effort, and it may gain you some additional contributors.
21+
5. All automated tests are passed successfully (all builds on [Travis CI](https://travis-ci.org/magento/magento2) must be green).
2122

22-
**Do I need to follow all requirements of the contribution process?**
23+
## Contribution process
2324

24-
Yes. We strongly encourage that you follow the requirements as stated, before submitting your code or patch for Magento 2 development team's review. Properly submitted contributions will help the Magento 2 development team to quickly assess your contribution and incorporate it into the Magento 2 project if deemed beneficial.
25-
26-
**Do you accept all contributions?**
25+
If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free). By doing that, you will be able to collaborate with the Magento 2 development team, “fork” the Magento 2 project and be able to easily send “pull requests”.
2726

28-
Not all contributions will be used or incorporated into the code for the project. The decision to incorporate the code or not is at the discretion of the Magento 2 development team.
27+
1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
28+
2. Review the [Contributor License Agreement](https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html) if this is your first time contributing.
29+
3. Create and test your work.
30+
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v1.0/contributor-guide/CONTRIBUTING.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v1.0/contributor-guide/CONTRIBUTING.html#pull_request).
31+
5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution.

app/code/Magento/Catalog/Block/Adminhtml/Category/Edit/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function _prepareLayout()
9393
'onclick' => "categoryDelete('" . $this->getUrl(
9494
'catalog/*/delete',
9595
['_current' => true]
96-
) . "', true, {$categoryId})",
96+
) . "')",
9797
'class' => 'delete'
9898
]
9999
);

app/code/Magento/Catalog/Block/Navigation.php

Lines changed: 0 additions & 266 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,6 @@ public function getCurrenCategoryKey()
173173
return $this->_currentCategoryKey;
174174
}
175175

176-
/**
177-
* Get catagories of current store
178-
*
179-
* @return \Magento\Framework\Data\Tree\Node\Collection
180-
*/
181-
public function getStoreCategories()
182-
{
183-
return $this->_catalogCategory->getStoreCategories();
184-
}
185-
186176
/**
187177
* Retrieve child categories of current category
188178
*
@@ -229,161 +219,6 @@ public function getCategoryUrl($category)
229219
return $url;
230220
}
231221

232-
/**
233-
* Return item position representation in menu tree
234-
*
235-
* @param int $level
236-
* @return string
237-
*/
238-
protected function _getItemPosition($level)
239-
{
240-
if ($level == 0) {
241-
$zeroLevelPosition = isset(
242-
$this->_itemLevelPositions[$level]
243-
) ? $this->_itemLevelPositions[$level] + 1 : 1;
244-
$this->_itemLevelPositions = [];
245-
$this->_itemLevelPositions[$level] = $zeroLevelPosition;
246-
} elseif (isset($this->_itemLevelPositions[$level])) {
247-
$this->_itemLevelPositions[$level]++;
248-
} else {
249-
$this->_itemLevelPositions[$level] = 1;
250-
}
251-
252-
$position = [];
253-
for ($i = 0; $i <= $level; $i++) {
254-
if (isset($this->_itemLevelPositions[$i])) {
255-
$position[] = $this->_itemLevelPositions[$i];
256-
}
257-
}
258-
return implode('-', $position);
259-
}
260-
261-
/**
262-
* Render category to html
263-
*
264-
* @param Category $category
265-
* @param int $level Nesting level number
266-
* @param boolean $isLast Whether ot not this item is last, affects list item class
267-
* @param boolean $isFirst Whether ot not this item is first, affects list item class
268-
* @param boolean $isOutermost Whether ot not this item is outermost, affects list item class
269-
* @param string $outermostItemClass Extra class of outermost list items
270-
* @param string $childrenWrapClass If specified wraps children list in div with this class
271-
* @param boolean $noEventAttributes Whether ot not to add on* attributes to list item
272-
* @return string
273-
*/
274-
protected function _renderCategoryMenuItemHtml(
275-
$category,
276-
$level = 0,
277-
$isLast = false,
278-
$isFirst = false,
279-
$isOutermost = false,
280-
$outermostItemClass = '',
281-
$childrenWrapClass = '',
282-
$noEventAttributes = false
283-
) {
284-
if (!$category->getIsActive()) {
285-
return '';
286-
}
287-
288-
// get all children
289-
if ($this->flatState->isAvailable()) {
290-
$children = (array)$category->getChildrenNodes();
291-
} else {
292-
$children = $category->getChildren();
293-
}
294-
295-
// select active children
296-
$activeChildren = [];
297-
foreach ($children as $child) {
298-
if ($child->getIsActive()) {
299-
$activeChildren[] = $child;
300-
}
301-
}
302-
303-
$activeChildrenCount = count($activeChildren);
304-
$hasActiveChildren = $activeChildrenCount > 0;
305-
306-
// prepare list item html classes
307-
$classes = [];
308-
$classes[] = 'level' . $level;
309-
$classes[] = 'nav-' . $this->_getItemPosition($level);
310-
if ($this->isCategoryActive($category)) {
311-
$classes[] = 'active';
312-
}
313-
314-
$linkClass = '';
315-
if ($isOutermost && $outermostItemClass) {
316-
$classes[] = $outermostItemClass;
317-
$linkClass = ' class="' . $outermostItemClass . '"';
318-
}
319-
if ($isFirst) {
320-
$classes[] = 'first';
321-
}
322-
if ($isLast) {
323-
$classes[] = 'last';
324-
}
325-
if ($hasActiveChildren) {
326-
$classes[] = 'parent';
327-
}
328-
329-
// prepare list item attributes
330-
$attributes = [];
331-
if (count($classes) > 0) {
332-
$attributes['class'] = implode(' ', $classes);
333-
}
334-
if ($hasActiveChildren && !$noEventAttributes) {
335-
$attributes['onmouseover'] = 'toggleMenu(this,1)';
336-
$attributes['onmouseout'] = 'toggleMenu(this,0)';
337-
}
338-
339-
// assemble list item with attributes
340-
$htmlLi = '<li';
341-
foreach ($attributes as $attrName => $attrValue) {
342-
$htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . '"';
343-
}
344-
$htmlLi .= '>';
345-
346-
$html = [];
347-
$html[] = $htmlLi;
348-
349-
$html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
350-
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
351-
$html[] = '</a>';
352-
353-
// render children
354-
$htmlChildren = '';
355-
$j = 0;
356-
foreach ($activeChildren as $child) {
357-
$htmlChildren .= $this->_renderCategoryMenuItemHtml(
358-
$child,
359-
$level + 1,
360-
$j == $activeChildrenCount - 1,
361-
$j == 0,
362-
false,
363-
$outermostItemClass,
364-
$childrenWrapClass,
365-
$noEventAttributes
366-
);
367-
$j++;
368-
}
369-
if (!empty($htmlChildren)) {
370-
if ($childrenWrapClass) {
371-
$html[] = '<div class="' . $childrenWrapClass . '">';
372-
}
373-
$html[] = '<ul class="level' . $level . '">';
374-
$html[] = $htmlChildren;
375-
$html[] = '</ul>';
376-
if ($childrenWrapClass) {
377-
$html[] = '</div>';
378-
}
379-
}
380-
381-
$html[] = '</li>';
382-
383-
$html = implode("\n", $html);
384-
return $html;
385-
}
386-
387222
/**
388223
* Enter description here...
389224
*
@@ -394,107 +229,6 @@ public function getCurrentCategory()
394229
return $this->_catalogLayer->getCurrentCategory();
395230
}
396231

397-
/**
398-
* Enter description here...
399-
*
400-
* @return string
401-
*/
402-
public function getCurrentCategoryPath()
403-
{
404-
if ($this->getCurrentCategory()) {
405-
return explode(',', $this->getCurrentCategory()->getPathInStore());
406-
}
407-
return [];
408-
}
409-
410-
/**
411-
* Enter description here...
412-
*
413-
* @param Category $category
414-
* @return string
415-
*/
416-
public function drawOpenCategoryItem($category)
417-
{
418-
$html = '';
419-
if (!$category->getIsActive()) {
420-
return $html;
421-
}
422-
423-
$html .= '<li';
424-
425-
if ($this->isCategoryActive($category)) {
426-
$html .= ' class="active"';
427-
}
428-
429-
$html .= '>' . "\n";
430-
$html .= '<a href="' . $this->getCategoryUrl(
431-
$category
432-
) . '">' . '<span>' . $this->escapeHtml(
433-
$category->getName()
434-
) . '</span></a>' . "\n";
435-
436-
if (in_array($category->getId(), $this->getCurrentCategoryPath())) {
437-
$children = $category->getChildren();
438-
$hasChildren = $children && $children->count();
439-
440-
if ($hasChildren) {
441-
$htmlChildren = '';
442-
foreach ($children as $child) {
443-
$htmlChildren .= $this->drawOpenCategoryItem($child);
444-
}
445-
446-
if (!empty($htmlChildren)) {
447-
$html .= '<ul>' . "\n" . $htmlChildren . '</ul>';
448-
}
449-
}
450-
}
451-
$html .= '</li>' . "\n";
452-
453-
return $html;
454-
}
455-
456-
/**
457-
* Render categories menu in HTML
458-
*
459-
* @param int $level Level number for list item class to start from
460-
* @param string $outermostItemClass Extra class of outermost list items
461-
* @param string $childrenWrapClass If specified wraps children list in div with this class
462-
* @return string
463-
*/
464-
public function renderCategoriesMenuHtml($level = 0, $outermostItemClass = '', $childrenWrapClass = '')
465-
{
466-
$activeCategories = [];
467-
foreach ($this->getStoreCategories() as $child) {
468-
if ($child->getIsActive()) {
469-
$activeCategories[] = $child;
470-
}
471-
}
472-
$activeCategoriesCount = count($activeCategories);
473-
$hasActiveCategoriesCount = $activeCategoriesCount > 0;
474-
475-
if (!$hasActiveCategoriesCount) {
476-
return '';
477-
}
478-
479-
$html = '';
480-
$j = 0;
481-
foreach ($activeCategories as $category) {
482-
$html .= $this->_renderCategoryMenuItemHtml(
483-
$category,
484-
$level,
485-
$j == $activeCategoriesCount - 1,
486-
$j == 0,
487-
true,
488-
$outermostItemClass,
489-
$childrenWrapClass,
490-
true
491-
);
492-
$j++;
493-
}
494-
495-
return $html;
496-
}
497-
498232
/**
499233
* Return identifiers for produced content
500234
*

app/code/Magento/Catalog/Controller/Adminhtml/Category/Delete.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77

88
class Delete extends \Magento\Catalog\Controller\Adminhtml\Category
99
{
10+
/** @var \Magento\Catalog\Api\CategoryRepositoryInterface */
11+
protected $categoryRepository;
12+
13+
/**
14+
* @param \Magento\Backend\App\Action\Context $context
15+
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
16+
* @param \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository
17+
*/
18+
public function __construct(
19+
\Magento\Backend\App\Action\Context $context,
20+
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
21+
\Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository
22+
) {
23+
parent::__construct($context, $resultRedirectFactory);
24+
$this->categoryRepository = $categoryRepository;
25+
}
26+
1027
/**
1128
* Delete category action
1229
*
@@ -18,14 +35,14 @@ public function execute()
1835
$resultRedirect = $this->resultRedirectFactory->create();
1936

2037
$categoryId = (int)$this->getRequest()->getParam('id');
38+
$parentId = null;
2139
if ($categoryId) {
2240
try {
23-
$category = $this->_objectManager->create('Magento\Catalog\Model\Category')->load($categoryId);
41+
$category = $this->categoryRepository->get($categoryId);
42+
$parentId = $category->getParentId();
2443
$this->_eventManager->dispatch('catalog_controller_category_delete', ['category' => $category]);
25-
26-
$this->_objectManager->get('Magento\Backend\Model\Auth\Session')->setDeletedPath($category->getPath());
27-
28-
$category->delete();
44+
$this->_auth->getAuthStorage()->setDeletedPath($category->getPath());
45+
$this->categoryRepository->delete($category);
2946
$this->messageManager->addSuccess(__('You deleted the category.'));
3047
} catch (\Magento\Framework\Model\Exception $e) {
3148
$this->messageManager->addError($e->getMessage());
@@ -35,6 +52,6 @@ public function execute()
3552
return $resultRedirect->setPath('catalog/*/edit', ['_current' => true]);
3653
}
3754
}
38-
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
55+
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => $parentId]);
3956
}
4057
}

0 commit comments

Comments
 (0)