@@ -35,6 +35,9 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | protected $itemNodes; |
| 37 | 37 | |
| 38 | + /** |
|
| 39 | + * @param EE_Base_Class $mainEntity |
|
| 40 | + */ |
|
| 38 | 41 | public function __construct($mainEntity, $relation) |
| 39 | 42 | { |
| 40 | 43 | $this->mainEntity = $mainEntity; |
@@ -66,7 +69,7 @@ discard block |
||
| 66 | 69 | |
| 67 | 70 | /** |
| 68 | 71 | * @since $VID:$ |
| 69 | - * @return boolean |
|
| 72 | + * @return boolean|null |
|
| 70 | 73 | */ |
| 71 | 74 | public function isComplete() |
| 72 | 75 | { |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace EventEspresso\core\services\orm\tree_traversal; |
| 4 | 4 | |
| 5 | 5 | use EE_Base_Class; |
| 6 | -use EventEspresso\core\libraries\rest_api\controllers\Base; |
|
| 7 | 6 | |
| 8 | 7 | /** |
| 9 | 8 | * Class RelationNode |
@@ -17,66 +17,66 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class RelationNode extends BaseNode |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var EE_Base_Class |
|
| 22 | - */ |
|
| 23 | - protected $mainEntity; |
|
| 20 | + /** |
|
| 21 | + * @var EE_Base_Class |
|
| 22 | + */ |
|
| 23 | + protected $mainEntity; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var int |
|
| 27 | - */ |
|
| 28 | - protected $count; |
|
| 25 | + /** |
|
| 26 | + * @var int |
|
| 27 | + */ |
|
| 28 | + protected $count; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var \EE_Model_Relation_Base |
|
| 32 | - */ |
|
| 33 | - protected $relation; |
|
| 30 | + /** |
|
| 31 | + * @var \EE_Model_Relation_Base |
|
| 32 | + */ |
|
| 33 | + protected $relation; |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - protected $itemNodes; |
|
| 36 | + protected $itemNodes; |
|
| 37 | 37 | |
| 38 | - public function __construct($mainEntity, $relation) |
|
| 39 | - { |
|
| 40 | - $this->mainEntity = $mainEntity; |
|
| 41 | - $this->relation = $relation; |
|
| 42 | - } |
|
| 38 | + public function __construct($mainEntity, $relation) |
|
| 39 | + { |
|
| 40 | + $this->mainEntity = $mainEntity; |
|
| 41 | + $this->relation = $relation; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - protected function work($work_to_do){ |
|
| 47 | - $items = $this->relation->get_this_model()->get_all_related( |
|
| 48 | - $this->mainEntity, |
|
| 49 | - $this->relation->get_other_model(), |
|
| 50 | - [ |
|
| 51 | - 'limit' => $work_to_do |
|
| 52 | - ] |
|
| 53 | - ); |
|
| 54 | - foreach($items as $item){ |
|
| 55 | - $this->itemNodes[] = new EntityNode($item); |
|
| 56 | - } |
|
| 57 | - } |
|
| 46 | + protected function work($work_to_do){ |
|
| 47 | + $items = $this->relation->get_this_model()->get_all_related( |
|
| 48 | + $this->mainEntity, |
|
| 49 | + $this->relation->get_other_model(), |
|
| 50 | + [ |
|
| 51 | + 'limit' => $work_to_do |
|
| 52 | + ] |
|
| 53 | + ); |
|
| 54 | + foreach($items as $item){ |
|
| 55 | + $this->itemNodes[] = new EntityNode($item); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Whether this item has already been initialized |
|
| 61 | - */ |
|
| 62 | - public function isDiscovered() |
|
| 63 | - { |
|
| 64 | - // TODO: Implement isDiscovered() method. |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * Whether this item has already been initialized |
|
| 61 | + */ |
|
| 62 | + public function isDiscovered() |
|
| 63 | + { |
|
| 64 | + // TODO: Implement isDiscovered() method. |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @since $VID:$ |
|
| 69 | - * @return boolean |
|
| 70 | - */ |
|
| 71 | - public function isComplete() |
|
| 72 | - { |
|
| 73 | - // TODO: Implement isComplete() method. |
|
| 74 | - } |
|
| 67 | + /** |
|
| 68 | + * @since $VID:$ |
|
| 69 | + * @return boolean |
|
| 70 | + */ |
|
| 71 | + public function isComplete() |
|
| 72 | + { |
|
| 73 | + // TODO: Implement isComplete() method. |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public function discover() |
|
| 77 | - { |
|
| 78 | - $this->count = $this->relation->get_this_model()->count_related($this->mainEntity, $this->relation->get_other_model()); |
|
| 79 | - } |
|
| 76 | + public function discover() |
|
| 77 | + { |
|
| 78 | + $this->count = $this->relation->get_this_model()->count_related($this->mainEntity, $this->relation->get_other_model()); |
|
| 79 | + } |
|
| 80 | 80 | } |
| 81 | 81 | // End of file RelationNode.php |
| 82 | 82 | // Location: EventEspresso\core\services\orm\tree_traversal/RelationNode.php |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - protected function work($work_to_do){ |
|
| 46 | + protected function work($work_to_do) { |
|
| 47 | 47 | $items = $this->relation->get_this_model()->get_all_related( |
| 48 | 48 | $this->mainEntity, |
| 49 | 49 | $this->relation->get_other_model(), |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | 'limit' => $work_to_do |
| 52 | 52 | ] |
| 53 | 53 | ); |
| 54 | - foreach($items as $item){ |
|
| 54 | + foreach ($items as $item) { |
|
| 55 | 55 | $this->itemNodes[] = new EntityNode($item); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -14,45 +14,45 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | abstract class BaseNode |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var boolean |
|
| 19 | - */ |
|
| 20 | - protected $complete; |
|
| 21 | - /** |
|
| 22 | - * Whether this item has already been initialized |
|
| 23 | - */ |
|
| 24 | - public abstract function isDiscovered(); |
|
| 17 | + /** |
|
| 18 | + * @var boolean |
|
| 19 | + */ |
|
| 20 | + protected $complete; |
|
| 21 | + /** |
|
| 22 | + * Whether this item has already been initialized |
|
| 23 | + */ |
|
| 24 | + public abstract function isDiscovered(); |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @since $VID:$ |
|
| 28 | - * @return boolean |
|
| 29 | - */ |
|
| 30 | - public abstract function isComplete(); |
|
| 26 | + /** |
|
| 27 | + * @since $VID:$ |
|
| 28 | + * @return boolean |
|
| 29 | + */ |
|
| 30 | + public abstract function isComplete(); |
|
| 31 | 31 | |
| 32 | - public abstract function discover(); |
|
| 32 | + public abstract function discover(); |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @since $VID:$ |
|
| 36 | - * @param $work_to_do |
|
| 37 | - * @return int units of work done |
|
| 38 | - */ |
|
| 39 | - public function visit($work_to_do){ |
|
| 40 | - if($this->isComplete()){ |
|
| 41 | - return; |
|
| 42 | - } |
|
| 43 | - if(! $this->isDiscovered()){ |
|
| 44 | - $this->discover(); |
|
| 45 | - } |
|
| 46 | - return $this->work($work_to_do); |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * @since $VID:$ |
|
| 36 | + * @param $work_to_do |
|
| 37 | + * @return int units of work done |
|
| 38 | + */ |
|
| 39 | + public function visit($work_to_do){ |
|
| 40 | + if($this->isComplete()){ |
|
| 41 | + return; |
|
| 42 | + } |
|
| 43 | + if(! $this->isDiscovered()){ |
|
| 44 | + $this->discover(); |
|
| 45 | + } |
|
| 46 | + return $this->work($work_to_do); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * |
|
| 51 | - * @since $VID:$ |
|
| 52 | - * @param $work_to_do |
|
| 53 | - * @return int units of work done |
|
| 54 | - */ |
|
| 55 | - protected abstract function work($work_to_do); |
|
| 49 | + /** |
|
| 50 | + * |
|
| 51 | + * @since $VID:$ |
|
| 52 | + * @param $work_to_do |
|
| 53 | + * @return int units of work done |
|
| 54 | + */ |
|
| 55 | + protected abstract function work($work_to_do); |
|
| 56 | 56 | } |
| 57 | 57 | // End of file BaseNode.php |
| 58 | 58 | // Location: EventEspresso\core\services\orm\tree_traversal/BaseNode.php |
@@ -36,11 +36,11 @@ |
||
| 36 | 36 | * @param $work_to_do |
| 37 | 37 | * @return int units of work done |
| 38 | 38 | */ |
| 39 | - public function visit($work_to_do){ |
|
| 40 | - if($this->isComplete()){ |
|
| 39 | + public function visit($work_to_do) { |
|
| 40 | + if ($this->isComplete()) { |
|
| 41 | 41 | return; |
| 42 | 42 | } |
| 43 | - if(! $this->isDiscovered()){ |
|
| 43 | + if ( ! $this->isDiscovered()) { |
|
| 44 | 44 | $this->discover(); |
| 45 | 45 | } |
| 46 | 46 | return $this->work($work_to_do); |
@@ -16,75 +16,75 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class EntityNode extends BaseNode |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @var EE_Base_Class |
|
| 21 | - */ |
|
| 22 | - protected $initialInstance; |
|
| 19 | + /** |
|
| 20 | + * @var EE_Base_Class |
|
| 21 | + */ |
|
| 22 | + protected $initialInstance; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var RelationNode[] |
|
| 26 | - */ |
|
| 27 | - protected $relation_nodes; |
|
| 24 | + /** |
|
| 25 | + * @var RelationNode[] |
|
| 26 | + */ |
|
| 27 | + protected $relation_nodes; |
|
| 28 | 28 | |
| 29 | - public function __construct( $instance) |
|
| 30 | - { |
|
| 31 | - $this->initialInstance = $instance; |
|
| 32 | - } |
|
| 29 | + public function __construct( $instance) |
|
| 30 | + { |
|
| 31 | + $this->initialInstance = $instance; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function discover(){ |
|
| 35 | - foreach($this->initialInstance->get_model()->relation_settings() as $relation){ |
|
| 36 | - if($relation->block_delete_if_related_models_exist()){ |
|
| 37 | - $this->relation_nodes[] = new RelationNode($this->initialInstance, $relation); |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - } |
|
| 34 | + public function discover(){ |
|
| 35 | + foreach($this->initialInstance->get_model()->relation_settings() as $relation){ |
|
| 36 | + if($relation->block_delete_if_related_models_exist()){ |
|
| 37 | + $this->relation_nodes[] = new RelationNode($this->initialInstance, $relation); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Whether this item has already been initialized |
|
| 45 | - */ |
|
| 46 | - public function isDiscovered() |
|
| 47 | - { |
|
| 48 | - // TODO: Implement isDiscovered() method. |
|
| 49 | - } |
|
| 43 | + /** |
|
| 44 | + * Whether this item has already been initialized |
|
| 45 | + */ |
|
| 46 | + public function isDiscovered() |
|
| 47 | + { |
|
| 48 | + // TODO: Implement isDiscovered() method. |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @since $VID:$ |
|
| 53 | - * @return boolean |
|
| 54 | - */ |
|
| 55 | - public function isComplete() |
|
| 56 | - { |
|
| 57 | - if($this->complete == null){ |
|
| 58 | - $this->complete = true; |
|
| 59 | - foreach($this->relation_nodes as $relation_node){ |
|
| 60 | - if(! $relation_node->isComplete()){ |
|
| 61 | - $this->complete = false; |
|
| 62 | - break; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $this->complete; |
|
| 67 | - } |
|
| 51 | + /** |
|
| 52 | + * @since $VID:$ |
|
| 53 | + * @return boolean |
|
| 54 | + */ |
|
| 55 | + public function isComplete() |
|
| 56 | + { |
|
| 57 | + if($this->complete == null){ |
|
| 58 | + $this->complete = true; |
|
| 59 | + foreach($this->relation_nodes as $relation_node){ |
|
| 60 | + if(! $relation_node->isComplete()){ |
|
| 61 | + $this->complete = false; |
|
| 62 | + break; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $this->complete; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * |
|
| 71 | - * @since $VID:$ |
|
| 72 | - * @param $work_to_do |
|
| 73 | - * @return int units of work done |
|
| 74 | - */ |
|
| 75 | - protected function work($work_to_do) |
|
| 76 | - { |
|
| 77 | - $units_worked = 0; |
|
| 78 | - foreach($this->relation_nodes as $relation_node){ |
|
| 79 | - if(! $relation_node->isComplete()){ |
|
| 80 | - $units_worked += $relation_node->visit($work_to_do); |
|
| 81 | - } |
|
| 82 | - if($units_worked >= $work_to_do){ |
|
| 83 | - break; |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - return $units_worked; |
|
| 87 | - } |
|
| 69 | + /** |
|
| 70 | + * |
|
| 71 | + * @since $VID:$ |
|
| 72 | + * @param $work_to_do |
|
| 73 | + * @return int units of work done |
|
| 74 | + */ |
|
| 75 | + protected function work($work_to_do) |
|
| 76 | + { |
|
| 77 | + $units_worked = 0; |
|
| 78 | + foreach($this->relation_nodes as $relation_node){ |
|
| 79 | + if(! $relation_node->isComplete()){ |
|
| 80 | + $units_worked += $relation_node->visit($work_to_do); |
|
| 81 | + } |
|
| 82 | + if($units_worked >= $work_to_do){ |
|
| 83 | + break; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + return $units_worked; |
|
| 87 | + } |
|
| 88 | 88 | } |
| 89 | 89 | // End of file Visitor.php |
| 90 | 90 | // Location: EventEspresso\core\services\orm\tree_traversal/Visitor.php |
@@ -26,14 +26,14 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | protected $relation_nodes; |
| 28 | 28 | |
| 29 | - public function __construct( $instance) |
|
| 29 | + public function __construct($instance) |
|
| 30 | 30 | { |
| 31 | 31 | $this->initialInstance = $instance; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function discover(){ |
|
| 35 | - foreach($this->initialInstance->get_model()->relation_settings() as $relation){ |
|
| 36 | - if($relation->block_delete_if_related_models_exist()){ |
|
| 34 | + public function discover() { |
|
| 35 | + foreach ($this->initialInstance->get_model()->relation_settings() as $relation) { |
|
| 36 | + if ($relation->block_delete_if_related_models_exist()) { |
|
| 37 | 37 | $this->relation_nodes[] = new RelationNode($this->initialInstance, $relation); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function isComplete() |
| 56 | 56 | { |
| 57 | - if($this->complete == null){ |
|
| 57 | + if ($this->complete == null) { |
|
| 58 | 58 | $this->complete = true; |
| 59 | - foreach($this->relation_nodes as $relation_node){ |
|
| 60 | - if(! $relation_node->isComplete()){ |
|
| 59 | + foreach ($this->relation_nodes as $relation_node) { |
|
| 60 | + if ( ! $relation_node->isComplete()) { |
|
| 61 | 61 | $this->complete = false; |
| 62 | 62 | break; |
| 63 | 63 | } |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | protected function work($work_to_do) |
| 76 | 76 | { |
| 77 | 77 | $units_worked = 0; |
| 78 | - foreach($this->relation_nodes as $relation_node){ |
|
| 79 | - if(! $relation_node->isComplete()){ |
|
| 78 | + foreach ($this->relation_nodes as $relation_node) { |
|
| 79 | + if ( ! $relation_node->isComplete()) { |
|
| 80 | 80 | $units_worked += $relation_node->visit($work_to_do); |
| 81 | 81 | } |
| 82 | - if($units_worked >= $work_to_do){ |
|
| 82 | + if ($units_worked >= $work_to_do) { |
|
| 83 | 83 | break; |
| 84 | 84 | } |
| 85 | 85 | } |