Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored mailer module to 2.0 style #2849

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c718f0e
refactored mailer module to 2.0 style
Guite Apr 19, 2016
6e6ee56
removed old version class
Guite Apr 19, 2016
5193772
typo
Guite Apr 19, 2016
0322d1c
updated installer class
Guite Apr 19, 2016
bb87dba
added config controller
Guite Apr 19, 2016
591cebf
use new header
Guite Apr 19, 2016
8001862
use new header
Guite Apr 19, 2016
6d9b3d3
added missing use statement
Guite Apr 19, 2016
7f2ac37
use shortcut method
Guite Apr 19, 2016
59c68db
typo
Guite Apr 19, 2016
b480870
more changes
Guite Apr 20, 2016
7473bc1
more explicite api
Guite Apr 20, 2016
b61435e
syntax fix
Guite Apr 20, 2016
e8a40ab
syntax fix
Guite Apr 20, 2016
0f724d4
several amendments
Guite Apr 21, 2016
0372eff
added event class and additional events
Guite Apr 21, 2016
776b5ec
updated header
Guite Apr 21, 2016
93e9470
minor typo
Guite Apr 21, 2016
a4c00a9
minor fix for composer.json
Guite Apr 22, 2016
3f0ff10
use redirectToRoute method
Guite Apr 22, 2016
37d1e58
use redirectToRoute method
Guite Apr 22, 2016
3733467
added default for translator option
Guite Apr 22, 2016
fd53812
added default for translator option
Guite Apr 22, 2016
221556b
typo
Guite Apr 22, 2016
efc4b64
form improvements in Settings module
Guite Apr 23, 2016
d69750b
form improvements in Theme module
Guite Apr 23, 2016
187543e
minor docblock fix
Guite Apr 23, 2016
330b1f9
minor improvements
Guite Apr 23, 2016
bbf06b9
minor amendments
Guite Apr 23, 2016
1ca430e
enhanced changelog entry
Guite Apr 25, 2016
d6ad7ff
use config dumper instead of swift mailer argument
Guite Apr 25, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getResponse(Request $request)
} else {
$request->getSession()->getFlashBag()->add('warning', __('Email settings are not yet configured. Please configure them below.'));

return new RedirectResponse($this->container->get('router')->generate('zikulamailermodule_admin_modifyconfig', array(), RouterInterface::ABSOLUTE_URL));
return new RedirectResponse($this->container->get('router')->generate('zikulamailermodule_config_config', array(), RouterInterface::ABSOLUTE_URL));
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/system/BlocksModule/Container/LinkContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ class LinkContainer implements LinkContainerInterface
* @var Translator
*/
private $translator;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need to decide here. I usually leave no space between property declarations. Otherwise we will keep 'fixing' each others code 😉 @cmfcmf @Guite others? opinions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep the blank lines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any way to make styleCI check this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find a way.

/**
* @var RouterInterface
*/
private $router;

/**
* @var PermissionApi
*/
Expand Down Expand Up @@ -87,8 +89,7 @@ private function getAdmin()
'text' => $this->translator->__('Create new block'),
'icon' => 'plus'
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is removed because it was checked twice.

if ($this->permissionApi->hasPermission('ZikulaBlocksModule::', '::', ACCESS_ADD)) {
// A
}
if ($this->permissionApi->hasPermission('ZikulaBlocksModule::', '::', ACCESS_ADD)) {
// B
}

became

if ($this->permissionApi->hasPermission('ZikulaBlocksModule::', '::', ACCESS_ADD)) {
// A
// B
}

}
if ($this->permissionApi->hasPermission('ZikulaBlocksModule::', '::', ACCESS_ADD)) {

$links[] = [
'url' => $this->router->generate('zikulablocksmodule_position_edit'),
'text' => $this->translator->__('Create new block position'),
Expand Down
12 changes: 7 additions & 5 deletions src/system/BlocksModule/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function viewAction(Request $request)
* @Template
*
* @param Request $request
* @throws AccessDeniedException Thrown if the user doesn't have admin access to the module
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function configAction(Request $request)
Expand All @@ -127,22 +128,23 @@ public function configAction(Request $request)
}

$form = $this->createFormBuilder($this->getVars())
->add('collapseable', 'checkbox', ['label' => __('Enable block collapse icons'),
->add('collapseable', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', [
'label' => $this->__('Enable block collapse icons'),
'required' => false
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for correcting these.

->add('save', 'submit', ['label' => 'Save'])
->add('cancel', 'submit', ['label' => 'Cancel'])
->add('save', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Save')])
->add('cancel', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Cancel')])
->getForm();

$form->handleRequest($request);

if ($form->isValid()) {
if ($form->get('save')->isClicked()) {
$this->setVars($form->getData());
$this->addFlash('status', __('Done! Module configuration updated.'));
$this->addFlash('status', $this->__('Done! Module configuration updated.'));
}
if ($form->get('cancel')->isClicked()) {
$this->addFlash('status', __('Operation cancelled.'));
$this->addFlash('status', $this->__('Operation cancelled.'));
}

return $this->redirect($this->generateUrl('zikulablocksmodule_admin_view'));
Expand Down
12 changes: 6 additions & 6 deletions src/system/BlocksModule/Controller/BlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public function deleteAction(Request $request, BlockEntity $blockEntity)
}

$form = $this->createFormBuilder()
->add('delete', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => 'Delete'])
->add('cancel', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => 'Cancel'])
->add('delete', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Delete')])
->add('cancel', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Cancel')])
->getForm();

$form->handleRequest($request);
Expand Down Expand Up @@ -247,11 +247,11 @@ private function getBlockModifyOutput($blockClassInstance, BlockEntity $blockEnt
*/
private function formContentModify(Request $request, BlockEntity $blockEntity = null)
{
$options = [];
if (isset($blockEntity)) {
$options = ['data' => $blockEntity->getContent() == [] ? '' : $blockEntity->getContent()];
} else {
$options = [];
}

$form = $this->createFormBuilder()
->add('content', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', $options)
->getForm();
Expand All @@ -277,7 +277,7 @@ private function formContentModify(Request $request, BlockEntity $blockEntity =
public function viewAction(BlockEntity $blockEntity = null)
{
return $this->render('@ZikulaBlocksModule/Admin/blockview.html.twig', [
'block' => $blockEntity,
]);
'block' => $blockEntity,
]);
}
}
12 changes: 6 additions & 6 deletions src/system/BlocksModule/Controller/PositionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public function editAction(Request $request, BlockPositionEntity $positionEntity
$em = $this->getDoctrine()->getManager();
$em->persist($positionEntity);
$em->flush();
$this->addFlash('status', __('Position saved!'));
$this->addFlash('status', $this->__('Position saved!'));
}
if ($form->get('cancel')->isClicked()) {
$this->addFlash('status', __('Operation cancelled.'));
$this->addFlash('status', $this->__('Operation cancelled.'));
}

return $this->redirect($this->generateUrl('zikulablocksmodule_admin_view'));
Expand Down Expand Up @@ -91,8 +91,8 @@ public function deleteAction(Request $request, BlockPositionEntity $positionEnti
}

$form = $this->createFormBuilder()
->add('delete', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => 'Delete'])
->add('cancel', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => 'Cancel'])
->add('delete', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Delete')])
->add('cancel', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Cancel')])
->getForm();

$form->handleRequest($request);
Expand All @@ -102,10 +102,10 @@ public function deleteAction(Request $request, BlockPositionEntity $positionEnti
$em = $this->getDoctrine()->getManager();
$em->remove($positionEntity);
$em->flush();
$this->addFlash('status', __('Done! Position deleted.'));
$this->addFlash('status', $this->__('Done! Position deleted.'));
}
if ($form->get('cancel')->isClicked()) {
$this->addFlash('status', __('Operation cancelled.'));
$this->addFlash('status', $this->__('Operation cancelled.'));
}

return $this->redirect($this->generateUrl('zikulablocksmodule_admin_view'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* This file is part of the Zikula package.
*
* Copyright Zikula Foundation - http://zikula.org/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


namespace Zikula\BlocksModule\DependencyInjection;

Expand Down
2 changes: 1 addition & 1 deletion src/system/BlocksModule/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<services>
<service id="zikula_blocks_module.container.link_container" class="%zikula_blocks_module.container.link_container.class%">
<argument type="service" id="translator" />
<argument type="service" id="translator.default" />
<argument type="service" id="jms_i18n_routing.router" />
<argument type="service" id="zikula_permissions_module.api.permission" />
<tag name="zikula.link_container"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
</div>
{{ form_end(form) }}
</div>

</div>
{{ adminFooter() }}
109 changes: 66 additions & 43 deletions src/system/ExtensionsModule/Container/LinkContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ class LinkContainer implements LinkContainerInterface
* @var Translator
*/
private $translator;

/**
* @var RouterInterface
*/
private $router;

/**
* @var PermissionApi
*/
Expand Down Expand Up @@ -71,51 +73,72 @@ public function getLinks($type = LinkContainerInterface::TYPE_ADMIN)
*/
private function getAdmin()
{
$links = array();

if ($this->permissionApi->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
$links[] = [
'url' => $this->router->generate('zikulaextensionsmodule_module_viewmodulelist'),
'text' => $this->translator->__('Extension List'),
'icon' => 'list'
];

$links[] = array(
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins'),
'text' => $this->translator->__('Plugins list'),
'icon' => 'table',
'links' => array(
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins'),
'text' => $this->translator->__('All')),
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('state' => \PluginUtil::NOTINSTALLED)),
'text' => $this->translator->__('Not installed')),
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('state' => \PluginUtil::DISABLED)),
'text' => $this->translator->__('Inactive')),
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('state' => \PluginUtil::ENABLED)),
'text' => $this->translator->__('Active'))
));

$links[] = array(
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('systemplugins' => true)),
'text' => $this->translator->__('System Plugins'),
'icon' => 'table',
'links' => array(
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('systemplugins' => true)),
'text' => $this->translator->__('All')),
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('systemplugins' => true, 'state' => \PluginUtil::NOTINSTALLED)),
'text' => $this->translator->__('Not installed')),
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('systemplugins' => true, 'state' => \PluginUtil::DISABLED)),
'text' => $this->translator->__('Inactive')),
array('url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', array('systemplugins' => true, 'state' => \PluginUtil::ENABLED)),
'text' => $this->translator->__('Active'))
));

$links[] = array(
'url' => $this->router->generate('zikulaextensionsmodule_config_config'),
'text' => $this->translator->__('Settings'),
'icon' => 'wrench');
$links = [];

if (!$this->permissionApi->hasPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
return $links;
}

$links[] = [
'url' => $this->router->generate('zikulaextensionsmodule_module_viewmodulelist'),
'text' => $this->translator->__('Extension List'),
'icon' => 'list'
];

$links[] = [
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins'),
'text' => $this->translator->__('Plugins list'),
'icon' => 'table',
'links' => [
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins'),
'text' => $this->translator->__('All')
],
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['state' => \PluginUtil::NOTINSTALLED]),
'text' => $this->translator->__('Not installed')
],
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['state' => \PluginUtil::DISABLED]),
'text' => $this->translator->__('Inactive')
],
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['state' => \PluginUtil::ENABLED]),
'text' => $this->translator->__('Active')
]
]
];

$links[] = [
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['systemplugins' => true]),
'text' => $this->translator->__('System Plugins'),
'icon' => 'table',
'links' => [
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['systemplugins' => true]),
'text' => $this->translator->__('All')
],
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['systemplugins' => true, 'state' => \PluginUtil::NOTINSTALLED]),
'text' => $this->translator->__('Not installed')
],
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['systemplugins' => true, 'state' => \PluginUtil::DISABLED]),
'text' => $this->translator->__('Inactive')
],
[
'url' => $this->router->generate('zikulaextensionsmodule_admin_viewplugins', ['systemplugins' => true, 'state' => \PluginUtil::ENABLED]),
'text' => $this->translator->__('Active')
]
]
];

$links[] = [
'url' => $this->router->generate('zikulaextensionsmodule_config_config'),
'text' => $this->translator->__('Settings'),
'icon' => 'wrench'
];

return $links;
}

Expand Down
4 changes: 2 additions & 2 deletions src/system/ExtensionsModule/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ public function uninstallAction(Request $request, ExtensionEntity $extension)
$blocks = $this->getDoctrine()->getManager()->getRepository('ZikulaBlocksModule:BlockEntity')->findBy(['module' => $extension]);

$form = $this->createFormBuilder()
->add('uninstall', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => 'Delete'])
->add('cancel', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => 'Cancel'])
->add('uninstall', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Delete')])
->add('cancel', 'Symfony\Component\Form\Extension\Core\Type\SubmitType', ['label' => $this->__('Cancel')])
->getForm();
$form->handleRequest($request);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* This file is part of the Zikula package.
*
* Copyright Zikula Foundation - http://zikula.org/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Zikula\ExtensionsModule\DependencyInjection;

Expand Down
2 changes: 1 addition & 1 deletion src/system/ExtensionsModule/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<services>
<service id="zikula_extensions_module.container.link_container" class="%zikula_extensions_module.container.link_container.class%">
<argument type="service" id="translator" />
<argument type="service" id="translator.default" />
<argument type="service" id="jms_i18n_routing.router" />
<argument type="service" id="zikula_permissions_module.api.permission" />
<tag name="zikula.link_container"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</div>
{{ form_end(form) }}
</div>

</div>
{{ adminFooter() }}
<script type="text/javascript">
Expand Down
48 changes: 0 additions & 48 deletions src/system/MailerModule/Api/AdminApi.php

This file was deleted.

Loading