Skip to content

Commit

Permalink
Merge pull request #511 from magento-tango/MAGETWO-41080
Browse files Browse the repository at this point in the history
[Tango] S57 - Support Tool, Glob Patterns, Bug Fixes
  • Loading branch information
Kovsher, Iurii(ikovsher) committed Aug 10, 2015
2 parents 1fb448a + 6d72d80 commit eef95ce
Show file tree
Hide file tree
Showing 23 changed files with 675 additions and 458 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,25 @@ $numColumns = sizeof($block->getColumns());
</div>
<?php if ($block->canDisplayContainer()): ?>
<script>
var deps = ['mage/adminhtml/grid'];
var deps = [];

<?php if ($block->getDependencyJsObject()): ?>
deps.push('uiRegistry');
<?php endif; ?>

<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
deps.push('Magento_Sales/order/create/form')
deps.push('Magento_Sales/order/create/form');
<?php endif; ?>

require(deps, function(){
deps.push('mage/adminhtml/grid');

require(deps, function(<?php echo ($block->getDependencyJsObject() ? 'registry' : '') ?>){
<?php //TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed ?>

<?php if ($block->getDependencyJsObject()): ?>
registry.get('<?php echo $block->getDependencyJsObject() ?>', function (<?php echo $block->getDependencyJsObject() ?>) {
<?php endif; ?>

<?php echo $block->getJsObjectName() ?> = new varienGrid('<?php echo $block->getId() ?>', '<?php echo $block->getGridUrl() ?>', '<?php echo $block->getVarNamePage() ?>', '<?php echo $block->getVarNameSort() ?>', '<?php echo $block->getVarNameDir() ?>', '<?php echo $block->getVarNameFilter() ?>');
<?php echo $block->getJsObjectName() ?>.useAjax = '<?php echo $block->getUseAjax() ?>';
<?php if ($block->getRowClickCallback()): ?>
Expand All @@ -74,6 +84,10 @@ require(deps, function(){
<?php echo $block->getMassactionBlock()->getJavaScript() ?>
<?php endif ?>

<?php if ($block->getDependencyJsObject()): ?>
});
<?php endif; ?>

});
</script>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,25 @@ $numColumns = sizeof($block->getColumns());
<?php if ($block->canDisplayContainer()): ?>
</div>
<script>
var deps = ['mage/adminhtml/grid'];
var deps = [];

<?php if ($block->getDependencyJsObject()): ?>
deps.push('uiRegistry');
<?php endif; ?>

<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
deps.push('Magento_Sales/order/create/form');
deps.push('Magento_Sales/order/create/form')
<?php endif; ?>

require(deps, function(){
deps.push('mage/adminhtml/grid');

require(deps, function(<?php echo ($block->getDependencyJsObject() ? 'registry' : '') ?>){
<?php //TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed ?>

<?php if ($block->getDependencyJsObject()): ?>
registry.get('<?php echo $block->getDependencyJsObject() ?>', function (<?php echo $block->getDependencyJsObject() ?>) {
<?php endif; ?>

<?php echo $block->getJsObjectName() ?> = new varienGrid('<?php echo $block->getId() ?>', '<?php echo $block->getGridUrl() ?>', '<?php echo $block->getVarNamePage() ?>', '<?php echo $block->getVarNameSort() ?>', '<?php echo $block->getVarNameDir() ?>', '<?php echo $block->getVarNameFilter() ?>');
<?php echo $block->getJsObjectName() ?>.useAjax = <?php echo $block->getUseAjax() ? 'true' : 'false' ?>;
<?php if ($block->getRowClickCallback()): ?>
Expand All @@ -171,6 +181,10 @@ $numColumns = sizeof($block->getColumns());
<?php echo $block->getChildBlock('grid.massaction')->getJavaScript() ?>
<?php endif ?>
<?php echo $block->getAdditionalJavaScript(); ?>

<?php if ($block->getDependencyJsObject()): ?>
});
<?php endif; ?>
});
</script>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,26 @@ $numColumns = sizeof($block->getColumns());
<?php if ($block->canDisplayContainer()): ?>
</div>
<script>
var deps = ['mage/adminhtml/grid'];
var deps = [];

<?php if ($block->getDependencyJsObject()): ?>
deps.push('uiRegistry');
<?php endif; ?>

<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
deps.push('Magento_Sales/order/create/form')
<?php endif; ?>

require(deps, function(){
deps.push('mage/adminhtml/grid');

require(deps, function(<?php echo ($block->getDependencyJsObject() ? 'registry' : '') ?>){
<?php //TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed ?>

//<![CDATA[
<?php if ($block->getDependencyJsObject()): ?>
registry.get('<?php echo $block->getDependencyJsObject() ?>', function (<?php echo $block->getDependencyJsObject() ?>) {
<?php endif; ?>

<?php echo $block->getJsObjectName() ?> = new varienGrid('<?php echo $block->getId() ?>', '<?php echo $block->getGridUrl() ?>', '<?php echo $block->getVarNamePage() ?>', '<?php echo $block->getVarNameSort() ?>', '<?php echo $block->getVarNameDir() ?>', '<?php echo $block->getVarNameFilter() ?>');
<?php echo $block->getJsObjectName() ?>.useAjax = '<?php echo $block->getUseAjax() ?>';
<?php if ($block->getRowClickCallback()): ?>
Expand All @@ -269,6 +279,10 @@ $numColumns = sizeof($block->getColumns());
<?php echo $block->getMassactionBlock()->getJavaScript() ?>
<?php endif ?>
<?php echo $block->getAdditionalJavaScript(); ?>

<?php if ($block->getDependencyJsObject()): ?>
});
<?php endif; ?>
//]]>

});
Expand Down
22 changes: 14 additions & 8 deletions app/code/Magento/Ui/view/base/ui_component/etc/definition.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/boolean</item>
<item name="extends" xsi:type="string">input</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/checkbox</item>
</item>
</item>
Expand All @@ -156,8 +156,8 @@
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/select</item>
<item name="extends" xsi:type="string">input</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/select</item>
</item>
</item>
Expand All @@ -168,8 +168,8 @@
<item name="template" xsi:type="string">ui/form/element/multiselect</item>
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/multiselect</item>
<item name="extends" xsi:type="string">input</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/multiselect</item>
</item>
</item>
Expand All @@ -179,8 +179,8 @@
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/textarea</item>
<item name="extends" xsi:type="string">input</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/textarea</item>
</item>
</item>
Expand Down Expand Up @@ -208,8 +208,9 @@
<image class="Magento\Ui\Component\Form\Element\DataType\Media">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="extends" xsi:type="string">input</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/media</item>
</item>
</item>
Expand All @@ -218,9 +219,9 @@
<date class="Magento\Ui\Component\Form\Element\DataType\Date">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="extends" xsi:type="string">input</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/element/date</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/date</item>
</item>
</item>
Expand All @@ -229,15 +230,20 @@
<boolean class="Magento\Ui\Component\Form\Element\DataType\Boolean">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="extends" xsi:type="string">input</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/input</item>
</item>
</item>
</argument>
</boolean>
<email class="Magento\Ui\Component\Form\Element\DataType\Email">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="extends" xsi:type="string">input</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/email</item>
</item>
</item>
Expand Down
Empty file modified app/code/Magento/Ui/view/base/web/js/form/element/abstract.js
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
* @return \Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/View/Element/UiComponentFactory.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function create($identifier, $name = null, array $arguments = [])
/** @var \Magento\Framework\View\Element\UiComponentInterface $component */
$component = $this->objectManager->create(
$className,
array_merge_recursive($componentArguments, $arguments)
array_replace_recursive($componentArguments, $arguments)
);

return $component;
Expand Down
67 changes: 67 additions & 0 deletions lib/internal/Magento/Framework/View/File/AbstractCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\View\File;

use Magento\Framework\Filesystem;
use Magento\Framework\View\File\Factory as FileFactory;
use Magento\Framework\View\Helper\PathPattern as PathPatternHelper;
use Magento\Framework\App\Filesystem\DirectoryList;

/**
* Abstract file collector
*/
abstract class AbstractCollector implements CollectorInterface
{
/**
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
*/
protected $directory;

/**
* @var \Magento\Framework\View\File\Factory
*/
protected $fileFactory;

/**
* @var \Magento\Framework\View\Helper\PathPattern
*/
protected $pathPatternHelper;

/**
* @var string
*/
protected $subDir;

/**
* Constructor
*
* @param \Magento\Framework\Filesystem $filesystem
* @param \Magento\Framework\View\File\Factory $fileFactory
* @param \Magento\Framework\View\Helper\PathPattern $pathPatternHelper
* @param string $subDir
*/
public function __construct(
Filesystem $filesystem,
FileFactory $fileFactory,
PathPatternHelper $pathPatternHelper,
$subDir = ''
) {
$this->directory = $filesystem->getDirectoryRead($this->getScopeDirectory());
$this->fileFactory = $fileFactory;
$this->pathPatternHelper = $pathPatternHelper;
$this->subDir = $subDir ? $subDir . '/' : '';
}

/**
* Get scope directory of this file collector
*
* @return string
*/
protected function getScopeDirectory()
{
return DirectoryList::MODULES;
}
}
60 changes: 9 additions & 51 deletions lib/internal/Magento/Framework/View/File/Collector/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,42 @@
*/
namespace Magento\Framework\View\File\Collector;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\ReadInterface;
use Magento\Framework\View\File\AbstractCollector;
use Magento\Framework\View\Design\ThemeInterface;
use Magento\Framework\View\File\CollectorInterface;
use Magento\Framework\View\File\Factory;

/**
* Source of base files introduced by modules
*/
class Base implements CollectorInterface
class Base extends AbstractCollector
{
/**
* File factory
*
* @var Factory
*/
private $fileFactory;

/**
* Modules directory
*
* @var ReadInterface
*/
protected $modulesDirectory;

/**
* Subdirectory where the files are located
*
* @var string
*/
protected $subDir;

/**
* Constructor
*
* @param Filesystem $filesystem
* @param Factory $fileFactory
* @param string $subDir
*/
public function __construct(
Filesystem $filesystem,
Factory $fileFactory,
$subDir = ''
) {
$this->modulesDirectory = $filesystem->getDirectoryRead(DirectoryList::MODULES);
$this->fileFactory = $fileFactory;
$this->subDir = $subDir ? $subDir . '/' : '';
}

/**
* Retrieve files
*
* @param ThemeInterface $theme
* @param \Magento\Framework\View\Design\ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
* @return \Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
$result = [];
$namespace = $module = '*';
$sharedFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/base/{$this->subDir}{$filePath}");
$sharedFiles = $this->directory->search("{$namespace}/{$module}/view/base/{$this->subDir}{$filePath}");

$filePathPtn = strtr(preg_quote($filePath), ['\*' => '[^/]+']);
$filePathPtn = $this->pathPatternHelper->translatePatternFromGlob($filePath);
$pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/base/{$this->subDir}" . $filePathPtn . "$#i";
foreach ($sharedFiles as $file) {
$filename = $this->modulesDirectory->getAbsolutePath($file);
$filename = $this->directory->getAbsolutePath($file);
if (!preg_match($pattern, $filename, $matches)) {
continue;
}
$moduleFull = "{$matches['namespace']}_{$matches['module']}";
$result[] = $this->fileFactory->create($filename, $moduleFull, null, true);
}
$area = $theme->getData('area');
$themeFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/{$area}/{$this->subDir}{$filePath}");
$themeFiles = $this->directory->search("{$namespace}/{$module}/view/{$area}/{$this->subDir}{$filePath}");
$pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/{$area}/{$this->subDir}" . $filePathPtn . "$#i";
foreach ($themeFiles as $file) {
$filename = $this->modulesDirectory->getAbsolutePath($file);
$filename = $this->directory->getAbsolutePath($file);
if (!preg_match($pattern, $filename, $matches)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
*
* @param ThemeInterface $theme
* @param string $filePath
* @return array|\Magento\Framework\View\File[]
* @return \Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
Expand Down
Loading

0 comments on commit eef95ce

Please sign in to comment.