Skip to content

Commit

Permalink
More tests, reorganize code and minore fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mducharme committed Sep 26, 2017
1 parent 6a996dc commit 86c4f43
Show file tree
Hide file tree
Showing 38 changed files with 487 additions and 196 deletions.
29 changes: 0 additions & 29 deletions src/Charcoal/Ui/AbstractUiItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ abstract class AbstractUiItem extends AbstractEntity implements
use UiItemTrait;
use ViewableTrait;

/**
* A UI item is active by default.
*
* @var boolean
*/
private $active = true;

/**
* Return a new UI item.
Expand Down Expand Up @@ -81,27 +75,4 @@ public function setDependencies(Container $container)
$this->setAuthenticator($container['authenticator']);
$this->setAuthorizer($container['authorizer']);
}

/**
* Activates/deactivates the UI item.
*
* @param boolean $active Activate (TRUE) or deactivate (FALSE) the UI item.
* @return AbstractUiItem Chainable
*/
public function setActive($active)
{
$this->active = !!$active;

return $this;
}

/**
* Determine if the UI item is active.
*
* @return boolean
*/
public function active()
{
return $this->active;
}
}
10 changes: 5 additions & 5 deletions src/Charcoal/Ui/Dashboard/AbstractDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Charcoal\Ui\Dashboard;

use \InvalidArgumentException;
use InvalidArgumentException;

// Intra-module (`charcoal-ui`) dependencies
use \Charcoal\Ui\AbstractUiItem;
use \Charcoal\Ui\Dashboard\DashboardInterface;
use \Charcoal\Ui\Dashboard\DashboardTrait;
use \Charcoal\Ui\Layout\LayoutAwareTrait;
use Charcoal\Ui\AbstractUiItem;
use Charcoal\Ui\Dashboard\DashboardInterface;
use Charcoal\Ui\Dashboard\DashboardTrait;
use Charcoal\Ui\Layout\LayoutAwareTrait;

/**
* A Basic Dashboard
Expand Down
4 changes: 2 additions & 2 deletions src/Charcoal/Ui/Dashboard/DashboardBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Charcoal\Ui\Dashboard;

use \Pimple\Container;
use Pimple\Container;

// From 'charcoal-factory'
use \Charcoal\Factory\FactoryInterface;
use Charcoal\Factory\FactoryInterface;

/**
* Dashboard Builder
Expand Down
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/Dashboard/DashboardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Charcoal\Ui\Dashboard;

// Intra-module (`charcoal-ui`) dependency
use \Charcoal\Ui\UiItemConfig;
use Charcoal\Ui\UiItemConfig;

/**
* A dashboard configuration set.
Expand Down
4 changes: 2 additions & 2 deletions src/Charcoal/Ui/Dashboard/DashboardInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Charcoal\Ui\Dashboard;

// Intra-module (`charcoal-ui`) dependencies
use \Charcoal\Ui\UiItemInterface;
use \Charcoal\Ui\Layout\LayoutAwareInterface;
use Charcoal\Ui\UiItemInterface;
use Charcoal\Ui\Layout\LayoutAwareInterface;

/**
* Defines a dashboard.
Expand Down
5 changes: 1 addition & 4 deletions src/Charcoal/Ui/Dashboard/DashboardTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ public function numWidgets()
*/
protected static function sortWidgetsByPriority($a, $b)
{
$a = $a->priority();
$b = $b->priority();

return ($a < $b) ? (-1) : 1;
return ($a->priority() < $b->priority()) ? (-1) : 1;
}
}
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/Dashboard/GenericDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Charcoal\Ui\Dashboard;

// Intra-module (`charcoal-ui`) dependency
use \Charcoal\Ui\Dashboard\AbstractDashboard;
use Charcoal\Ui\Dashboard\AbstractDashboard;

/**
* A Generic Dashboard
Expand Down
10 changes: 5 additions & 5 deletions src/Charcoal/Ui/Form/FormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Charcoal\Ui\Form;

use \Exception;
use \InvalidArgumentException;
use Exception;
use InvalidArgumentException;

// From 'charcoal-factory'
use \Charcoal\Factory\FactoryInterface;
use Charcoal\Factory\FactoryInterface;

// From 'charcoal-ui'
use \Charcoal\Ui\Form\FormInterface;
use \Charcoal\Ui\FormGroup\FormGroupInterface;
use Charcoal\Ui\Form\FormInterface;
use Charcoal\Ui\FormGroup\FormGroupInterface;

/**
* Provides an implementation of {@see FormInterface}.
Expand Down
10 changes: 5 additions & 5 deletions src/Charcoal/Ui/FormGroup/AbstractFormGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Charcoal\Ui\FormGroup;

// Intra-module (`charcoal-ui`) dependencies
use \Charcoal\Ui\AbstractUiItem;
use \Charcoal\Ui\FormGroup\FormGroupInterface;
use \Charcoal\Ui\FormGroup\FormGroupTrait;
use \Charcoal\Ui\Layout\LayoutAwareInterface;
use \Charcoal\Ui\Layout\LayoutAwareTrait;
use Charcoal\Ui\AbstractUiItem;
use Charcoal\Ui\FormGroup\FormGroupInterface;
use Charcoal\Ui\FormGroup\FormGroupTrait;
use Charcoal\Ui\Layout\LayoutAwareInterface;
use Charcoal\Ui\Layout\LayoutAwareTrait;

/**
* A Basic Form Group
Expand Down
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/FormGroup/FormGroupConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Charcoal\Ui\FormGroup;

// Intra-module (`charcoal-ui`) dependency
use \Charcoal\Ui\UiItemConfig;
use Charcoal\Ui\UiItemConfig;

/**
* A form group configuration set.
Expand Down
34 changes: 2 additions & 32 deletions src/Charcoal/Ui/FormGroup/FormGroupInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Charcoal\Ui\FormGroup;

use \Charcoal\Ui\Form\FormInterface;
use Charcoal\Ui\Form\FormInterface;

/**
* Defines a form group.
Expand Down Expand Up @@ -76,7 +76,7 @@ public function numInputs();
* Set the identifier of the group.
*
* @param string $ident Sidemenu group identifier.
* @return UiGroupingInterface Chainable
* @return FormGroupInterface Chainable
*/
public function setIdent($ident);

Expand All @@ -86,34 +86,4 @@ public function setIdent($ident);
* @return string
*/
public function ident();

/**
* Activates/deactivates the group.
*
* @param boolean $active Activate (TRUE) or deactivate (FALSE) the group.
* @return UiItemInterface Chainable
*/
public function setActive($active);

/**
* Determine if the group is active.
*
* @return boolean
*/
public function active();

/**
* Set the group's priority or sorting index.
*
* @param integer $priority An index, for sorting.
* @return UiGroupingInterface Chainable
*/
public function setPriority($priority);

/**
* Retrieve the group's priority or sorting index.
*
* @return integer
*/
public function priority();
}
45 changes: 4 additions & 41 deletions src/Charcoal/Ui/FormGroup/FormGroupTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Charcoal\Ui\FormGroup;

use \InvalidArgumentException;
use InvalidArgumentException;

// Intra-module (`charcoal-ui`) dependencies
use \Charcoal\Ui\Form\FormInterface;
use \Charcoal\Ui\FormInput\FormInputBuilder;
use \Charcoal\Ui\FormInput\FormInputInterface;
use Charcoal\Ui\Form\FormInterface;
use Charcoal\Ui\FormInput\FormInputBuilder;
use Charcoal\Ui\FormInput\FormInputInterface;

/**
* Provides an implementation of {@see \Charcoal\Ui\FormGroup\FormGroupInterface}.
Expand Down Expand Up @@ -58,13 +58,6 @@ trait FormGroupTrait
*/
private $ident;

/**
* The group's priority.
*
* @var integer
*/
private $priority;

/**
* The required Acl permissions fetch from form group.
*
Expand Down Expand Up @@ -251,36 +244,6 @@ public function ident()
return $this->ident;
}

/**
* Set the group's priority or sorting index.
*
* @param integer $priority An index, for sorting.
* @throws InvalidArgumentException If the priority is not an integer.
* @return self
*/
public function setPriority($priority)
{
if (!is_numeric($priority)) {
throw new InvalidArgumentException(
'Priority must be an integer'
);
}

$this->priority = intval($priority);

return $this;
}

/**
* Retrieve the group's priority or sorting index.
*
* @return integer
*/
public function priority()
{
return $this->priority;
}

/**
* @param string|\string[] $classes Class or Classes for tab form group.
* @return self
Expand Down
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/FormGroup/GenericFormGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Charcoal\Ui\FormGroup;

use \Charcoal\Ui\FormGroup\AbstractFormGroup;
use Charcoal\Ui\FormGroup\AbstractFormGroup;

/**
* A Generic Form Group
Expand Down
4 changes: 2 additions & 2 deletions src/Charcoal/Ui/FormInput/AbstractFormInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Charcoal\Ui\FormInput;

// Intra-module (`charcoal-ui`) dependencies
use \Charcoal\Ui\AbstractUiItem;
use \Charcoal\Ui\FormGroup\FormGroupInterface;
use Charcoal\Ui\AbstractUiItem;
use Charcoal\Ui\FormGroup\FormGroupInterface;

/**
* A Basic Form Input
Expand Down
4 changes: 2 additions & 2 deletions src/Charcoal/Ui/FormInput/FormInputBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Charcoal\Ui\FormInput;

use \Pimple\Container;
use Pimple\Container;

// From 'charcoal-factory'
use \Charcoal\Factory\FactoryInterface;
use Charcoal\Factory\FactoryInterface;

/**
* Form Input Builder
Expand Down
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/FormInput/FormInputConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Charcoal\Ui\Dashboard;

// Intra-module (`charcoal-ui`) dependency
use \Charcoal\Ui\UiItemConfig;
use Charcoal\Ui\UiItemConfig;

/**
* A form input configuration set.
Expand Down
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/FormInput/FormInputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Charcoal\Ui\FormInput;

// Intra-module (`charcoal-ui`) dependency
use \Charcoal\Ui\FormGroup\FormGroupInterface;
use Charcoal\Ui\FormGroup\FormGroupInterface;

/**
* Defines a form input.
Expand Down
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/FormInput/GenericFormInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Charcoal\Ui\FormInput;

use \Charcoal\Ui\FormInput\AbstractFormInput;
use Charcoal\Ui\FormInput\AbstractFormInput;

/**
* A Generic Form Input
Expand Down
6 changes: 3 additions & 3 deletions src/Charcoal/Ui/Layout/AbstractLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Charcoal\Ui\Layout;

// From 'charcoal-config'
use \Charcoal\Config\AbstractEntity;
use Charcoal\Config\AbstractEntity;

// Intra-module (`charcoal-ui`) dependencies
use \Charcoal\Ui\Layout\LayoutInterface;
use \Charcoal\Ui\Layout\LayoutTrait;
use Charcoal\Ui\Layout\LayoutInterface;
use Charcoal\Ui\Layout\LayoutTrait;

/**
* A Basic Layout
Expand Down
2 changes: 1 addition & 1 deletion src/Charcoal/Ui/Layout/GenericLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Charcoal\Ui\Layout;

use \Charcoal\Ui\Layout\AbstractLayout;
use Charcoal\Ui\Layout\AbstractLayout;

/**
* A Generic Layout
Expand Down
9 changes: 6 additions & 3 deletions src/Charcoal/Ui/Layout/LayoutFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Charcoal\Ui\Layout;

use \Charcoal\Factory\ResolverFactory;
use Charcoal\Factory\ResolverFactory;

use Charcoal\Ui\Layout\LayoutInterface;
use Charcoal\Ui\Layout\GenericLayout;

/**
* Layout Factory
Expand All @@ -14,15 +17,15 @@ class LayoutFactory extends ResolverFactory
*/
public function baseClass()
{
return '\Charcoal\Ui\Layout\LayoutInterface';
return LayoutInterface::class;
}

/**
* @return string
*/
public function defaultClass()
{
return '\Charcoal\Ui\Layout\GenericLayout';
return GenericLayout::class;
}

/**
Expand Down

0 comments on commit 86c4f43

Please sign in to comment.