コード例 #1
0
 /**
  * @param ConsoleEvent $event
  * @return mixed|void
  */
 public function listen(ConsoleEvent $event)
 {
     $event->getOutput()->writeln('<info>DebugBar:</info> also publishing assets...');
     $reflection = new \ReflectionClass('\\DebugBar\\DebugBar');
     $debugBarRoot = dirname($reflection->getFileName());
     $eventData = $event->getData();
     $webRootPublic = $eventData['webRootPublic'];
     if (is_link($webRootPublic . 'debugbar')) {
         unlink($webRootPublic . 'debugbar');
     }
     symlink($debugBarRoot . '/Resources', $webRootPublic . 'debugbar');
 }
コード例 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $application = $this->container->getApplication();
     $webRoot = $application->getWebRoot();
     foreach ($application->getPackages() as $package) {
         $target = $application->locatePublicFolder($package);
         $link = $this->container->getParameter('directories.public') . DIRECTORY_SEPARATOR . $package->getName();
         if (!is_dir($this->container->getParameter('directories.public'))) {
             mkdir($this->container->getParameter('directories.public'), 0777, true);
         }
         if (is_dir($target)) {
             $output->writeln(sprintf('Publishing assets for package <info>%s</info>, <info>%s</info> -> <info>%s</info>', $package->getName(), $target, $link));
             if (is_link($link)) {
                 unlink($link);
             }
             symlink($target, $link);
         }
     }
     $event = new ConsoleEvent($this, $input, $output);
     $event->setData(array('webRoot' => $webRoot, 'webRootPublic' => $webRoot . '/public/'));
     $this->container->getEventDispatcher()->dispatch(FrameworkConsoleEvent::ASSETS_PUBLISH, $event);
 }