Commit 14206a74 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

Add bundle dir

parent a0f92d8f
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle ArchivesCourrier
*
* Bundle ArchivesCourrier is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle ArchivesCourrier is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle ArchivesCourrier. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\archivesCourrier\bundle\archivesCourrier\Controller;
/**
* Content controller
*
* @author Cyril Vazquez <cyril.vazquez@maarch.org>
*/
class content
extends \ext\archivesPubliques\bundle\archivesPubliques\Controller\Content
implements \bundle\recordsManagement\Controller\archiveDescriptionInterface
{
/**
* Recherche d'un contenu d'archive
* @param string $query
* @param bool $hasParent
* @param date $sentDateFrom
* @param date $sentDateTo
* @param string $originatorOrgRegNumber
*
* @return Array Array of archive description
*/
public function find(
$query = null,
$hasParent = false,
$sentDateFrom = null,
$sentDateTo = null,
$originatorOrgRegNumber = null)
{
$queryParts = array();
$queryParams = array();
$currentDate = \laabs::newDate();
$currentDateString = $currentDate->format('Y-m-d');
$queryParts['accessRule'] = $this->getAccessRuleAssert();
if ($query) {
$tokens = \laabs\explode(' ', $text);
foreach ($tokens as $i => $token) {
$tokens[$i] = $token.':*';
}
$queryParts['term'] = "<?SQL text @@ to_tsquery('".implode(' & ', $tokens)."') ?>";
}
// content description
if ($sentDateFrom && $sentDateTo) {
$queryParams['sentDateFrom'] = $sentDateFrom;
$queryParams['sentDateTo'] = $sentDateTo;
$queryParts['date'] = "sentDateTo >= :sentDateFrom AND sentDateFrom <= :sentDateTo";
} elseif ($sentDateFrom) {
$queryParams['sentDateFrom'] = $sentDateFrom;
$queryParts['date'] = "sentDateFrom >= :sentDateFrom";
} elseif ($sentDateTo) {
$queryParams['sentDateTo'] = $sentDateTo;
$queryParts['date'] = "sentDateTo <= :sentDateTo";
}
if ($originatorOrgRegNumber) {
$queryParams['originatorOrgRegNumber'] = $originatorOrgRegNumber;
$queryParts['originatorOrgRegNumber'] = "originatorOrgRegNumber = :originatorOrgRegNumber";
}
if ($hasParent === true) {
$queryParts['hasParent'] = "parentArchiveId!=null";
}
if ($hasParent === false) {
$queryParts['hasParent'] = "parentArchiveId=null";
}
$queryString = \laabs\implode(' AND ', $queryParts);
$contents = $this->sdoFactory->find("archivesPubliques/archiveDescription", $queryString, $queryParams, '>depositDate', 0, 100);
return $contents;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment