Skip to content

Commit

Permalink
Merge pull request #49 from jedi58/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jedi58 committed May 7, 2016
2 parents b5cc526 + 61b2e72 commit ca66c5e
Show file tree
Hide file tree
Showing 17 changed files with 391 additions and 392 deletions.
8 changes: 4 additions & 4 deletions src/Inachis/Common/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Application
/**
* @var string The mode for the current environment; limited to {@link Application::MODES}
*/
protected $env = 'dev';
protected static $env = 'dev';
/**
* @var ConfigManager Instance used for handling Application config
*/
Expand Down Expand Up @@ -59,9 +59,9 @@ public static function getInstance($env = 'dev')
* Returns the current environment mode
* @return string The current environment
*/
public function getEnv()
public static function getEnv()
{
return $this->env;
return self::$env;
}
/**
* Returns the {@link Application}'s {@link RoutingManager} object
Expand Down Expand Up @@ -89,7 +89,7 @@ public function setEnv($value)
if (!in_array($value, self::MODES)) {
throw new Exception\InvalidEnvironmentException('Mode ' . $value . ' not supported');
}
$this->env = $value;
self::$env = $value;
}
/**
* Returns the path to the root of where the application has been installed
Expand Down
192 changes: 96 additions & 96 deletions src/Inachis/Common/Form/AbstractFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,101 @@
*/
abstract class AbstractFormType
{
/**
* @var string The id of the element
*/
protected $id;
/**
* @var string The name of the element
*/
protected $name;
/**
* @var string[] The array of classes to apply to the object
*/
protected $cssClasses = array();
/**
* @var string[] Array of attributes for the element; e.g. 'item' => 'test'
* would be output as `data-item="test"` by the view
*/
protected $dataAttributes = array();
/**
* @var string The id of the element
*/
protected $id;
/**
* @var string The name of the element
*/
protected $name;
/**
* @var string[] The array of classes to apply to the object
*/
protected $cssClasses = array();
/**
* @var string[] Array of attributes for the element; e.g. 'item' => 'test'
* would be output as `data-item="test"` by the view
*/
protected $dataAttributes = array();
/**
* Returns the type of the current element
* @return string The type of the current element
*/
abstract public function getType();
/**
* Sets the ID for the current form element
* @var string $value The new ID for the form
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
*/
public function setId($value)
{
if (!empty($value) && !preg_match('/^[a-zA-Z0-9\-\_]+$/', $value)) {
throw new FormBuilderConfigurationException(sprintf('Invalid id attribute \'%s\'.', $value));
}
$this->id = $value;
abstract public function getType();
/**
* Sets the ID for the current form element
* @var string $value The new ID for the form
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
*/
public function setId($value)
{
if (!empty($value) && !preg_match('/^[a-zA-Z0-9\-\_]+$/', $value)) {
throw new FormBuilderConfigurationException(sprintf('Invalid id attribute \'%s\'.', $value));
}
$this->id = $value;
return $this;
}
/**
* Returns the ID of the current form element
* @return string The ID of the form element
*/
public function getId()
{
return $this->id;
}
/**
* Sets the name for the current form element
* @var string $value The new name for the form
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
*/
public function setName($value)
{
if (!$this->isValidName($value)) {
throw new FormBuilderConfigurationException(sprintf('Invalid name attribute \'%s\'.', $value));
}
if (in_array($this->getType(), array('checkbox', 'radio')) && !mb_strpos($value, '[]')) {
$value .= '[]';
}
$this->name = $value;
}
/**
* Returns the ID of the current form element
* @return string The ID of the form element
*/
public function getId()
{
return $this->id;
}
/**
* Sets the name for the current form element
* @var string $value The new name for the form
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
*/
public function setName($value)
{
if (!$this->isValidName($value)) {
throw new FormBuilderConfigurationException(sprintf('Invalid name attribute \'%s\'.', $value));
}
if (in_array($this->getType(), array('checkbox', 'radio')) && !mb_strpos($value, '[]')) {
$value .= '[]';
}
$this->name = $value;
return $this;
}
/**
* Returns the name of the current form element
* @return string The name of the form element
*/
public function getName()
{
return $this->name;
}
}
/**
* Returns the name of the current form element
* @return string The name of the form element
*/
public function getName()
{
return $this->name;
}
/**
* Sets the array of CSS classes to apply to the element
* @var string[] $value The CSS to apply to the element
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
* Sets the array of CSS classes to apply to the element
* @var string[] $value The CSS to apply to the element
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
*/
public function setCssClasses($value)
{
if (!is_array($value)) {
throw new FormBuilderConfigurationException(sprintf('Array required, %s provided', gettype($value)));
}
$this->cssClasses = $value;
return $this;
if (!is_array($value)) {
throw new FormBuilderConfigurationException(sprintf('Array required, %s provided', gettype($value)));
}
$this->cssClasses = $value;
return $this;
}
public function setCssClassesFromString($value)
{
$this->cssClasses = explode(' ', $value);
return $this;
$this->cssClasses = explode(' ', $value);
return $this;
}
/**
* Returns the array of CSS classes for the form element
* @return string[] The array of CSS classes for the element
*/
public function getCssClasses()
{
return $this->cssClasses;
return $this->cssClasses;
}
/**
* Returns the array of CSS classes as a string so it can be used
Expand All @@ -113,37 +113,37 @@ public function getCssClasses()
*/
public function getCssClassesAsString()
{
return implode(' ', $this->cssClasses);
return implode(' ', $this->cssClasses);
}
/**
* Adds a CSS classname to the form element
* @var string $value The CSS class to add
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
* Adds a CSS classname to the form element
* @var string $value The CSS class to add
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
*/
public function addCssClass($value)
{
if (!$this->isValidName($value)) {
throw new FormBuilderConfigurationException(sprintf('Class name \'%s\' is invalid', $value));
}
$this->cssClasses[] = $value;
return $this;
if (!$this->isValidName($value)) {
throw new FormBuilderConfigurationException(sprintf('Class name \'%s\' is invalid', $value));
}
$this->cssClasses[] = $value;
return $this;
}
/**
* Removes a CSS classname to the form element
* @var string $value The CSS class to remove
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
* Removes a CSS classname to the form element
* @var string $value The CSS class to remove
* @return AbstractFormType A reference to itself
* @throws FormBuilderConfigurationException
*/
public function removeCssClass($value)
{
if (!isset($this->cssClasses[$value])) {
throw new FormBuilderConfigurationException(
sprintf('Class \'%s\' does not exist - could not be removed', $value)
);
}
unset($this->cssClasses[$value]);
return $this;
if (!isset($this->cssClasses[$value])) {
throw new FormBuilderConfigurationException(
sprintf('Class \'%s\' does not exist - could not be removed', $value)
);
}
unset($this->cssClasses[$value]);
return $this;
}
/**
* Validates the name for the form to confirm it's valid in HTML
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/AbstractSelectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Inachis\Component\Common\Form\FormComponent;
use Inachis\Component\Common\Exception\FormBuilderConfigurationException;

/**
* Object for handling select fields
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/ButtonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Inachis\Component\Common\Form\FormComponent;
use Inachis\Component\Common\Exception\FormBuilderConfigurationException;

/**
* Object for handling `type="button|submit"` buttons
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Inachis\Component\Common\Form\FormComponent;
use Inachis\Component\Common\Exception\FormBuilderConfigurationException;

/**
* Object for handling `type="checkbox"` fields
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/FileUploadType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Inachis\Component\Common\Form\FormComponent;
use Inachis\Component\Common\Exception\FormBuilderConfigurationException;

/**
* Object for handling `type="file"` fields
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/HiddenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Inachis\Component\Common\Form\Fields;

use Inachis\Component\Common\Form\FormComponent;

/**
* Object for handling `type="hidden"` buttons
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/NumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Inachis\Component\Common\Form\FormComponent;
use Inachis\Component\Common\Exception\FormBuilderConfigurationException;

/**
* Object for handling `type="date|datetime|datetime-local"` fields
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Inachis/Common/Form/Fields/SelectOptionGroupType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Inachis\Component\Common\Form\Fields;

use Inachis\Component\Common\Form\FormComponent;

/**
* Object for handling select fields
*/
Expand Down Expand Up @@ -55,6 +54,6 @@ public function getLabel()
*/
public function getLabelAsId()
{
return preg_replace('/[^a-zA-Z0-9\-\_]/', '', lcfirst(ucwords(strtolower($this->label))));
return preg_replace('/[^a-zA-Z0-9\-\_]/','', lcfirst(ucwords(strtolower($this->label))));
}
}
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/SelectOptionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Inachis\Component\Common\Form\Fields;

use Inachis\Component\Common\Form\FormComponent;

/**
* Object for handling select fields
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/SelectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Inachis\Component\Common\Form\Fields;

use Inachis\Component\Common\Form\FormComponent;

/**
* Object for handling select fields
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/TextAreaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Inachis\Component\Common\Form\FormComponent;
use Inachis\Component\Common\Exception\FormBuilderConfigurationException;

/**
* Object for handling textarea fields
*/
Expand Down
1 change: 0 additions & 1 deletion src/Inachis/Common/Form/Fields/TextType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Inachis\Component\Common\Form\FormComponent;
use Inachis\Component\Common\Exception\FormBuilderConfigurationException;

/**
* Object for handling `type="text"` fields
*/
Expand Down
Loading

0 comments on commit ca66c5e

Please sign in to comment.