TYPO3 CMS  TYPO3_6-2
All Classes Namespaces Files Functions Variables Pages
StructureHasRecordConstraint.php
Go to the documentation of this file.
1 <?php
3 
18 
23 
28  protected function matchesSection(ResponseSection $responseSection) {
29  $nonMatchingVariants = array();
30  $remainingRecordVariants = array();
31 
32  foreach ($responseSection->findStructures($this->recordIdentifier, $this->recordField) as $path => $structure) {
33  if (empty($structure) || !is_array($structure)) {
34  $this->sectionFailures[$responseSection->getIdentifier()] = 'No records found in "' . $path . '"';
35  return FALSE;
36  }
37 
38  $remainingRecords = array();
39  $nonMatchingValues = $this->getNonMatchingValues($structure);
40 
41  if ($this->strict) {
42  $remainingRecords = $this->getRemainingRecords($structure);
43  }
44 
45  if (empty($nonMatchingValues) && (!$this->strict || empty($remainingRecords))) {
46  return TRUE;
47  }
48 
49  if (!empty($nonMatchingValues)) {
50  $nonMatchingVariants[$path] = $nonMatchingValues;
51  }
52  if ($this->strict && !empty($remainingRecords)) {
53  $remainingRecordVariants[$path] = $remainingRecords;
54  }
55  }
56 
57  $failureMessage = '';
58 
59  if (!empty($nonMatchingVariants)) {
60  $failureMessage .= 'Could not assert all values for "' . $this->table . '.' . $this->field . '"' . LF;
61  foreach ($nonMatchingVariants as $path => $nonMatchingValues) {
62  $failureMessage .= ' * Not found in "' . $path . '": ' . implode(', ', $nonMatchingValues) . LF;
63  }
64  }
65 
66  if (!empty($remainingRecordVariants)) {
67  $failureMessage .= 'Found remaining records for "' . $this->table . '.' . $this->field . '"' . LF;
68  foreach ($remainingRecordVariants as $path => $remainingRecords) {
69  $failureMessage .= ' * Found in "' . $path . '": ' . implode(', ', array_keys($remainingRecords)) . LF;
70  }
71  }
72 
73  $this->sectionFailures[$responseSection->getIdentifier()] = $failureMessage;
74  return FALSE;
75  }
76 
82  public function toString() {
83  return 'structure has record';
84  }
85 
86 }