-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
2,647 additions
and
29 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
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
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
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,45 @@ | ||
<?php | ||
|
||
/** | ||
* Select multiple | ||
* | ||
* @package Slick\Form\Element | ||
* @author Filipe Silva <silvam.filipe@gmail.com> | ||
* @copyright 2014 Filipe Silva | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
* @since Version 1.1.0 | ||
*/ | ||
|
||
namespace Slick\Form\Element; | ||
use Slick\Form\Template\AbstractTemplate; | ||
|
||
/** | ||
* Select multiple | ||
* | ||
* @package Slick\Form\Element | ||
* @author Filipe Silva <silvam.filipe@gmail.com> | ||
*/ | ||
class SelectMultiple extends Select | ||
{ | ||
|
||
/** | ||
* @readwrite | ||
* @var array HTML attributes | ||
*/ | ||
protected $_attributes = [ | ||
'multiple' | ||
]; | ||
|
||
/** | ||
* lazy loads a default template for this element | ||
* | ||
* @return AbstractTemplate | ||
*/ | ||
public function getTemplate() | ||
{ | ||
if (is_null($this->_template)) { | ||
$this->_template = new \Slick\Form\Template\SelectMultiple(); | ||
} | ||
return $this->_template; | ||
} | ||
} |
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
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,29 @@ | ||
<?php | ||
|
||
/** | ||
* SelectMultiple input | ||
* | ||
* @package Slick\Form\Template | ||
* @author Filipe Silva <silvam.filipe@gmail.com> | ||
* @copyright 2014 Filipe Silva | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
* @since Version 1.1.0 | ||
*/ | ||
|
||
namespace Slick\Form\Template; | ||
|
||
/** | ||
* SelectMultiple input | ||
* | ||
* @package Slick\Form\Template | ||
* @author Filipe Silva <silvam.filipe@gmail.com> | ||
*/ | ||
class SelectMultiple extends AbstractTemplate | ||
{ | ||
|
||
/** | ||
* @readwrite | ||
* @var string | ||
*/ | ||
protected $_templateFile = 'selectMultiple-input.html.twig'; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Slick/Form/Template/Views/selectMultiple-input.html.twig
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,13 @@ | ||
{% extends "default-input.html.twig" %} | ||
|
||
{% block inputElement %} | ||
<select name="{{ element.getName }}[]" id="{{ element.getName() }}-input" {{ element.getHtmlAttributes|raw }}> | ||
{% for key, value in element.getOptions() %} | ||
{% if key == element.getValue() %} | ||
<option selected="selected" value="{{ key }}">{{ value }}</option> | ||
{% else %} | ||
<option value="{{ key }}">{{ value }}</option> | ||
{% endif %} | ||
{% endfor %} | ||
</select> | ||
{% endblock %} |
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
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
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
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,127 @@ | ||
<?php | ||
|
||
/** | ||
* Generate controller command | ||
* | ||
* @package Slick\Mvc\Command | ||
* @author Filipe Silva <silvam.filipe@gmail.com> | ||
* @copyright 2014 Filipe Silva | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
* @since Version 1.0.0 | ||
*/ | ||
|
||
namespace Slick\Mvc\Command; | ||
|
||
use Slick\Mvc\Command\Task\GenerateScaffoldController; | ||
use Slick\Mvc\Command\Task\GenerateController as GenerateControllerTask; | ||
use Slick\Mvc\Command\Utils\ControllerData; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Generate controller command | ||
* | ||
* @package Slick\Mvc\Command | ||
* @author Filipe Silva <silvam.filipe@gmail.com> | ||
*/ | ||
class GenerateController extends Command | ||
{ | ||
|
||
/** | ||
* Configures the current command. | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName("generate:controller") | ||
->setDescription("Generate a controller file for the provided model name.") | ||
->addArgument( | ||
'modelName', | ||
InputArgument::REQUIRED, | ||
'Full qualified model class name' | ||
) | ||
->addOption( | ||
'path', | ||
'p', | ||
InputOption::VALUE_OPTIONAL, | ||
'Sets the application path where controllers are located', | ||
getcwd() | ||
) | ||
->addOption( | ||
'out', | ||
'o', | ||
InputOption::VALUE_OPTIONAL, | ||
'The controllers folder where to save the controller.', | ||
'Controllers' | ||
) | ||
->addOption( | ||
'scaffold', | ||
'S', | ||
InputOption::VALUE_NONE, | ||
'If set the controller will have only the scaffold property set.' | ||
); | ||
} | ||
|
||
/** | ||
* Executes the current command. | ||
* | ||
* This method is not abstract because you can use this class | ||
* as a concrete class. In this case, instead of defining the | ||
* execute() method, you set the code to execute by passing | ||
* a Closure to the setCode() method. | ||
* | ||
* @param InputInterface $input An InputInterface instance | ||
* @param OutputInterface $output An OutputInterface instance | ||
* | ||
* @return null|integer null or 0 if everything went fine, or an error code | ||
* | ||
* @throws \LogicException When this abstract method is not implemented | ||
* @see setCode() | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
|
||
/** @var Application $application */ | ||
$application = $this->getApplication(); | ||
$output->writeln($application->getLongVersion()); | ||
$output->writeln( | ||
"Generate controller for model ". $input->getArgument('modelName') | ||
); | ||
$output->writeln(""); | ||
|
||
$controllerData = new ControllerData( | ||
[ | ||
'controllerName' => $input->getArgument('modelName'), | ||
'namespace' => $input->getOption('out'), | ||
'modelName' => $input->getArgument('modelName') | ||
] | ||
); | ||
|
||
$path = $input->getOption('path'); | ||
$path .= '/'. $input->getOption('out'); | ||
|
||
if ($input->getOption('scaffold')) { | ||
$task = new GenerateScaffoldController( | ||
[ | ||
'command' => $this, | ||
'controllerData' => $controllerData, | ||
'path' => $path | ||
] | ||
); | ||
$task->run($input, $output); | ||
} else { | ||
$task = new GenerateControllerTask( | ||
[ | ||
'command' => $this, | ||
'controllerData' => $controllerData, | ||
'path' => $path | ||
] | ||
); | ||
$task->run($input, $output); | ||
} | ||
} | ||
} |
Oops, something went wrong.