Util/DataGrid/DataGridRequestHandler.php
public function getByToken($token)
    {
        if (null === $this->profiler) {
            throw new \RuntimeException('Invalid profiler instance.');
        }

        $profile = $this->profiler->loadProfile($token);

        // In case no results were found
        if (!$profile instanceof Profile) {
            return array(array(), 0);
        }

        try {
            /** @var TranslationDataCollector $collector */
            $collector = $profile->getCollector('translation');
            $messages = $collector->getMessages();

            $transUnits = array();
            foreach ($messages as $message) {
                $transUnit = $this->storage->getTransUnitByKeyAndDomain($message['id'], $message['domain']);

                if ($transUnit instanceof TransUnit) {
                    $transUnits[] = $transUnit;
                } elseif (true === $this->createMissing) {
                    $transUnits[] = $transUnit = $this->transUnitManager->create($message['id'], $message['domain'], true);
                }

                // Also store the translation if profiler state was defined
                if (!$transUnit->hasTranslation($message['locale']) && $message['state'] === DataCollectorTranslator::MESSAGE_DEFINED) {
                    $file = $this->fileManager->getFor(sprintf('%s.%s.%s', $message['domain'], $message['locale'], $this->defaultFileFormat));

                    $this->transUnitManager->addTranslation($transUnit, $message['locale'], $message['translation'], $file, true);
                }
            }

            return array($transUnits, count($transUnits));

        } catch (\InvalidArgumentException $e) {

            // Translation collector is a 2.7 feature
            return array(array(), 0);
        }
    }
public function getByToken($token)
    {
        if (null === $this->profiler) {
            throw new \RuntimeException('Invalid profiler instance.');
        }

        $profile = $this->profiler->loadProfile($token);

        // In case no results were found
        if (!$profile instanceof Profile) {
            return array(array(), 0);
        }

        try {
            /** @var TranslationDataCollector $collector */
            $collector = $profile->getCollector('translation');
            $messages = $collector->getMessages();

            $transUnits = array();
            foreach ($messages as $message) {
                $transUnit = $this->storage->getTransUnitByKeyAndDomain($message['id'], $message['domain']);

                if ($transUnit instanceof TransUnit) {
                    $transUnits[] = $transUnit;
                } elseif (true === $this->createMissing) {
                    $transUnits[] = $transUnit = $this->transUnitManager->create($message['id'], $message['domain'], true);
                }

                // Also store the translation if profiler state was defined
                if (!$transUnit->hasTranslation($message['locale']) && $message['state'] === DataCollectorTranslator::MESSAGE_DEFINED) {
                    $file = $this->fileManager->getFor(sprintf('%s.%s.%s', $message['domain'], $message['locale'], $this->defaultFileFormat));

                    $this->transUnitManager->addTranslation($transUnit, $message['locale'], $message['translation'], $file, true);
                }
            }

            return array($transUnits, count($transUnits));

        } catch (\InvalidArgumentException $e) {

            // Translation collector is a 2.7 feature
            return array(array(), 0);
        }
    }
public function getByToken ( $ token ) { if ( null === $ this -> profiler ) { throw new \ RuntimeException ( 'Invalid profiler instance.' ) ; } $ profile = $ this -> profiler -> loadProfile ( $ token ) ; // In case no results were found if ( ! $ profile instanceof Profile ) { return array ( array ( ) , 0 ) ; } try { /** @var TranslationDataCollector $collector */ $ collector = $ profile -> getCollector ( 'translation' ) ; $ messages = $ collector -> getMessages ( ) ; $ transUnits = array ( ) ; foreach ( $ messages as $ message ) { $ transUnit = $ this -> storage -> getTransUnitByKeyAndDomain ( $ message [ 'id' ] , $ message [ 'domain' ] ) ; if ( $ transUnit instanceof TransUnit ) { $ transUnits [ ] = $ transUnit ; } elseif ( true === $ this -> createMissing ) { $ transUnits [ ] = $ transUnit = $ this -> transUnitManager -> create ( $ message [ 'id' ] , $ message [ 'domain' ] , true ) ; } // Also store the translation if profiler state was defined if ( ! $ transUnit -> hasTranslation ( $ message [ 'locale' ] ) && $ message [ 'state' ] === DataCollectorTranslator :: MESSAGE_DEFINED ) { $ file = $ this -> fileManager -> getFor ( sprintf ( '%s.%s.%s' , $ message [ 'domain' ] , $ message [ 'locale' ] , $ this -> defaultFileFormat ) ) ; $ this -> transUnitManager -> addTranslation ( $ transUnit , $ message [ 'locale' ] , $ message [ 'translation' ] , $ file , true ) ; } } return array ( $ transUnits , count ( $ transUnits ) ) ; } catch ( \ InvalidArgumentException $ e ) { // Translation collector is a 2.7 feature return array ( array ( ) , 0 ) ; } }
Get a profile's translation messages based on a previous Profiler token.

@param string $token by which a Profile can be found in the Profiler

@return array with collection of TransUnits and it's count
Get a profile s translation messages based on a previous Profiler token .