1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace StatsBundle\Command;
- use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- use StatsBundle\Services\DeviceManager;
- class StatsDevicesCommand extends ContainerAwareCommand
- {
- protected function configure()
- {
- $this
- ->setName('stats:devices')
- ->setDescription('Stats Devices command')
- ->setHelp('This command allows you to get and update stats devices list from devices server url')
- ;
- }
- /**
- * @param InputInterface $input
- * @param OutputInterface $output
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- /* @var $statsDeviceManager DeviceManager */
- $statsDeviceManager = $this->getContainer()->get('stats.device.manager');
- $devices = $statsDeviceManager->getDevices();
- if (count($devices)) {
- $output->writeln('Nuevos StatsDevice:');
- foreach ($devices as $device) {
- $output->writeln(sprintf('<info>DeviceType:</info> %s <info>DeviceIp:</info> %s', $device->getDeviceType(), $device->getIp()));
- }
- } else {
- $output->writeln('No hay nuevos StatsDevice');
- }
- }
- }
|