"Fossies" - the Fresh Open Source Software Archive

Member "Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php" (17 Dec 2017, 2672 Bytes) of package /linux/www/Symfony_Standard_Vendors_3.4.39.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractCommand.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 /*
    3  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    4  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    5  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    6  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    7  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    8  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    9  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   10  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   11  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   12  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   13  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   14  *
   15  * This software consists of voluntary contributions made by many individuals
   16  * and is licensed under the MIT license. For more information, see
   17  * <http://www.doctrine-project.org>.
   18  */
   19 
   20 namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
   21 
   22 use Symfony\Component\Console\Input\InputInterface;
   23 use Symfony\Component\Console\Output\OutputInterface;
   24 use Symfony\Component\Console\Command\Command;
   25 use Doctrine\ORM\Tools\SchemaTool;
   26 
   27 /**
   28  * Base class for CreateCommand, DropCommand and UpdateCommand.
   29  *
   30  * @link    www.doctrine-project.org
   31  * @since   2.0
   32  * @author  Benjamin Eberlei <kontakt@beberlei.de>
   33  * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
   34  * @author  Jonathan Wage <jonwage@gmail.com>
   35  * @author  Roman Borschel <roman@code-factory.org>
   36  */
   37 abstract class AbstractCommand extends Command
   38 {
   39     /**
   40      * @param InputInterface  $input
   41      * @param OutputInterface $output
   42      * @param SchemaTool      $schemaTool
   43      * @param array           $metadatas
   44      *
   45      * @return null|int Null or 0 if everything went fine, or an error code.
   46      */
   47     abstract protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas);
   48 
   49     /**
   50      * {@inheritdoc}
   51      */
   52     protected function execute(InputInterface $input, OutputInterface $output)
   53     {
   54         $emHelper = $this->getHelper('em');
   55 
   56         /* @var $em \Doctrine\ORM\EntityManager */
   57         $em = $emHelper->getEntityManager();
   58 
   59         $metadatas = $em->getMetadataFactory()->getAllMetadata();
   60 
   61         if ( ! empty($metadatas)) {
   62             // Create SchemaTool
   63             $tool = new SchemaTool($em);
   64 
   65             return $this->executeSchemaCommand($input, $output, $tool, $metadatas);
   66         } else {
   67             $output->writeln('No Metadata Classes to process.');
   68             return 0;
   69         }
   70     }
   71 }