Fixed CS
This commit is contained in:
parent
4f9a41df37
commit
ab50b5ec39
|
@ -32,21 +32,47 @@ abstract class AbstractPropelCommand extends ContainerAwareCommand
|
|||
* @var array
|
||||
*/
|
||||
protected $additionalPhingArgs = array();
|
||||
|
||||
/**
|
||||
* Temporary XML schemas used on command execution.
|
||||
* @var array
|
||||
*/
|
||||
protected $tempSchemas = array();
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $cacheDir = null;
|
||||
|
||||
/**
|
||||
* The Phing output.
|
||||
* @string
|
||||
*/
|
||||
protected $buffer = null;
|
||||
|
||||
/**
|
||||
* Return the package prefix for a given bundle.
|
||||
*
|
||||
* @param Bundle $bundle
|
||||
* @param string $baseDirectory The base directory to exclude from prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function getPackagePrefix(Bundle $bundle, $baseDirectory = '')
|
||||
{
|
||||
$parts = explode(DIRECTORY_SEPARATOR, realpath($bundle->getPath()));
|
||||
$length = count(explode('\\', $bundle->getNamespace())) * (-1);
|
||||
|
||||
$prefix = implode(DIRECTORY_SEPARATOR, array_slice($parts, 1, $length));
|
||||
$prefix = ltrim(str_replace($baseDirectory, '', $prefix), DIRECTORY_SEPARATOR);
|
||||
|
||||
if (!empty($prefix)) {
|
||||
$prefix = str_replace(DIRECTORY_SEPARATOR, '.', $prefix).'.';
|
||||
}
|
||||
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -138,40 +164,6 @@ abstract class AbstractPropelCommand extends ContainerAwareCommand
|
|||
return $returnStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles arguments/properties for the Phing process.
|
||||
* @return array
|
||||
*/
|
||||
private function getPhingArguments(KernelInterface $kernel, $workingDirectory, $properties)
|
||||
{
|
||||
$args = array();
|
||||
|
||||
// Default properties
|
||||
$properties = array_merge(array(
|
||||
'propel.database' => 'mysql',
|
||||
'project.dir' => $workingDirectory,
|
||||
'propel.output.dir' => $kernel->getRootDir().'/propel',
|
||||
'propel.php.dir' => $kernel->getRootDir().'/..',
|
||||
'propel.packageObjectModel' => true,
|
||||
), $properties);
|
||||
|
||||
// Adding user defined properties from the configuration
|
||||
$properties = array_merge(
|
||||
$properties,
|
||||
$this->getContainer()->get('propel.build_properties')->getProperties()
|
||||
);
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
$args[] = "-D$key=$value";
|
||||
}
|
||||
|
||||
// Build file
|
||||
$args[] = '-f';
|
||||
$args[] = realpath($this->getContainer()->getParameter('propel.path').'/generator/build.xml');
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param KernelInterface $kernel The application kernel.
|
||||
*/
|
||||
|
@ -188,7 +180,6 @@ abstract class AbstractPropelCommand extends ContainerAwareCommand
|
|||
$finalSchemas = array();
|
||||
|
||||
foreach ($kernel->getBundles() as $bundle) {
|
||||
|
||||
if (is_dir($dir = $bundle->getPath().'/Resources/config')) {
|
||||
$finder = new Finder();
|
||||
$schemas = $finder->files()->name('*schema.xml')->followLinks()->in($dir);
|
||||
|
@ -220,7 +211,6 @@ abstract class AbstractPropelCommand extends ContainerAwareCommand
|
|||
$file = $cacheDir.DIRECTORY_SEPARATOR.$tempSchema;
|
||||
$filesystem->copy((string) $finalSchema, $file, true);
|
||||
|
||||
|
||||
// the package needs to be set absolute
|
||||
// besides, the automated namespace to package conversion has
|
||||
// not taken place yet so it needs to be done manually
|
||||
|
@ -253,41 +243,6 @@ abstract class AbstractPropelCommand extends ContainerAwareCommand
|
|||
}
|
||||
}
|
||||
|
||||
private function transformToLogicalName(\SplFileInfo $schema, BundleInterface $bundle)
|
||||
{
|
||||
$schemaPath = str_replace($bundle->getPath().'/Resources/config/', '', $schema->getPathname());
|
||||
|
||||
return sprintf('@%s/Resources/config/%s', $bundle->getName(), $schemaPath);
|
||||
}
|
||||
|
||||
private function getFileLocator()
|
||||
{
|
||||
return $this->getContainer()->get('file_locator');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the package prefix for a given bundle.
|
||||
*
|
||||
* @param Bundle $bundle
|
||||
* @param string $baseDirectory The base directory to exclude from prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getPackagePrefix(Bundle $bundle, $baseDirectory = '')
|
||||
{
|
||||
$parts = explode(DIRECTORY_SEPARATOR, realpath($bundle->getPath()));
|
||||
$length = count(explode('\\', $bundle->getNamespace())) * (-1);
|
||||
|
||||
$prefix = implode(DIRECTORY_SEPARATOR, array_slice($parts, 1, $length));
|
||||
$prefix = ltrim(str_replace($baseDirectory, '', $prefix), DIRECTORY_SEPARATOR);
|
||||
|
||||
if (!empty($prefix)) {
|
||||
$prefix = str_replace(DIRECTORY_SEPARATOR, '.', $prefix).'.';
|
||||
}
|
||||
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a 'build.properties' file.
|
||||
*
|
||||
|
@ -391,7 +346,8 @@ EOT;
|
|||
* Return the current Propel cache directory.
|
||||
* @return string The current Propel cache directory.
|
||||
*/
|
||||
protected function getCacheDir() {
|
||||
protected function getCacheDir()
|
||||
{
|
||||
return $this->cacheDir;
|
||||
}
|
||||
|
||||
|
@ -405,7 +361,8 @@ EOT;
|
|||
* @throw \InvalidArgumentException If the connection does not exist.
|
||||
* @return array
|
||||
*/
|
||||
protected function getConnection(InputInterface $input, OutputInterface $output) {
|
||||
protected function getConnection(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$propelConfiguration = $this->getContainer()->get('propel.configuration');
|
||||
$name = $input->getOption('connection') ?: $this->getContainer()->getParameter('propel.dbal.default_connection');
|
||||
|
||||
|
@ -427,8 +384,10 @@ EOT;
|
|||
* @param string $dsn A DSN
|
||||
* @return string The database name extracted from the given DSN
|
||||
*/
|
||||
protected function parseDbName($dsn) {
|
||||
protected function parseDbName($dsn)
|
||||
{
|
||||
preg_match('#dbname=([a-zA-Z0-9\_]+)#', $dsn, $matches);
|
||||
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
|
@ -488,7 +447,7 @@ EOT;
|
|||
*
|
||||
* @param OutputInterface $output The output.
|
||||
* @param string $taskName A task name.
|
||||
* @param Boolean $more Whether to add a 'more details' message or not.
|
||||
* @param Boolean $more Whether to add a 'more details' message or not.
|
||||
*/
|
||||
protected function writeTaskError($output, $taskName, $more = true)
|
||||
{
|
||||
|
@ -501,14 +460,14 @@ EOT;
|
|||
), 'fg=white;bg=red');
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param OutputInterface $output The output.
|
||||
* @param string $filename The filename.
|
||||
*/
|
||||
* @param string $filename The filename.
|
||||
*/
|
||||
protected function writeNewFile($output, $filename)
|
||||
{
|
||||
return $output->writeln('>> <info>File+</info> ' . $filename);
|
||||
}
|
||||
{
|
||||
return $output->writeln('>> <info>File+</info> ' . $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask confirmation from the user.
|
||||
|
@ -521,4 +480,50 @@ EOT;
|
|||
{
|
||||
return $this->getHelperSet()->get('dialog')->askConfirmation($output, $question, $default);
|
||||
}
|
||||
|
||||
private function transformToLogicalName(\SplFileInfo $schema, BundleInterface $bundle)
|
||||
{
|
||||
$schemaPath = str_replace($bundle->getPath().'/Resources/config/', '', $schema->getPathname());
|
||||
|
||||
return sprintf('@%s/Resources/config/%s', $bundle->getName(), $schemaPath);
|
||||
}
|
||||
|
||||
private function getFileLocator()
|
||||
{
|
||||
return $this->getContainer()->get('file_locator');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles arguments/properties for the Phing process.
|
||||
* @return array
|
||||
*/
|
||||
private function getPhingArguments(KernelInterface $kernel, $workingDirectory, $properties)
|
||||
{
|
||||
$args = array();
|
||||
|
||||
// Default properties
|
||||
$properties = array_merge(array(
|
||||
'propel.database' => 'mysql',
|
||||
'project.dir' => $workingDirectory,
|
||||
'propel.output.dir' => $kernel->getRootDir().'/propel',
|
||||
'propel.php.dir' => $kernel->getRootDir().'/..',
|
||||
'propel.packageObjectModel' => true,
|
||||
), $properties);
|
||||
|
||||
// Adding user defined properties from the configuration
|
||||
$properties = array_merge(
|
||||
$properties,
|
||||
$this->getContainer()->get('propel.build_properties')->getProperties()
|
||||
);
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
$args[] = "-D$key=$value";
|
||||
}
|
||||
|
||||
// Build file
|
||||
$args[] = '-f';
|
||||
$args[] = realpath($this->getContainer()->getParameter('propel.path').'/generator/build.xml');
|
||||
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ EOT
|
|||
|
||||
if (false === $this->askConfirmation($output, 'Are you sure ? (y/n) ', false)) {
|
||||
$output->writeln('Aborted, nice decision !');
|
||||
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ EOT
|
|||
'[Propel] Exception',
|
||||
'',
|
||||
$e->getMessage()), 'fg=white;bg=red');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -188,6 +188,7 @@ EOT
|
|||
'[Propel] Exception',
|
||||
'',
|
||||
$e->getMessage()), 'fg=white;bg=red');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -279,8 +280,10 @@ EOT
|
|||
), 'fg=green;bg=black');
|
||||
} else {
|
||||
$this->writeTaskError($output, 'insert-sql', false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ EOT
|
|||
|
||||
if (false === $this->askConfirmation($output, 'Are you sure ? (y/n) ', false)) {
|
||||
$output->writeln('<info>Aborted, nice decision !</info>');
|
||||
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,6 +202,7 @@ abstract class AbstractDataDumper extends AbstractDataHandler implements DataDum
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class XmlDataLoader extends AbstractDataLoader
|
|||
protected function transformDataToArray($file)
|
||||
{
|
||||
$xml = simplexml_load_file($file);
|
||||
|
||||
return $this->simpleXmlToArray($xml);
|
||||
}
|
||||
|
||||
|
@ -54,6 +55,7 @@ class XmlDataLoader extends AbstractDataLoader
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,12 +188,14 @@ class ModelChoiceList extends ArrayChoiceList
|
|||
if (count($this->identifier) > 1) {
|
||||
// $key is a collection index
|
||||
$models = $this->getModels();
|
||||
|
||||
return isset($models[$key]) ? $models[$key] : null;
|
||||
} else if ($this->models) {
|
||||
return isset($this->models[$key]) ? $this->models[$key] : null;
|
||||
}
|
||||
|
||||
$queryClass = $this->class . 'Query';
|
||||
|
||||
return $queryClass::create()->findPk($key);
|
||||
} catch (NoResultException $e) {
|
||||
return null;
|
||||
|
|
|
@ -71,4 +71,4 @@ class ModelType extends AbstractType
|
|||
{
|
||||
return 'model';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ class ModelUserProvider implements UserProviderInterface
|
|||
}
|
||||
|
||||
$proxyClass = $this->proxyClass;
|
||||
|
||||
return new $proxyClass($user);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,10 @@ class BookQuery extends BaseBookQuery {
|
|||
if (1 === $key) {
|
||||
$book = new Book();
|
||||
$book->setId(1);
|
||||
|
||||
return $book;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -40,6 +42,7 @@ class BookQuery extends BaseBookQuery {
|
|||
if ('my-book' == $slug) {
|
||||
$this->bySlug = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -61,8 +64,10 @@ class BookQuery extends BaseBookQuery {
|
|||
$book->setId(1);
|
||||
$book->setName('My Book');
|
||||
$book->setSlug('my-book');
|
||||
|
||||
return $book;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
} // BookQuery
|
||||
|
|
|
@ -20,38 +20,38 @@ use \TableMap;
|
|||
class BookTableMap extends TableMap
|
||||
{
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'vendor/bundles/Propel/PropelBundle/Tests/Fixtures/Model.map.BookTableMap';
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'vendor/bundles/Propel/PropelBundle/Tests/Fixtures/Model.map.BookTableMap';
|
||||
|
||||
/**
|
||||
* Initialize the table attributes, columns and validators
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('book');
|
||||
$this->setPhpName('Book');
|
||||
$this->setClassname('Propel\\PropelBundle\\Tests\\Fixtures\\Model\\Book');
|
||||
$this->setPackage('vendor/bundles/Propel/PropelBundle/Tests/Fixtures/Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('NAME', 'Name', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('SLUG', 'Slug', 'VARCHAR', false, 255, null);
|
||||
// validators
|
||||
} // initialize()
|
||||
/**
|
||||
* Initialize the table attributes, columns and validators
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('book');
|
||||
$this->setPhpName('Book');
|
||||
$this->setClassname('Propel\\PropelBundle\\Tests\\Fixtures\\Model\\Book');
|
||||
$this->setPackage('vendor/bundles/Propel/PropelBundle/Tests/Fixtures/Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('NAME', 'Name', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('SLUG', 'Slug', 'VARCHAR', false, 255, null);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
} // buildRelations()
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
} // buildRelations()
|
||||
|
||||
} // BookTableMap
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -73,6 +73,7 @@ abstract class BaseBookQuery extends ModelCriteria
|
|||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -98,6 +99,7 @@ abstract class BaseBookQuery extends ModelCriteria
|
|||
$stmt = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->getSelectStatement($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +117,7 @@ abstract class BaseBookQuery extends ModelCriteria
|
|||
public function findPks($keys, $con = null)
|
||||
{
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
|
||||
return $this
|
||||
->filterByPrimaryKeys($keys)
|
||||
->find($con);
|
||||
|
@ -167,6 +170,7 @@ abstract class BaseBookQuery extends ModelCriteria
|
|||
if (is_array($id) && null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(BookPeer::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
|
@ -195,6 +199,7 @@ abstract class BaseBookQuery extends ModelCriteria
|
|||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(BookPeer::NAME, $name, $comparison);
|
||||
}
|
||||
|
||||
|
@ -223,6 +228,7 @@ abstract class BaseBookQuery extends ModelCriteria
|
|||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(BookPeer::SLUG, $slug, $comparison);
|
||||
}
|
||||
|
||||
|
@ -242,4 +248,4 @@ abstract class BaseBookQuery extends ModelCriteria
|
|||
return $this;
|
||||
}
|
||||
|
||||
} // BaseBookQuery
|
||||
} // BaseBookQuery
|
||||
|
|
|
@ -19,6 +19,7 @@ spl_autoload_register(function($class) {
|
|||
return false;
|
||||
}
|
||||
require_once $path;
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -65,10 +65,10 @@ class UniqueObjectValidator extends ConstraintValidator
|
|||
foreach ($fields as $fieldName) {
|
||||
$constraintMessage .= sprintf(' %s "%s" and', $peerClass::translateFieldName($fieldName, \BasePeer::TYPE_FIELDNAME, \BasePeer::TYPE_PHPNAME), $object->getByName($fieldName, \BasePeer::TYPE_FIELDNAME));
|
||||
}
|
||||
|
||||
|
||||
$constraintMessage = substr($constraintMessage, 0, -4) . '.';
|
||||
$this->setMessage($constraintMessage);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue