Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_news
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_news
Commits
b689e245
Commit
b689e245
authored
6 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASk] First draft of command controller
parent
ae08347b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Feature news migration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Command/MigrateNewsCommandController.php
+120
-0
120 additions, 0 deletions
Classes/Command/MigrateNewsCommandController.php
ext_localconf.php
+6
-1
6 additions, 1 deletion
ext_localconf.php
with
126 additions
and
1 deletion
Classes/Command/MigrateNewsCommandController.php
0 → 100644
+
120
−
0
View file @
b689e245
<?php
namespace
SGalinski\SgNews\Command
;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
SGalinski\SgNews\Domain\Model\News
;
use
SGalinski\SgNews\Service\DataHandler
;
use
TYPO3\CMS\Backend\FrontendBackendUserAuthentication
;
use
TYPO3\CMS\Core\Database\DatabaseConnection
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Extbase\Mvc\Controller\CommandController
;
use
TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings
;
/**
* Command controller, that migrates data from tx_news to sg_news
*/
class
MigrateNewsCommandController
extends
CommandController
{
/**
* @var bool
*/
protected
$requestAdminPermissions
=
TRUE
;
/**
* @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
* @inject
*/
protected
$persistenceManager
;
/**
* @var \SGalinski\SgNews\Domain\Repository\NewsRepository
* @inject
*/
protected
$newsRepository
;
/**
* @param int $copyPageId
*/
public
function
runMigrateNewsCommand
(
$copyPageId
)
{
/** @var DatabaseConnection $db */
$db
=
$GLOBALS
[
'TYPO3_DB'
];
$where
=
'hidden = 0 and deleted = 0'
;
/** @var \mysqli_result $result */
$result
=
$db
->
exec_SELECTquery
(
'*'
,
'tx_news_domain_model_news'
,
$where
,
''
,
''
);
$localDataHandler
=
GeneralUtility
::
makeInstance
(
DataHandler
::
class
);
$beUser
=
$this
->
simulateBackendUser
();
$localCommandMap
=
[
'pages'
=>
[
$copyPageId
=>
[
'copy'
=>
340
]
]
];
$resultArray
=
[];
while
(
$row
=
$result
->
fetch_assoc
())
{
$resultArray
[]
=
$row
;
$localDataHandler
->
start
([],
$localCommandMap
,
$beUser
);
$localDataHandler
->
bypassAccessCheckForRecords
=
TRUE
;
$localDataHandler
->
checkModifyAccessList
(
'pages'
);
$localDataHandler
->
process_cmdmap
();
// get the id of the new object
$newPageId
=
$localDataHandler
->
copyMappingArray
[
'pages'
][
$copyPageId
];
/** @var $querySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */
$querySettings
=
$this
->
objectManager
->
get
(
Typo3QuerySettings
::
class
);
$querySettings
->
setIgnoreEnableFields
(
TRUE
);
$this
->
persistenceManager
->
persistAll
();
$this
->
newsRepository
->
setDefaultQuerySettings
(
$querySettings
);
/** @var News $newsPage */
$newsPage
=
$this
->
newsRepository
->
findByUid
(
$newPageId
);
return
;
}
}
/**
* Simulate Backend User for DataHandler
*/
public
function
simulateBackendUser
()
{
/** @var \TYPO3\CMS\Backend\FrontendBackendUserAuthentication $BE_USER */
$BE_USER
=
GeneralUtility
::
makeInstance
(
FrontendBackendUserAuthentication
::
class
);
$BE_USER
->
setBeUserByName
(
'admin'
);
if
(
$BE_USER
->
user
[
'uid'
])
{
$BE_USER
->
fetchGroupData
();
}
$BE_USER
->
uc_default
[
'copyLevels'
]
=
'9999'
;
$BE_USER
->
uc
=
$BE_USER
->
uc_default
;
$GLOBALS
[
'PAGES_TYPES'
][
254
][
'allowedTables'
]
=
'*'
;
return
$BE_USER
;
}
}
This diff is collapsed.
Click to expand it.
ext_localconf.php
+
6
−
1
View file @
b689e245
...
...
@@ -98,4 +98,9 @@ if(!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
'cms/layout/db_layout.php'
][
'drawHeaderHook'
]
=
[];
}
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
'cms/layout/db_layout.php'
][
'drawHeaderHook'
][]
=
\SGalinski\SgNews\Hooks\PageLayoutController
::
class
.
'->addNewsModuleLink'
;
\ No newline at end of file
\SGalinski\SgNews\Hooks\PageLayoutController
::
class
.
'->addNewsModuleLink'
;
// register command controllers
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
'extbase'
][
'commandControllers'
][]
=
'SGalinski\SgNews\Command\MigrateNewsCommandController'
;
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