Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
M2 content provisioning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TechDivision Public
M2 content provisioning
Commits
c968b425
Commit
c968b425
authored
2 months ago
by
Eduarda Lentz Rodrigues da Silva
Browse files
Options
Downloads
Patches
Plain Diff
ZERO-162 Added moduleConfig to get block information. Deleted unnecessary code.
parent
7d3ea934
No related branches found
Branches containing commit
No related tags found
1 merge request
!46
ZERO-162-changes
Pipeline
#91872
canceled
2 months ago
Stage: static-tests
Stage: integration-tests
Stage: semver-tests
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Model/Console/BlockListCommand.php
+15
-35
15 additions, 35 deletions
Model/Console/BlockListCommand.php
Model/Query/GetFilesContentInformation.php
+24
-45
24 additions, 45 deletions
Model/Query/GetFilesContentInformation.php
Model/RenderChangedBlockList.php
+1
-0
1 addition, 0 deletions
Model/RenderChangedBlockList.php
with
40 additions
and
80 deletions
Model/Console/BlockListCommand.php
+
15
−
35
View file @
c968b425
...
...
@@ -2,6 +2,21 @@
declare
(
strict_types
=
1
);
/**
* Copyright (c) 2024 TechDivision GmbH
* All rights reserved
*
* This product includes proprietary software developed at TechDivision GmbH, Germany
* For more information see https://www.techdivision.com/
*
* To obtain a valid license for using this software please contact us at
* license@techdivision.com
*
* @copyright Copyright (c) 2024 TechDivision GmbH (https://www.techdivision.com)
* @author TechDivision Team Zero <zero@techdivision.com>
* @link https://www.techdivision.com/
*/
namespace
Firegento\ContentProvisioning\Model\Console
;
use
Firegento\ContentProvisioning\Model\Query\GetBlockEntryList
as
GetBlockEntryList
;
...
...
@@ -10,7 +25,6 @@ use Firegento\ContentProvisioning\Model\Query\GetFilesContentInformation;
use
Firegento\ContentProvisioning\Model\RenderChangedBlockList
;
use
Magento\Framework\Exception\LocalizedException
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Helper\Table
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
...
...
@@ -107,38 +121,4 @@ class BlockListCommand extends Command
$files
=
$this
->
GetFilesContentInformation
->
execute
();
return
$this
->
getChangedBlocksIdentifier
->
execute
(
$files
);
}
/**
* Return array with block information from content_provisioning file
* @param array $files
* @return array
* @throws \Exception
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public
function
getBlockInformation
(
array
$files
):
array
{
$results
=
[];
foreach
(
$files
as
$fileName
=>
$fileContent
)
{
try
{
$xml
=
new
\SimpleXMLElement
(
$fileContent
);
foreach
(
$xml
->
block
as
$block
)
{
$stores
=
(
string
)(
isset
(
$block
->
stores
->
store
)
&&
$block
->
stores
->
store
->
attributes
()
?
$block
->
stores
->
store
->
attributes
()
->
code
:
null
);
$results
[]
=
[
'identifier'
=>
(
string
)
$block
[
'identifier'
],
'key'
=>
(
string
)
$block
[
'key'
],
'content'
=>
(
string
)
$block
->
content
,
'stores'
=>
$stores
,
'is_active'
=>
(
string
)
$block
[
'active'
]
?
'yes'
:
'no'
,
'is_maintained'
=>
(
string
)
$block
[
'maintained'
]
?
'yes'
:
'no'
,
'title'
=>
$block
->
title
];
}
}
catch
(
LocalizedException
$e
)
{
error_log
(
$e
->
getMessage
());
}
}
return
$results
;
}
}
This diff is collapsed.
Click to expand it.
Model/Query/GetFilesContentInformation.php
+
24
−
45
View file @
c968b425
...
...
@@ -19,6 +19,7 @@ declare(strict_types=1);
namespace
Firegento\ContentProvisioning\Model\Query
;
use
Firegento\ContentProvisioning\Model\Config\Data
;
use
Magento\Framework\Module\ModuleList
;
use
Magento\Framework\Module\Dir
;
use
Magento\Framework\Filesystem\Driver\File
;
...
...
@@ -41,19 +42,27 @@ class GetFilesContentInformation
*/
private
File
$fileDriver
;
/**
* @var Data
*/
private
Data
$moduleConfig
;
/**
* @param ModuleList $moduleList
* @param Dir $moduleDirReader
* @param File $fileDriver
* @param Data $moduleConfig
*/
public
function
__construct
(
ModuleList
$moduleList
,
Dir
$moduleDirReader
,
File
$fileDriver
File
$fileDriver
,
Data
$moduleConfig
)
{
$this
->
moduleList
=
$moduleList
;
$this
->
moduleDirReader
=
$moduleDirReader
;
$this
->
fileDriver
=
$fileDriver
;
$this
->
moduleConfig
=
$moduleConfig
;
}
/**
...
...
@@ -66,32 +75,12 @@ class GetFilesContentInformation
return
$this
->
getBlockInformation
(
$this
->
getContentProvisioningFiles
());
}
/**
* @return mixed
*/
public
function
getContentProvisioningFiles
()
{
$files
=
[];
$modules
=
$this
->
moduleList
->
getAll
();
foreach
(
$modules
as
$moduleName
=>
$moduleData
)
{
try
{
$modulePath
=
$this
->
moduleDirReader
->
getDir
(
$moduleName
);
// only app/code modules
if
(
!
str_contains
(
$modulePath
,
'app/code'
))
{
continue
;
}
$moduleEtcPath
=
$this
->
moduleDirReader
->
getDir
(
$moduleName
,
Dir
::
MODULE_ETC_DIR
);
$provisionFilePath
=
$moduleEtcPath
.
DIRECTORY_SEPARATOR
.
'content_provisioning.xml'
;
if
(
$this
->
fileDriver
->
isExists
(
$provisionFilePath
))
{
$content
=
$this
->
fileDriver
->
fileGetContents
(
$provisionFilePath
);
$files
[
$moduleName
]
=
$content
;
}
}
catch
(
LocalizedException
$e
)
{
return
'ERROR: '
.
$e
->
getMessage
();
}
}
return
$files
;
return
$this
->
moduleConfig
->
getList
()[
'blocks'
];
}
/**
...
...
@@ -104,26 +93,16 @@ class GetFilesContentInformation
public
function
getBlockInformation
(
array
$files
):
array
{
$results
=
[];
foreach
(
$files
as
$fileName
=>
$fileContent
)
{
try
{
$xml
=
new
\SimpleXMLElement
(
$fileContent
);
foreach
(
$xml
->
block
as
$block
)
{
$stores
=
(
string
)(
isset
(
$block
->
stores
->
store
)
&&
$block
->
stores
->
store
->
attributes
()
?
$block
->
stores
->
store
->
attributes
()
->
code
:
null
);
$results
[]
=
[
'identifier'
=>
(
string
)
$block
[
'identifier'
],
'key'
=>
(
string
)
$block
[
'key'
],
'content'
=>
(
string
)
$block
->
content
,
'stores'
=>
$stores
,
'is_active'
=>
(
string
)
$block
[
'active'
]
?
'yes'
:
'no'
,
'is_maintained'
=>
(
string
)
$block
[
'maintained'
]
?
'yes'
:
'no'
,
'title'
=>
$block
->
title
];
}
}
catch
(
LocalizedException
$e
)
{
error_log
(
$e
->
getMessage
());
}
foreach
(
$files
as
$fileName
=>
$fileData
)
{
$results
[]
=
[
'identifier'
=>
(
string
)
$fileData
[
'identifier'
],
'title'
=>
$fileData
[
'title'
],
'key'
=>
(
string
)
$fileData
[
'key'
],
'content'
=>
(
string
)
$fileData
[
'content'
],
'stores'
=>
implode
(
", "
,
$fileData
[
'stores'
]),
'is_active'
=>
(
string
)
$fileData
[
'is_active'
]
?
'yes'
:
'no'
,
'is_maintained'
=>
(
string
)
$fileData
[
'is_maintained'
]
?
'yes'
:
'no'
];
}
return
$results
;
}
...
...
This diff is collapsed.
Click to expand it.
Model/RenderChangedBlockList.php
+
1
−
0
View file @
c968b425
...
...
@@ -19,6 +19,7 @@ declare(strict_types=1);
namespace
Firegento\ContentProvisioning\Model
;
use
Firegento\ContentProvisioning\Model\Query\GetExistsInDbValueByKey
;
use
Symfony\Component\Console\Helper\Table
;
class
RenderChangedBlockList
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment