Skip to content

Commit

Permalink
[imp] create common base views ready for usage
Browse files Browse the repository at this point in the history
  • Loading branch information
phproberto committed Jun 8, 2018
1 parent 52283b9 commit 3d6e66f
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
40 changes: 40 additions & 0 deletions extensions/libraries/twig/src/View/FormView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @package Phproberto.Joomla-Twig
* @subpackage Twig
*
* @copyright Copyright (C) 2017-2018 Roberto Segura López, Inc. All rights reserved.
* @license See COPYING.txt
*/

namespace Phproberto\Joomla\Twig\View;

defined('_JEXEC') || die;

use Phproberto\Joomla\Twig\View\HtmlView;

/**
* Base form view.
*
* @since 0.1.6
*/
abstract class FormView extends HtmlView
{
/**
* Load layout data.
*
* @return self
*/
protected function loadLayoutData()
{
$model = $this->getModel();

return array_merge(
parent::loadLayoutData(),
[
'form' => $model->getForm(),
'model' => $model
]
);
}
}
37 changes: 37 additions & 0 deletions extensions/libraries/twig/src/View/ItemFormView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* @package Phproberto.Joomla-Twig
* @subpackage Twig
*
* @copyright Copyright (C) 2017-2018 Roberto Segura López, Inc. All rights reserved.
* @license See COPYING.txt
*/

namespace Phproberto\Joomla\Twig\View;

defined('_JEXEC') || die;

use Phproberto\Joomla\Twig\View\ItemView;

/**
* Base item form view.
*
* @since 0.1.6
*/
abstract class ItemFormView extends ItemView
{
/**
* Load layout data.
*
* @return self
*/
protected function loadLayoutData()
{
return array_merge(
parent::loadLayoutData(),
[
'form' => $this->getModel()->getForm()
]
);
}
}
40 changes: 40 additions & 0 deletions extensions/libraries/twig/src/View/ItemView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @package Phproberto.Joomla-Twig
* @subpackage Twig
*
* @copyright Copyright (C) 2017-2018 Roberto Segura López, Inc. All rights reserved.
* @license See COPYING.txt
*/

namespace Phproberto\Joomla\Twig\View;

defined('_JEXEC') || die;

use Phproberto\Joomla\Twig\View\HtmlView;

/**
* Base item view.
*
* @since __DEPLOY_VERSION__
*/
abstract class ItemView extends HtmlView
{
/**
* Load layout data.
*
* @return self
*/
protected function loadLayoutData()
{
$model = $this->getModel();

return array_merge(
parent::loadLayoutData(),
[
'item' => $model->getItem(),
'model' => $model
]
);
}
}
44 changes: 44 additions & 0 deletions extensions/libraries/twig/src/View/ListView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* @package Phproberto.Joomla-Twig
* @subpackage Twig
*
* @copyright Copyright (C) 2017-2018 Roberto Segura López, Inc. All rights reserved.
* @license See COPYING.txt
*/

namespace Phproberto\Joomla\Twig\View;

defined('_JEXEC') || die;

use Phproberto\Joomla\Twig\View\HtmlView;

/**
* Base list view.
*
* @since __DEPLOY_VERSION__
*/
abstract class ListView extends HtmlView
{
/**
* Load layout data.
*
* @return self
*/
protected function loadLayoutData()
{
$model = $this->getModel();

return array_merge(
parent::loadLayoutData(),
[
'items' => $model->getItems(),
'state' => $model->getState(),
'pagination' => $model->getPagination(),
'filterForm' => $model->getFilterForm(),
'activeFilters' => $model->getActiveFilters(),
'model' => $model
]
);
}
}

0 comments on commit 3d6e66f

Please sign in to comment.