-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from sumocoders/switch-to-doctrine-and-symfony-…
…form Switch to doctrine and symfony form
- Loading branch information
Showing
45 changed files
with
1,736 additions
and
1,602 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# @see http://editorconfig.org/ | ||
# | ||
|
||
root = true | ||
|
||
[*.{js,php,py,yml}] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{html,rb,tpl,twig,xml}] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
# | ||
# Following languages aren't used at the moment in Fork CMS, but just in case. | ||
# (for instance: Capistrano is used in a lot of projects for deployment) | ||
# | ||
# [*.{py,rb}] |
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 |
---|---|---|
|
@@ -2,85 +2,40 @@ | |
|
||
namespace Backend\Modules\Partners\Actions; | ||
|
||
/* | ||
* This file is part of Fork CMS. | ||
* | ||
* For the full copyright and license information, please view the license | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Backend\Core\Engine\Base\ActionAdd as BackendBaseActionAdd; | ||
use Backend\Core\Engine\Form as BackendForm; | ||
use Backend\Core\Engine\Language as BL; | ||
use Backend\Core\Engine\Model as BackendModel; | ||
use Backend\Modules\Partners\Engine\Model as BackendPartnersModel; | ||
use Frontend\Modules\Partners\Engine\Model as FrontendPartnersModel; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* This action will add a widget to the partners module. | ||
* | ||
* @author Jelmer Prins <[email protected]> | ||
*/ | ||
class Add extends BackendBaseActionAdd | ||
use Backend\Core\Engine\Base\ActionAdd; | ||
use Backend\Core\Engine\Model; | ||
use Backend\Core\Language\Language; | ||
use Backend\Modules\Partners\Domain\Partner\PartnerType; | ||
use Backend\Modules\Partners\Domain\Partner\Command\CreatePartner; | ||
use Backend\Modules\Partners\Domain\Widget\Command\CreateWidget; | ||
use Backend\Modules\Partners\Domain\Widget\WidgetType; | ||
|
||
class Add extends ActionAdd | ||
{ | ||
/** | ||
* Execute the action | ||
*/ | ||
public function execute() | ||
{ | ||
parent::execute(); | ||
|
||
$this->loadForm(); | ||
$this->validateForm(); | ||
|
||
$this->parse(); | ||
$this->display(); | ||
} | ||
|
||
/** | ||
* Load the form | ||
*/ | ||
private function loadForm() | ||
{ | ||
$this->frm = new BackendForm('add'); | ||
$this->frm->addText('name', null, 255, 'inputText title', 'inputTextError title')->setAttribute('required'); | ||
} | ||
|
||
/** | ||
* Validate the form | ||
*/ | ||
private function validateForm() | ||
{ | ||
if ($this->frm->isSubmitted()) { | ||
$this->frm->cleanupFields(); | ||
|
||
// validation | ||
$this->frm->getField('name')->isFilled(BL::err('NameIsRequired')); | ||
|
||
// no errors? | ||
if ($this->frm->isCorrect()) { | ||
$item['name'] = $this->frm->getField('name')->getValue(); | ||
$item['id'] = BackendPartnersModel::insertWidget($item); | ||
|
||
//create img dir | ||
$fs = new Filesystem(); | ||
$fs->mkdir( | ||
FRONTEND_FILES_PATH . '/' . FrontendPartnersModel::IMAGE_PATH . '/' . $item['id'] . '/48x48' | ||
); | ||
|
||
// everything is saved, so redirect to the overview | ||
$this->redirect( | ||
BackendModel::createURLForAction( | ||
'edit', | ||
null, | ||
null, | ||
array( | ||
'id' => $item['id'] | ||
) | ||
) | ||
); | ||
} | ||
$createWidget = new CreateWidget(); | ||
$form = $this->createForm(WidgetType::class, $createWidget); | ||
$form->handleRequest($this->get('request')); | ||
if (!$form->isValid()) { | ||
$this->tpl->assign('form', $form->createView()); | ||
$this->display(); | ||
|
||
return; | ||
} | ||
$this->get('command_bus')->handle($form->getData()); | ||
|
||
return $this->redirect( | ||
Model::createURLForAction( | ||
'Index', | ||
null, | ||
null, | ||
[ | ||
'report' => 'added', | ||
'var' => $createWidget->title, | ||
] | ||
) | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,71 +2,33 @@ | |
|
||
namespace Backend\Modules\Partners\Actions; | ||
|
||
/* | ||
* This file is part of Fork CMS. | ||
* | ||
* For the full copyright and license information, please view the license | ||
* file that was distributed with this source code. | ||
*/ | ||
use Backend\Core\Engine\Base\ActionDelete; | ||
use Backend\Core\Engine\Model; | ||
use Backend\Modules\Partners\Domain\Widget\Widget; | ||
use Backend\Modules\Partners\Domain\Widget\Command\DeleteWidget; | ||
|
||
use Backend\Core\Engine\Base\ActionDelete as BackendBaseActionDelete; | ||
use Backend\Core\Engine\Model as BackendModel; | ||
use Backend\Modules\Partners\Engine\Model as BackendPartnersModel; | ||
use Frontend\Modules\Partners\Engine\Model as FrontendPartnersModel; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* This action will delete a partner | ||
* | ||
* @author Jelmer Prins <[email protected]> | ||
*/ | ||
class Delete extends BackendBaseActionDelete | ||
class Delete extends ActionDelete | ||
{ | ||
/** | ||
* Execute the action | ||
*/ | ||
public function execute() | ||
{ | ||
$this->id = $this->getParameter('id', 'int'); | ||
$widget = $this->get('partners.repository.widget')->find( | ||
$this->getParameter('id', 'int') | ||
); | ||
|
||
// does the item exist | ||
if ($this->id == null || !BackendPartnersModel::widgetExists($this->id)) { | ||
$this->redirect( | ||
BackendModel::createURLForAction( | ||
'index', | ||
null, | ||
null, | ||
array( | ||
'error' => 'non-existing' | ||
) | ||
) | ||
); | ||
if (!$widget instanceof Widget) { | ||
return $this->redirect(Model::createURLForAction('Index', null, null, ['error' => 'non-existing'])); | ||
} | ||
$this->get('command_bus')->handle(new DeleteWidget($widget)); | ||
|
||
// get data | ||
$this->record = BackendPartnersModel::getWidget($this->id); | ||
|
||
// delete item | ||
BackendPartnersModel::deleteWidget($this->record['id'], $this->record['widget_id']); | ||
|
||
// delete files | ||
$fs = new Filesystem(); | ||
$fs->remove( | ||
FRONTEND_FILES_PATH . '/' . FrontendPartnersModel::IMAGE_PATH . '/' . $this->id | ||
); | ||
|
||
// item was deleted, so redirect | ||
$this->redirect( | ||
BackendModel::createURLForAction( | ||
'index', | ||
return $this->redirect( | ||
Model::createURLForAction( | ||
'Index', | ||
null, | ||
null, | ||
array( | ||
[ | ||
'report' => 'deleted', | ||
'var' => urlencode( | ||
$this->record['name'] | ||
) | ||
) | ||
'var' => $widget->getTitle(), | ||
] | ||
) | ||
); | ||
} | ||
|
Oops, something went wrong.