Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webcul-dam
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Akeneo bundles
webcul-dam
Commits
6173dc59
Commit
6173dc59
authored
Oct 27, 2020
by
Krzysztof Kuźniar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update module - fix media asset import path #3
parent
fa14ac42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
DamServices.php
Services/DamServices.php
+28
-12
No files found.
Services/DamServices.php
View file @
6173dc59
...
...
@@ -149,33 +149,38 @@ class DamServices
if
(
filter_var
(
$value
,
FILTER_VALIDATE_URL
))
{
$media
[]
=
$this
->
changeUrlToContent
(
$value
,
$code
,
$index
);
}
else
{
$dataFilePath
=
$value
;
// $mediapath[$index]['data'] = sprintf(
// '%s%s%s',
// $filePath,
// DIRECTORY_SEPARATOR,
// $dataFilePath
// );
$mediapath
=
sprintf
(
'%s%s%s'
,
$filePath
,
DIRECTORY_SEPARATOR
,
$dataFilePath
);
$mediapath
=
$this
->
clean
(
$mediapath
);
// dd($filePath, $mediapath);
try
{
$link_array
=
explode
(
'/'
,
$filePath
);
$page
=
str_replace
(
' '
,
''
,
end
(
$link_array
));
$newFilePath
=
$page
.
'/'
.
$dataFilePath
;
$newFileDirectory
=
substr
(
$newFilePath
,
0
,
strrpos
(
$newFilePath
,
'/'
));
if
(
!
file_exists
(
$newFilePath
)
||
$this
->
overrideImages
)
{
$fileSystemProvide
=
$this
->
fileSystem
;
$fs
=
$fileSystemProvide
->
getFilesystem
(
'tmpStorage'
);
if
(
!
file_exists
(
$newFilePath
)
||
$this
->
overrideImages
)
{
// if ($version > '3.0' && $version < '4.0') {
// $fs = $this->fileSystem->getFilesystem('tmpStorage');
// } else {
// $fs = $this->fileSystem->getFilesystem(\FileStorage::CATALOG_STORAGE_ALIAS);
// }
$fs
=
$this
->
fileSystem
->
getFilesystem
(
'catalogStorage'
);
$content
=
fopen
(
$mediapath
,
'r'
);
try
{
$content
=
fopen
(
$mediapath
,
'r'
);
}
catch
(
\Exception
$e
)
{
dump
(
'Exception : '
,
$e
->
getMessage
());
}
$fs
->
put
(
$newFilePath
,
$content
);
$newFilePath
=
$fs
->
getAdapter
()
->
getPathPrefix
()
.
$newFilePath
;
...
...
@@ -183,15 +188,26 @@ class DamServices
$media
[]
=
$newFilePath
;
}
catch
(
\Exception
$e
)
{
echo
$e
->
getMessage
();
$newFilePath
=
null
;
}
}
}
}
return
$media
;
}
public
function
clean
(
$full_path
){
return
str_replace
(
array
(
"
\\\\
"
,
"
\\
/"
,
"//"
,
"
\\
/"
,
"/
\\
"
),
DIRECTORY_SEPARATOR
,
$full_path
);
}
public
function
getMetricUnits
()
{
$measure
=
$this
->
metric
->
indexAction
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment