Returns "years ago" result with absolute diff in calendar years

@param DateDiffRequest $request
@return DateDiffResult
517934
public static function calculateYearsAgo(DateDiffRequest $request)
    {
        return new DateDiffResult($request, self::YEARS_AGO, $request->getInterval()->y);
    }
441294
public static function calculateMinutesAgo(DateDiffRequest $request)
    {
        return new DateDiffResult($request, self::MINUTES_AGO, (int)floor(abs($request->getDiffInSeconds()) / Unit::MINUTE));
    }
445335
public function cgetAction(Request $request)
    {
        $locale = $this->getProductLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale'));
        $queryString = $request->get('query');

        if ($request->get('flat') == 'true') {
            $list = $this->getListRepresentation($request);
        } else {
            $list = new CollectionRepresentation(
                $this->getManager()->findAllByLocaleAndQueryString($locale, $queryString),
                self::$entityKey
            );
        }

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
190162
public function scoreLastMonths(Request $request)
    {
        $repos = new ResultsRepository();
        return view(
            'game-of-tests::results.list',
            [
                'type' => 'from',
                'months_back' => $request->input('monthsBack', 0),
                'results' => $repos->getScoreLastMonths($request->input('monthsBack', 0))
            ]
        );
    }
686190
public function indexAction(Request $request)
    {
        if (null !== ($response = $this->getDumpedIndexResponse($request))) {
            return $response;
        }

        $sitemap = $this->get('sulu_website.sitemap.xml_renderer')->renderIndex();
        if (!$sitemap) {
            $aliases = array_keys($this->get('sulu_website.sitemap.pool')->getProviders());

            return $this->sitemapPaginatedAction($request, reset($aliases), 1);
        }

        return $this->setCacheLifetime(new Response($sitemap));
    }
762121
public function fileHistoryForm($request = null)
    {
        // Get ID either from posted back value, or url parameter
        if (!$request) {
            $this->jsonError(400);
            return null;
        }
        $id = $request->param('ID');
        if (!$id) {
            $this->jsonError(400);
            return null;
        }
        $versionID = $request->param('VersionID');
        if (!$versionID) {
            $this->jsonError(400);
            return null;
        }
        $form = $this->getFileHistoryForm([
            'RecordID' => $id,
            'RecordVersion' => $versionID,
        ]);
        return $form;
    }
1366968
public function postExport(Request $request)
    {

        $form = FormBuilder::create($this->export_form, [
            'model' => $this->model
        ]);


        if ($form->hasError())
        {
            return $form->validateAndRedirectBack();
        }


        $data = $request->all();
        $dateStart = !empty($data['range']) && !empty($data['range']['start']) ? $data['range']['start'] : Carbon::now()->format('Y-m-d');
        $dateEnd = !empty($data['range']) && !empty($data['range']['end']) ? $data['range']['end'] : Carbon::now()->format('Y-m-d');
        $type = !empty($data['type']) ? $data['type'] : 'csv';
        $filename = str_replace('/', '-', $dateStart.'_'.$dateEnd).'.'.mb_strtolower($type);

        return (new BaseExport($this->model, $data))->export($filename);
    }
158415
private function determineLifeTime(Request $request)
    {
        if ($lifetime = $request->query->getInt('ttl')) {
            return $this->revertToNullOnMinusOne($lifetime);
        }

        try {
            $inputData = new JsonArray($request->getContent());
            if ($inputData->has('ttl')) {
                return $this->revertToNullOnMinusOne(intval($inputData->get('ttl')));
            }
        } catch (\Exception $e) {
            // Swallow exception, we need to return a defined result.
        }

        return 3600;
    }
978101
public function searchAction(Request $request)
    {
        $queryString = $request->query->get('q');
        $index = $request->query->get('index', null);
        $locale = $request->query->get('locale', null);

        $page = $this->listRestHelper->getPage();
        $limit = $this->listRestHelper->getLimit();
        $startTime = microtime(true);

        $indexes = $index ? [$index] : $this->getAllowedIndexes();

        $query = $this->searchManager->createSearch($queryString);

        if ($locale) {
            $query->locale($locale);
        }

        $query->indexes($indexes);
        $query->setLimit($limit);

        $time = microtime(true) - $startTime;

        $adapter = new ArrayAdapter(iterator_to_array($query->execute()));
        $pager = new Pagerfanta($adapter);
        $pager->setMaxPerPage($limit);
        $pager->setCurrentPage($page);

        $representation = new SearchResultRepresentation(
            new CollectionRepresentation($pager->getCurrentPageResults(), 'result'),
            'sulu_search_search',
            [
                'locale' => $locale,
                'query' => $query,
                'index' => $index,
            ],
            (int) $page,
            (int) $limit,
            $pager->getNbPages(),
            'page',
            'limit',
            false,
            $adapter->getNbResults(),
            $this->getIndexTotals($adapter->getArray()),
            number_format($time, 8)
        );

        $view = View::create($representation);
        $context = new Context();
        $context->enableMaxDepth();
        $view->setContext($context);

        return $this->viewHandler->handle($view);
    }
977426
@RequestMapping(value = "changelog/diff", method = RequestMethod.GET)
    public ResponseEntity<String> diff(FileDiffChangeLogRequest request) {
        // Null proof
        FileDiffChangeLogRequest nonNullRequest = request != null ? request : new FileDiffChangeLogRequest();
        // Gets the change log
        GitChangeLog changeLog = gitService.changeLog(nonNullRequest);
        // Diff export
        String diff = gitService.diff(
                changeLog,
                nonNullRequest.getPatterns()
        );
        // Content type
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set("Content-Type", "text/plain");
        // Body and headers
        return new ResponseEntity<>(diff, responseHeaders, HttpStatus.OK);
    }
581330
protected function getDocumentFromID($request)
    {
        $doc = null;

        $id = Convert::raw2sql($request->param('ID'));
        if (strpos($id, 'version') === 0) {
            // Versioned document
            $id = $this->getDocumentIdFromSlug(str_replace('version', '', $id));
            $doc = DataObject::get_by_id('DMSDocument_versions', $id);
            $this->extend('updateVersionFromID', $doc, $request);
        } else {
            // Normal document
            $doc = DataObject::get_by_id('DMSDocument', $this->getDocumentIdFromSlug($id));
            $this->extend('updateDocumentFromID', $doc, $request);
        }

        return $doc;
    }
338503
protected function getRefererQueryParameters(Request $request)
    {
        $referer = $request->server->get('HTTP_REFERER');
        $request = Request::create($referer);

        return (array) $request->query->getIterator();
    }
510036
public function viewArchive($request)
    {
        $year = $request->param('Year');
        $month = $request->param('Month');


        $this->blogPosts = $this->getArchives();

        if (!$this->blogPosts->count()) {
            return $this->httpError(404);
        }

        $title = $year;
        if ($month) {
            $title = $month . '/' . $year;
        }

        $orig_title = $this->dataRecord->Title;

        $this->Title = 'Archived posts for "' . $title . '" | ' . $orig_title;

        $this->ArchivePeriod = $title;

        return $this->render();
    }
93723
public function transactionsAction(Request $request)
    {
        $dataArray = [
            'html'    => '',
            'success' => 0,
        ];

        $filters = null;
        // filters means the transaction table had a column sort or filter submission or pagination, otherwise its a fresh page load
        if ($request->request->has('filters')) {
            foreach ($request->request->get('filters') as $filter) {
                if (in_array($filter['name'], ['dateTo', 'dateFrom']) && !empty($filter['value'])) {
                    $filter['value']        = new \DateTime($filter['value']);
                    list($hour, $min, $sec) = 'dateTo' == $filter['name'] ? [23, 59, 59] : [00, 00, 00];
                    $filter['value']->setTime($hour, $min, $sec);
                }
                if (!empty($filter['value'])) {
                    $filters[$filter['name']] = $filter['value'];
                }
            }
        }
        $page     = isset($filters['page']) && !empty($filters['page']) ? $filters['page'] : 1;
        $objectId = InputHelper::clean($request->request->get('objectId'));
        if (empty($objectId)) {
            return $this->sendJsonResponse($dataArray);
        }

        $contactClient = $this->checkContactClientAccess($objectId, 'view');
        if ($contactClient instanceof Response) {
            return $this->sendJsonResponse($dataArray);
        }

        $order = [
            'date_added',
            'DESC',
        ];

        if (isset($filters['orderby']) && !empty($filters['orderby'])) {
            $order[0] = $filters['orderby'];
        }
        if (isset($filters['orderbydir']) && !empty($filters['orderbydir'])) {
            $order[1] = $filters['orderbydir'];
        }

        $transactions = $this->getEngagements($contactClient, $filters, $order, $page);

        $dataArray['html']    = $this->renderView(
            'MauticContactClientBundle:Transactions:list.html.php',
            [
                'page'          => $page,
                'contactClient' => $contactClient,
                'transactions'  => $transactions,
                'order'         => $order,
            ]
        );
        $dataArray['success'] = 1;
        $dataArray['total']   = $transactions['total'];

        return $this->sendJsonResponse($dataArray);
    }
1132859
public static function calculateMonthsAgo(DateDiffRequest $request)
    {
        return new DateDiffResult($request, self::MONTHS_AGO, abs($request->getCalendarMonths()));
    }
1074214
private function wasLastActionNotToday(VisitProperties $visitProperties, Request $request)
    {
        $lastActionTime = $visitProperties->getProperty('visit_last_action_time');

        if (empty($lastActionTime)) {
            return false;
        }

        $idSite = $request->getIdSite();
        $timezone = $this->getTimezoneForSite($idSite);

        if (empty($timezone)) {
            throw new UnexpectedWebsiteFoundException('An unexpected website was found, check idSite in the request');
        }

        $date = Date::factory((int)$lastActionTime, $timezone);
        $now = $request->getCurrentTimestamp();
        $now = Date::factory((int)$now, $timezone);

        return $date->toString() !== $now->toString();
    }
603765
public function retrieveCurrent(Request $request)
    {
        if (ConfigQuery::isRewritingEnable()) {
            $view = $request->attributes->get('_view', null);

            $viewLocale = $this->getViewLocale($request);

            $viewId = $view === null ? null : $request->query->get($view . '_id', null);

            $allOtherParameters = $request->query->all();
            if ($view !== null) {
                unset($allOtherParameters['view']);
                if ($viewId !== null) {
                    unset($allOtherParameters[$view . '_id']);
                }
            }
            if ($viewLocale !== null) {
                unset($allOtherParameters['lang']);
                unset($allOtherParameters['locale']);
            }

            $this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
        } else {
            $allParametersWithoutView = $request->query->all();
            $view = $request->attributes->get('_view');
            if (isset($allOtherParameters['view'])) {
                unset($allOtherParameters['view']);
            }
            $this->retriever->rewrittenUrl = null;
            $this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
        }

        return $this->retriever;
    }