Added more phpDocs for commands

This commit is contained in:
Kévin Gomez 2013-12-14 14:17:10 +00:00
parent a1b30ac4a4
commit f84ab8eefd
6 changed files with 105 additions and 17 deletions

View file

@ -83,7 +83,9 @@ abstract class AbstractCommand extends ContainerAwareCommand
}
/**
* @param KernelInterface $kernel The application kernel.
* @param KernelInterface $kernel The application kernel.
* @param string $cacheDir The directory in which the schemas will
* be copied.
*/
protected function copySchemas(KernelInterface $kernel, $cacheDir)
{
@ -152,9 +154,11 @@ abstract class AbstractCommand extends ContainerAwareCommand
/**
* Return a list of final schema files that will be processed.
*
* @param \Symfony\Component\HttpKernel\KernelInterface $kernel
* @param KernelInterface $kernel The application kernel.
* @param BundleInterface $bundle If given, only the bundle's schemas will
* be returned.
*
* @return array
* @return array A list of schemas.
*/
protected function getFinalSchemas(KernelInterface $kernel, BundleInterface $bundle = null)
{
@ -165,6 +169,16 @@ abstract class AbstractCommand extends ContainerAwareCommand
return $this->getSchemaLocator()->locateFromBundles($kernel->getBundles());
}
/**
* Run a Symfony command.
*
* @param Command $command The command to run.
* @param array $parameters An array of parameters to give to the command.
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int The command return code.
*/
protected function runCommand(Command $command, array $parameters, InputInterface $input, OutputInterface $output)
{
// add the command's name to the parameters
@ -250,6 +264,13 @@ EOT;
return $dsnList;
}
/**
* Get the data (host, user, ...) for a given connection.
*
* @param string $name The connection name.
*
* @return array The connection data.
*/
protected function getConnectionData($name)
{
$knownConnections = $this->getContainer()->getParameter('propel.configuration');
@ -260,6 +281,13 @@ EOT;
return $knownConnections[$name];
}
/**
* Get the DSN for a given connection.
*
* @param string $connectionName The connection name.
*
* @return string The DSN.
*/
protected function getDsn($connectionName)
{
$connection = $this->getConnectionData($connectionName);
@ -300,7 +328,9 @@ EOT;
}
/**
* Check the PropelConfiguration object.
* Check the configuration parameters.
*
* @throws RuntimeException If the configuration is invalid.
*/
protected function checkConfiguration()
{
@ -344,6 +374,13 @@ EOT;
return $this->cacheDir;
}
/**
* Converts an array to its INI equivalent
*
* @param array $data The array to convert.
*
* @return string The INI formatted array.
*/
protected function arrayToIni(array $data)
{
$lines = array();

View file

@ -100,6 +100,11 @@ EOT
}
}
/**
* {@inheritdoc}
*
* @note We override this method to only return the acl-related schema
*/
protected function getFinalSchemas(KernelInterface $kernel, BundleInterface $bundle = null)
{
$aclSchema = new \SplFileInfo($kernel->locateResource('@PropelBundle/Resources/acl_schema.xml'));
@ -111,6 +116,8 @@ EOT
/**
* {@inheritdoc}
*
* @note We override this method to modify the cache directory
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{

View file

@ -48,9 +48,7 @@ EOT
}
/**
* @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{

View file

@ -53,9 +53,7 @@ EOT
}
/**
* @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{

View file

@ -110,9 +110,7 @@ EOT
}
/**
* @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@ -156,6 +154,7 @@ EOT
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param string $type If specified, only fixtures with the given type will be loaded (yml, xml).
*/
protected function loadFixtures(InputInterface $input, OutputInterface $output, $type = null)
{
@ -308,6 +307,8 @@ EOT
/**
* Returns the path the command will look into to find fixture files
*
* @param BundleInterface $bundle The bundle to explore.
*
* @return String
*/
protected function getFixturesPath(BundleInterface $bundle)

View file

@ -33,7 +33,7 @@ class FormGenerateCommand extends AbstractCommand
const DEFAULT_FORM_TYPE_DIRECTORY = '/Form/Type';
/**
* @see Command
* {@inheritdoc}
*/
protected function configure()
{
@ -57,9 +57,7 @@ EOT
}
/**
* @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@ -84,6 +82,15 @@ EOT
}
}
/**
* Create FormTypes from a given database, bundle and models.
*
* @param BundleInterface $bundle The bundle for which the FormTypes will be generated.
* @param Database $database The database to inspect.
* @param array $models The models to build.
* @param OutputInterface $output An OutputInterface instance
* @param boolean $force Override files if present.
*/
protected function createFormTypeFromDatabase(BundleInterface $bundle, Database $database, $models, OutputInterface $output, $force = false)
{
$dir = $this->createDirectory($bundle, $output);
@ -103,6 +110,14 @@ EOT
}
}
/**
* Create the FormType directory and log the result.
*
* @param BundleInterface $bundle The bundle in which we'll create the directory.
* @param OutputInterface $output An OutputInterface instance.
*
* @return string The path to the created directory.
*/
protected function createDirectory(BundleInterface $bundle, OutputInterface $output)
{
$fs = new Filesystem();
@ -115,6 +130,15 @@ EOT
return $dir;
}
/**
* Write a FormType.
*
* @param BundleInterface $bundle The bundle in which the FormType will be created.
* @param Table $table The table for which the FormType will be created.
* @param SplFileInfo $file File representing the FormType.
* @param boolean $force Is the write forced?
* @param OutputInterface $output An OutputInterface instance.
*/
protected function writeFormType(BundleInterface $bundle, Table $table, \SplFileInfo $file, $force, OutputInterface $output)
{
$modelName = $table->getPhpName();
@ -130,6 +154,14 @@ EOT
$this->writeNewFile($output, $this->getRelativeFileName($file) . ($force ? ' (forced)' : ''));
}
/**
* Add the fields in the FormType.
*
* @param Table $table Table from which the fields will be extracted.
* @param string $formTypeContent FormType skeleton.
*
* @return string The FormType code.
*/
protected function addFields(Table $table, $formTypeContent)
{
$buildCode = '';
@ -151,6 +183,13 @@ EOT
return substr(str_replace(realpath($this->getContainer()->getParameter('kernel.root_dir') . '/../'), '', $file), 1);
}
/**
* Get the GeneratorConfig instance to use.
*
* @param InputInterface $input An InputInterface instance.
*
* @return GeneratorConfig
*/
protected function getGeneratorConfig(InputInterface $input)
{
$generatorConfig = array(
@ -190,6 +229,14 @@ EOT
return new GeneratorConfig($generatorConfig);
}
/**
* Get the ModelManager to use.
*
* @param InputInterface $input An InputInterface instance.
* @param array $schemas A list of schemas.
*
* @return ModelManager
*/
protected function getModelManager(InputInterface $input, array $schemas)
{
$schemaFiles = array();