Skip to content

Commit 9f28495

Browse files
author
Mathieu De Keyzer
committed
first step in devuging criteria 1.6
1 parent 68907d5 commit 9f28495

File tree

2 files changed

+366
-339
lines changed

2 files changed

+366
-339
lines changed
Lines changed: 175 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,176 @@
1-
<?php
2-
namespace EMS\CoreBundle\Entity\Form;
3-
4-
5-
6-
use EMS\CoreBundle\Entity\DataField;
7-
use EMS\CoreBundle\Entity\View;
8-
use Symfony\Component\HttpFoundation\Session\Session;
9-
10-
/**
11-
* RebuildIndex
12-
*/
13-
class CriteriaUpdateConfig{
14-
15-
private $columnCriteria;
16-
17-
private $rowCriteria;
18-
19-
private $category;
20-
21-
private $criterion;
22-
23-
/**@var Session */
24-
private $session;
25-
26-
27-
function __construct(View $view, Session $session){
28-
29-
$this->session = $session;
30-
$this->criterion = [];
31-
$contentType = $view->getContentType();
32-
33-
$rootFieldType = $contentType->getFieldType();
34-
35-
if(!empty($view->getOptions()['categoryFieldPath']) && $categoryField = $rootFieldType->getChildByPath($view->getOptions()['categoryFieldPath'])){
36-
$dataField = new DataField();
37-
$dataField->setFieldType($categoryField);
38-
$this->setCategory($dataField);
39-
}
40-
41-
$criteriaField = $rootFieldType;
42-
43-
if($view->getOptions()['criteriaMode'] == 'internal'){
44-
$criteriaField = $rootFieldType->__get('ems_'.$view->getOptions()['criteriaField']);
45-
}
46-
else if ($view->getOptions()['criteriaMode'] == 'another'){
47-
48-
}
49-
else {
50-
throw new \Exception('Should never happen');
51-
}
52-
53-
54-
$fieldPaths = preg_split("/\\r\\n|\\r|\\n/", $view->getOptions()['criteriaFieldPaths']);
55-
56-
foreach ($fieldPaths as $path){
57-
$child = $criteriaField->getChildByPath($path);
58-
if($child){
59-
$dataField = new DataField();
60-
$dataField->setFieldType($child);
61-
$this->criterion[$child->getName()] = $dataField;
62-
}
63-
else {
64-
$this->session->getFlashBag()->add('warning', 'Field path not found '.$path);
65-
}
66-
}
67-
68-
}
69-
70-
/**
71-
* Set the column criteria field name
72-
*
73-
* @param string $columnCriteria
74-
*
75-
* @return CriteriaUpdateConfig
76-
*/
77-
public function setColumnCriteria($columnCriteria)
78-
{
79-
$this->columnCriteria = $columnCriteria;
80-
81-
return $this;
82-
}
83-
84-
/**
85-
* Get the column criteria field name
86-
*
87-
* @return string
88-
*/
89-
public function getColumnCriteria()
90-
{
91-
return $this->columnCriteria;
92-
}
93-
94-
/**
95-
* Set the row criteria field name
96-
*
97-
* @param string $rowCriteria
98-
*
99-
* @return CriteriaUpdateConfig
100-
*/
101-
public function setRowCriteria($rowCriteria)
102-
{
103-
$this->rowCriteria = $rowCriteria;
104-
105-
return $this;
106-
}
107-
108-
/**
109-
* Get the row criteria field name
110-
*
111-
* @return string
112-
*/
113-
public function getRowCriteria()
114-
{
115-
return $this->rowCriteria;
116-
}
117-
118-
/**
119-
* Set the category field type
120-
*
121-
* @param DataField $category
122-
*
123-
* @return CriteriaUpdateConfig
124-
*/
125-
public function setCategory($category)
126-
{
127-
$this->category = $category;
128-
129-
return $this;
130-
}
131-
132-
/**
133-
* Get the category field
134-
*
135-
* @return DataField
136-
*/
137-
public function getCategory()
138-
{
139-
return $this->category;
140-
}
141-
142-
/**
143-
* Add criterion
144-
*
145-
* @param DataField $criterion
146-
*
147-
* @return CriteriaUpdateConfig
148-
*/
149-
public function addCriterion($criterion)
150-
{
151-
if($criterion)
152-
$this->criterion[] = $criterion;
153-
154-
return $this;
155-
}
156-
157-
/**
158-
* Remove criterion
159-
*
160-
* @param DataField $criterion
161-
*/
162-
public function removeCriterion(DataField $criterion)
163-
{
164-
$this->criterion->removeElement($criterion);
165-
}
166-
167-
/**
168-
* Get filters
169-
*
170-
* @return \Doctrine\Common\Collections\Collection
171-
*/
172-
public function getCriterion()
173-
{
174-
return $this->criterion;
175-
}
1+
<?php
2+
namespace EMS\CoreBundle\Entity\Form;
3+
4+
5+
6+
use EMS\CoreBundle\Entity\DataField;
7+
use EMS\CoreBundle\Entity\View;
8+
use Symfony\Component\HttpFoundation\Session\Session;
9+
10+
/**
11+
* RebuildIndex
12+
*/
13+
class CriteriaUpdateConfig{
14+
15+
private $columnCriteria;
16+
17+
private $rowCriteria;
18+
19+
private $category;
20+
21+
private $criterion;
22+
23+
/**@var Session */
24+
private $session;
25+
26+
27+
function __construct(View $view, Session $session){
28+
29+
$this->session = $session;
30+
$this->criterion = [];
31+
$contentType = $view->getContentType();
32+
33+
$rootFieldType = $contentType->getFieldType();
34+
35+
if(!empty($view->getOptions()['categoryFieldPath']) && $categoryField = $rootFieldType->getChildByPath($view->getOptions()['categoryFieldPath'])){
36+
$dataField = new DataField();
37+
$dataField->setFieldType($categoryField);
38+
$this->setCategory($dataField);
39+
}
40+
41+
$criteriaField = $rootFieldType;
42+
43+
if($view->getOptions()['criteriaMode'] == 'internal'){
44+
$criteriaField = $rootFieldType->__get('ems_'.$view->getOptions()['criteriaField']);
45+
}
46+
else if ($view->getOptions()['criteriaMode'] == 'another'){
47+
48+
}
49+
else {
50+
throw new \Exception('Should never happen');
51+
}
52+
53+
54+
$fieldPaths = preg_split("/\\r\\n|\\r|\\n/", $view->getOptions()['criteriaFieldPaths']);
55+
56+
foreach ($fieldPaths as $path){
57+
$child = $criteriaField->getChildByPath($path);
58+
if($child){
59+
$dataField = new DataField();
60+
$dataField->setFieldType($child);
61+
$this->criterion[$child->getName()] = $dataField;
62+
}
63+
else {
64+
$this->session->getFlashBag()->add('warning', 'Field path not found '.$path);
65+
}
66+
}
67+
68+
}
69+
70+
/**
71+
* Set the column criteria field name
72+
*
73+
* @param string $columnCriteria
74+
*
75+
* @return CriteriaUpdateConfig
76+
*/
77+
public function setColumnCriteria($columnCriteria)
78+
{
79+
$this->columnCriteria = $columnCriteria;
80+
81+
return $this;
82+
}
83+
84+
/**
85+
* Get the column criteria field name
86+
*
87+
* @return string
88+
*/
89+
public function getColumnCriteria()
90+
{
91+
return $this->columnCriteria;
92+
}
93+
94+
/**
95+
* Set the row criteria field name
96+
*
97+
* @param string $rowCriteria
98+
*
99+
* @return CriteriaUpdateConfig
100+
*/
101+
public function setRowCriteria($rowCriteria)
102+
{
103+
$this->rowCriteria = $rowCriteria;
104+
105+
return $this;
106+
}
107+
108+
/**
109+
* Get the row criteria field name
110+
*
111+
* @return string
112+
*/
113+
public function getRowCriteria()
114+
{
115+
return $this->rowCriteria;
116+
}
117+
118+
/**
119+
* Set the category field type
120+
*
121+
* @param DataField $category
122+
*
123+
* @return CriteriaUpdateConfig
124+
*/
125+
public function setCategory($category)
126+
{
127+
$this->category = $category;
128+
129+
return $this;
130+
}
131+
132+
/**
133+
* Get the category field
134+
*
135+
* @return DataField
136+
*/
137+
public function getCategory()
138+
{
139+
return $this->category;
140+
}
141+
142+
/**
143+
* Add criterion
144+
*
145+
* @param DataField $criterion
146+
*
147+
* @return CriteriaUpdateConfig
148+
*/
149+
public function addCriterion(DataField $criterion)
150+
{
151+
$this->criterion[$criterion->getFieldType()->getName()] = $criterion;
152+
return $this;
153+
}
154+
155+
/**
156+
* Remove criterion
157+
*
158+
* @param DataField $criterion
159+
*/
160+
public function removeCriterion(DataField $criterion)
161+
{
162+
if(isset($this->criterion[$criterion->getFieldType()->getName()])) {
163+
unset($this->criterion[$criterion->getFieldType()->getName()]);
164+
}
165+
}
166+
167+
/**
168+
* Get filters
169+
*
170+
* @return \Doctrine\Common\Collections\Collection
171+
*/
172+
public function getCriterion()
173+
{
174+
return $this->criterion;
175+
}
176176
}

0 commit comments

Comments
 (0)