-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
873 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace oat\taoItems\migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use oat\oatbox\event\EventManager; | ||
use oat\oatbox\reporting\Report; | ||
use oat\tao\model\accessControl\func\AccessRule; | ||
use oat\tao\model\accessControl\func\AclProxy; | ||
use oat\tao\model\menu\SectionVisibilityFilter; | ||
use oat\tao\scripts\tools\migrations\AbstractMigration; | ||
use oat\tao\scripts\update\OntologyUpdater; | ||
use oat\taoItems\model\event\ItemCreatedEvent; | ||
use oat\taoItems\model\event\ItemRemovedEvent; | ||
use oat\taoItems\model\event\ItemUpdatedEvent; | ||
use oat\taoItems\model\Translation\Listener\TranslationItemEventListener; | ||
use oat\taoItems\model\user\TaoItemsRoles; | ||
|
||
final class Version202409060743452142_taoItems extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add new Item Translator Role, sync models and add new listener'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
OntologyUpdater::syncModels(); | ||
|
||
AclProxy::applyRule($this->getRule()); | ||
|
||
$this->addReport(Report::createSuccess('Applied rules for role ' . TaoItemsRoles::ITEM_TRANSLATOR)); | ||
|
||
/** @var SectionVisibilityFilter $sectionVisibilityFilter */ | ||
$sectionVisibilityFilter = $this->getServiceManager()->get(SectionVisibilityFilter::SERVICE_ID); | ||
|
||
$sectionVisibilityFilter->showSectionByFeatureFlag( | ||
$sectionVisibilityFilter->createSectionPath( | ||
[ | ||
'manage_items', | ||
'item-translate' | ||
] | ||
), | ||
'FEATURE_FLAG_TRANSLATION_ENABLED' | ||
); | ||
$this->getServiceManager()->register(SectionVisibilityFilter::SERVICE_ID, $sectionVisibilityFilter); | ||
|
||
$this->addReport( | ||
Report::createSuccess('Hide item section for feature flag FEATURE_FLAG_TRANSLATION_ENABLED') | ||
); | ||
|
||
/** @var EventManager $eventManager */ | ||
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID); | ||
$eventManager->attach( | ||
ItemCreatedEvent::class, | ||
[TranslationItemEventListener::class, 'populateTranslationProperties'] | ||
); | ||
$eventManager->attach( | ||
ItemUpdatedEvent::class, | ||
[TranslationItemEventListener::class, 'populateTranslationProperties'] | ||
); | ||
$eventManager->attach( | ||
ItemRemovedEvent::class, | ||
[TranslationItemEventListener::class, 'deleteTranslations'] | ||
); | ||
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager); | ||
|
||
$this->addReport( | ||
Report::createSuccess('Listen to ' . ItemCreatedEvent::class . ' at ' . TranslationItemEventListener::class) | ||
); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
AclProxy::revokeRule($this->getRule()); | ||
|
||
/** @var EventManager $eventManager */ | ||
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID); | ||
$eventManager->detach( | ||
ItemCreatedEvent::class, | ||
[TranslationItemEventListener::class, 'populateTranslationProperties'] | ||
); | ||
$eventManager->detach( | ||
ItemUpdatedEvent::class, | ||
[TranslationItemEventListener::class, 'populateTranslationProperties'] | ||
); | ||
$eventManager->detach( | ||
ItemRemovedEvent::class, | ||
[TranslationItemEventListener::class, 'deleteTranslations'] | ||
); | ||
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager); | ||
} | ||
|
||
private function getRule(): AccessRule | ||
{ | ||
return new AccessRule( | ||
AccessRule::GRANT, | ||
TaoItemsRoles::ITEM_TRANSLATOR, | ||
[ | ||
'ext' => 'tao', | ||
'mod' => 'Translation' | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* This program 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; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program 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. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2024 (original work) Open Assessment Technologies SA. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace oat\taoItems\model\Form\Modifier; | ||
|
||
use oat\tao\model\form\Modifier\AbstractFormModifier; | ||
|
||
final class FormModifierProxy extends AbstractFormModifier | ||
{ | ||
} |
51 changes: 51 additions & 0 deletions
51
models/classes/Form/ServiceProvider/FormServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** | ||
* This program 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; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program 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. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2024 (original work) Open Assessment Technologies SA. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace oat\taoItems\model\Form\ServiceProvider; | ||
|
||
use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface; | ||
use oat\tao\model\form\Modifier\UniqueIdFormModifier; | ||
use oat\taoItems\model\Form\Modifier\FormModifierProxy; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service; | ||
|
||
class FormServiceProvider implements ContainerServiceProviderInterface | ||
{ | ||
public function __invoke(ContainerConfigurator $configurator): void | ||
{ | ||
$services = $configurator->services(); | ||
|
||
$services | ||
->set(FormModifierProxy::class, FormModifierProxy::class) | ||
->public(); | ||
|
||
$services | ||
->get(FormModifierProxy::class) | ||
->call( | ||
'addModifier', | ||
[ | ||
service(UniqueIdFormModifier::class), | ||
] | ||
); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
models/classes/Translation/Form/Modifier/TranslationFormModifierProxy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* This program 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; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program 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. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2024 (original work) Open Assessment Technologies SA. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace oat\taoItems\model\Translation\Form\Modifier; | ||
|
||
use oat\tao\model\form\Modifier\AbstractFormModifier; | ||
|
||
final class TranslationFormModifierProxy extends AbstractFormModifier | ||
{ | ||
} |
Oops, something went wrong.