src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsDataCollectCommand.php
public function updateData($overviews)
    {
        // helpers
        $queryHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.query');
        $configHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.config');
        $metrics = new MetricsCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
        $chartData = new ChartDataCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
        $goals = new GoalCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
        $visitors = new UsersCommandHelper($configHelper, $queryHelper, $this->output, $this->em);

        // get data per overview
        foreach ($overviews as $overview) {
            $configHelper->init($overview->getConfig()->getId());
            /* @var AnalyticsOverview $overview */
            $this->output->writeln('Fetching data for overview "<fg=green>' . $overview->getTitle() . '</fg=green>"');

            try {
                // metric data
                $metrics->getData($overview);
                if ($overview->getSessions()) { // if there are any visits
                    // day-specific data
                    $chartData->getData($overview);

                    // get goals
                    $goals->getData($overview);

                    // visitor types
                    $visitors->getData($overview);
                } else {
                    // reset overview
                    $this->reset($overview);
                    $this->output->writeln("\t" . 'No visitors');
                }
                // persist entity back to DB
                $this->output->writeln("\t" . 'Persisting..');
                $this->em->persist($overview);
                $this->em->flush($overview);

                $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->setUpdated($overview->getConfig()->getId());
            } catch (\Google_ServiceException $e) {
                $error = explode(')', $e->getMessage());
                $error = $error[1];
                $this->output->writeln("\t" . '<fg=red>Invalid segment: </fg=red>' .$error);
                $this->errors += 1;
            }
        }
    }
public function updateData($overviews)
    {
        // helpers
        $queryHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.query');
        $configHelper = $this->getContainer()->get('kunstmaan_dashboard.helper.google.analytics.config');
        $metrics = new MetricsCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
        $chartData = new ChartDataCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
        $goals = new GoalCommandHelper($configHelper, $queryHelper, $this->output, $this->em);
        $visitors = new UsersCommandHelper($configHelper, $queryHelper, $this->output, $this->em);

        // get data per overview
        foreach ($overviews as $overview) {
            $configHelper->init($overview->getConfig()->getId());
            /* @var AnalyticsOverview $overview */
            $this->output->writeln('Fetching data for overview "<fg=green>' . $overview->getTitle() . '</fg=green>"');

            try {
                // metric data
                $metrics->getData($overview);
                if ($overview->getSessions()) { // if there are any visits
                    // day-specific data
                    $chartData->getData($overview);

                    // get goals
                    $goals->getData($overview);

                    // visitor types
                    $visitors->getData($overview);
                } else {
                    // reset overview
                    $this->reset($overview);
                    $this->output->writeln("\t" . 'No visitors');
                }
                // persist entity back to DB
                $this->output->writeln("\t" . 'Persisting..');
                $this->em->persist($overview);
                $this->em->flush($overview);

                $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->setUpdated($overview->getConfig()->getId());
            } catch (\Google_ServiceException $e) {
                $error = explode(')', $e->getMessage());
                $error = $error[1];
                $this->output->writeln("\t" . '<fg=red>Invalid segment: </fg=red>' .$error);
                $this->errors += 1;
            }
        }
    }
public function updateData ( $ overviews ) { // helpers $ queryHelper = $ this -> getContainer ( ) -> get ( 'kunstmaan_dashboard.helper.google.analytics.query' ) ; $ configHelper = $ this -> getContainer ( ) -> get ( 'kunstmaan_dashboard.helper.google.analytics.config' ) ; $ metrics = new MetricsCommandHelper ( $ configHelper , $ queryHelper , $ this -> output , $ this -> em ) ; $ chartData = new ChartDataCommandHelper ( $ configHelper , $ queryHelper , $ this -> output , $ this -> em ) ; $ goals = new GoalCommandHelper ( $ configHelper , $ queryHelper , $ this -> output , $ this -> em ) ; $ visitors = new UsersCommandHelper ( $ configHelper , $ queryHelper , $ this -> output , $ this -> em ) ; // get data per overview foreach ( $ overviews as $ overview ) { $ configHelper -> init ( $ overview -> getConfig ( ) -> getId ( ) ) ; /* @var AnalyticsOverview $overview */ $ this -> output -> writeln ( 'Fetching data for overview "<fg=green>' . $ overview -> getTitle ( ) . '</fg=green>"' ) ; try { // metric data $ metrics -> getData ( $ overview ) ; if ( $ overview -> getSessions ( ) ) { // if there are any visits // day-specific data $ chartData -> getData ( $ overview ) ; // get goals $ goals -> getData ( $ overview ) ; // visitor types $ visitors -> getData ( $ overview ) ; } else { // reset overview $ this -> reset ( $ overview ) ; $ this -> output -> writeln ( "\t" . 'No visitors' ) ; } // persist entity back to DB $ this -> output -> writeln ( "\t" . 'Persisting..' ) ; $ this -> em -> persist ( $ overview ) ; $ this -> em -> flush ( $ overview ) ; $ this -> em -> getRepository ( 'KunstmaanDashboardBundle:AnalyticsConfig' ) -> setUpdated ( $ overview -> getConfig ( ) -> getId ( ) ) ; } catch ( \ Google_ServiceException $ e ) { $ error = explode ( ')' , $ e -> getMessage ( ) ) ; $ error = $ error [ 1 ] ; $ this -> output -> writeln ( "\t" . '<fg=red>Invalid segment: </fg=red>' . $ error ) ; $ this -> errors += 1 ; } } }
update the overviews

@param array $overviews collection of all overviews which need to be updated
update the overviews