Source of file DoctrineStep.php
Size: 3,008 Bytes - Last Modified: 2013-07-17T08:24:17+02:00
/home/theseer/Downloads/Symfony/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Configurator/Step/DoctrineStep.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sensio\Bundle\DistributionBundle\Configurator\Step; use Sensio\Bundle\DistributionBundle\Configurator\Form\DoctrineStepType; use Symfony\Component\Validator\Constraints as Assert; /** * Doctrine Step. * * @author Fabien Potencier <fabien@symfony.com> */ class DoctrineStep implements StepInterface { /** * @Assert\Choice(callback="getDriverKeys") */ public $driver; /** * @Assert\NotBlank */ public $host; /** * @Assert\Range(min = "0") */ public $port; /** * @Assert\NotBlank */ public $name; /** * @Assert\NotBlank */ public $user; public $password; public $path; public function __construct(array $parameters) { foreach ($parameters as $key => $value) { if (0 === strpos($key, 'database_')) { $parameters[substr($key, 9)] = $value; $key = substr($key, 9); $this->$key = $value; } } } /** * @see StepInterface */ public function getFormType() { return new DoctrineStepType(); } /** * @see StepInterface */ public function checkRequirements() { $messages = array(); if (!class_exists('\PDO')) { $messages[] = 'PDO extension is mandatory.'; } else { $drivers = \PDO::getAvailableDrivers(); if (0 == count($drivers)) { $messages[] = 'Please install PDO drivers.'; } } return $messages; } /** * @see StepInterface */ public function checkOptionalSettings() { return array(); } /** * @see StepInterface */ public function update(StepInterface $data) { $parameters = array(); foreach ($data as $key => $value) { $parameters['database_'.$key] = $value; } return $parameters; } /** * @see StepInterface */ public function getTemplate() { return 'SensioDistributionBundle:Configurator/Step:doctrine.html.twig'; } /** * @return array */ public static function getDriverKeys() { return array_keys(static::getDrivers()); } /** * @return array */ public static function getDrivers() { return array( 'pdo_mysql' => 'MySQL (PDO)', 'pdo_sqlite' => 'SQLite (PDO)', 'pdo_pgsql' => 'PosgreSQL (PDO)', 'oci8' => 'Oracle (native)', 'ibm_db2' => 'IBM DB2 (native)', 'pdo_oci' => 'Oracle (PDO)', 'pdo_ibm' => 'IBM DB2 (PDO)', 'pdo_sqlsrv' => 'SQLServer (PDO)', ); } } |