3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
33 class CRM_Utils_Check_Case
{
36 * @var CRM_Case_XMLRepository
43 protected $caseTypeNames;
46 * @param CRM_Case_XMLRepository $xmlRepo
47 * @param array <string> $caseTypeNames
49 public function __construct($xmlRepo, $caseTypeNames) {
50 $this->caseTypeNames
= $caseTypeNames;
51 $this->xmlRepo
= $xmlRepo;
55 * Run some sanity checks.
57 * @return array<CRM_Utils_Check_Message>
59 public function checkAll() {
60 $messages = array_merge(
61 $this->checkCaseTypeNameConsistency()
67 * Check that the case-type names don't rely on double-munging.
69 * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
71 public function checkCaseTypeNameConsistency() {
74 foreach ($this->caseTypeNames
as $caseTypeName) {
75 $normalFile = $this->xmlRepo
->findXmlFile($caseTypeName);
76 $mungedFile = $this->xmlRepo
->findXmlFile(CRM_Case_XMLProcessor
::mungeCaseType($caseTypeName));
78 if ($normalFile && $mungedFile && $normalFile == $mungedFile) {
81 elseif ($normalFile && $mungedFile) {
82 $messages[] = new CRM_Utils_Check_Message(
84 ts('Case type "%2" has duplicate XML files ("%3" and "%4").<br /><a href="%1">Read more about this warning</a>', array(
85 1 => CRM_Utils_System
::getWikiBaseURL() . __FUNCTION__
,
93 elseif ($normalFile && !$mungedFile) {
96 elseif (!$normalFile && $mungedFile) {
97 $messages[] = new CRM_Utils_Check_Message(
99 ts('Case type "%2" corresponds to XML file ("%3") The XML file should be named "%4".<br /><a href="%1">Read more about this warning</a>', array(
100 1 => CRM_Utils_System
::getWikiBaseURL() . __FUNCTION__
,
103 4 => "{$caseTypeName}.xml",
108 elseif (!$normalFile && !$mungedFile) {
109 // ok -- probably a new or DB-based CaseType