Loading src/Entity/Workflow.php +0 −67 Changes for src/Entity/Workflow.php: 0 added lines, 67 removed lines. Original line number Diff line number Diff line Loading @@ -3,75 +3,8 @@ /** * @file * Contains workflow\includes\Entity\Workflow. * Contains workflow\includes\Entity\WorkflowController. */ /** * Implements a controller class for Workflow. */ class WorkflowController extends EntityAPIControllerExportable { // public function create(array $values = array()) { return parent::create($values); } // public function load($ids = array(), $conditions = array()) { } public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace WorkflowController::delete() with parent. // @todo: throw error if not workflow->isDeletable(). foreach ($ids as $wid) { if ($workflow = workflow_load($wid)) { $workflow->delete(); } } $this->resetCache(); } /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to Core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } /** * Overrides DrupalDefaultEntityController::cacheSet(). */ /* // protected function cacheSet($entities) { } // return parent::cacheSet($entities); // } */ /** * Overrides DrupalDefaultEntityController::resetCache(). * * Called by workflow_reset_cache, to * Reset the Workflow when States, Transitions have been changed. */ // public function resetCache(array $ids = NULL) { // parent::resetCache($ids); // } /** * Overrides DrupalDefaultEntityController::attachLoad(). */ protected function attachLoad(&$queried_entities, $revision_id = FALSE) { foreach ($queried_entities as $entity) { // Load the states, so they are already present on the next (cached) load. $entity->states = $entity->getStates($all = TRUE); $entity->transitions = $entity->getTransitions(FALSE); $entity->typeMap = $entity->getTypeMap(); } parent::attachLoad($queried_entities, $revision_id); } } class Workflow extends Entity { public $wid = 0; public $name = ''; Loading src/Entity/WorkflowConfigTransition.php +0 −59 Changes for src/Entity/WorkflowConfigTransition.php: 0 added lines, 59 removed lines. Original line number Diff line number Diff line Loading @@ -3,67 +3,8 @@ /** * @file * Contains workflow\includes\Entity\WorkflowConfigTransition. * Contains workflow\includes\Entity\WorkflowConfigTransitionController. */ /** * Implements a controller class for WorkflowConfigTransition. * * The 'true' controller class is 'Workflow'. */ class WorkflowConfigTransitionController extends EntityAPIController { /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } public function save($entity, DatabaseTransaction $transaction = NULL) { $workflow = $entity->getWorkflow(); // To avoid double posting, check if this transition already exist. if (empty($entity->tid)) { if ($workflow) { $config_transitions = $workflow->getTransitionsBySidTargetSid($entity->sid, $entity->target_sid); $config_transition = reset($config_transitions); if ($config_transition) { $entity->tid = $config_transition->tid; } } } // Create the machine_name. This can be used to rebuild/revert the Feature in a target system. if (empty($entity->name)) { $entity->name = $entity->sid . '_' . $entity->target_sid; } $return = parent::save($entity, $transaction); if ($return) { // Save in current workflow for the remainder of this page request. // Keep in sync with Workflow::getTransitions() ! $workflow = $entity->getWorkflow(); if ($workflow) { $workflow->transitions[$entity->tid] = $entity; // $workflow->sortTransitions(); } } // Reset the cache for the affected workflow, to force reload upon next page_load. workflow_reset_cache($entity->wid); return $return; } } /** * Implements a configurated Transition. */ Loading src/Entity/WorkflowConfigTransitionController.php 0 → 100644 +63 −0 Changes for src/Entity/WorkflowConfigTransitionController.php: 63 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains workflow\includes\Entity\WorkflowConfigTransitionController. */ /** * Implements a controller class for WorkflowConfigTransition. * * The 'true' controller class is 'Workflow'. */ class WorkflowConfigTransitionController extends EntityAPIController { /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } public function save($entity, DatabaseTransaction $transaction = NULL) { $workflow = $entity->getWorkflow(); // To avoid double posting, check if this transition already exist. if (empty($entity->tid)) { if ($workflow) { $config_transitions = $workflow->getTransitionsBySidTargetSid($entity->sid, $entity->target_sid); $config_transition = reset($config_transitions); if ($config_transition) { $entity->tid = $config_transition->tid; } } } // Create the machine_name. This can be used to rebuild/revert the Feature in a target system. if (empty($entity->name)) { $entity->name = $entity->sid . '_' . $entity->target_sid; } $return = parent::save($entity, $transaction); if ($return) { // Save in current workflow for the remainder of this page request. // Keep in sync with Workflow::getTransitions() ! $workflow = $entity->getWorkflow(); if ($workflow) { $workflow->transitions[$entity->tid] = $entity; // $workflow->sortTransitions(); } } // Reset the cache for the affected workflow, to force reload upon next page_load. workflow_reset_cache($entity->wid); return $return; } } src/Entity/WorkflowController.php 0 → 100644 +72 −0 Changes for src/Entity/WorkflowController.php: 72 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains workflow\includes\Entity\WorkflowController. */ /** * Implements a controller class for Workflow. */ class WorkflowController extends EntityAPIControllerExportable { // public function create(array $values = array()) { return parent::create($values); } // public function load($ids = array(), $conditions = array()) { } public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace WorkflowController::delete() with parent. // @todo: throw error if not workflow->isDeletable(). foreach ($ids as $wid) { if ($workflow = workflow_load($wid)) { $workflow->delete(); } } $this->resetCache(); } /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to Core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } /** * Overrides DrupalDefaultEntityController::cacheSet(). */ /* // protected function cacheSet($entities) { } // return parent::cacheSet($entities); // } */ /** * Overrides DrupalDefaultEntityController::resetCache(). * * Called by workflow_reset_cache, to * Reset the Workflow when States, Transitions have been changed. */ // public function resetCache(array $ids = NULL) { // parent::resetCache($ids); // } /** * Overrides DrupalDefaultEntityController::attachLoad(). */ protected function attachLoad(&$queried_entities, $revision_id = FALSE) { foreach ($queried_entities as $entity) { // Load the states, so they are already present on the next (cached) load. $entity->states = $entity->getStates($all = TRUE); $entity->transitions = $entity->getTransitions(FALSE); $entity->typeMap = $entity->getTypeMap(); } parent::attachLoad($queried_entities, $revision_id); } } src/Entity/WorkflowState.php +0 −43 Changes for src/Entity/WorkflowState.php: 0 added lines, 43 removed lines. Original line number Diff line number Diff line Loading @@ -5,49 +5,6 @@ * Contains workflow\includes\Entity\WorkflowState. */ class WorkflowStateController extends EntityAPIController { public function save($entity, DatabaseTransaction $transaction = NULL) { // Create the machine_name. if (empty($entity->name)) { if ($label = $entity->state) { $entity->name = str_replace(' ', '_', strtolower($label)); } else { $entity->name = 'state_' . $entity->sid; } } $return = parent::save($entity, $transaction); if ($return) { $workflow = $entity->getWorkflow(); // Maintain the new object in the workflow. $workflow->states[$entity->sid] = $entity; } // Reset the cache for the affected workflow. workflow_reset_cache($entity->wid); return $return; } public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace with parent. foreach ($ids as $id) { if ($state = workflow_state_load($id)) { $wid = $state->wid; db_delete('workflow_states') ->condition('sid', $state->sid) ->execute(); // Reset the cache for the affected workflow. workflow_reset_cache($wid); } } } } class WorkflowState extends Entity { // Since workflows do not change, it is implemented as a singleton. protected static $states = array(); Loading Loading
src/Entity/Workflow.php +0 −67 Changes for src/Entity/Workflow.php: 0 added lines, 67 removed lines. Original line number Diff line number Diff line Loading @@ -3,75 +3,8 @@ /** * @file * Contains workflow\includes\Entity\Workflow. * Contains workflow\includes\Entity\WorkflowController. */ /** * Implements a controller class for Workflow. */ class WorkflowController extends EntityAPIControllerExportable { // public function create(array $values = array()) { return parent::create($values); } // public function load($ids = array(), $conditions = array()) { } public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace WorkflowController::delete() with parent. // @todo: throw error if not workflow->isDeletable(). foreach ($ids as $wid) { if ($workflow = workflow_load($wid)) { $workflow->delete(); } } $this->resetCache(); } /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to Core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } /** * Overrides DrupalDefaultEntityController::cacheSet(). */ /* // protected function cacheSet($entities) { } // return parent::cacheSet($entities); // } */ /** * Overrides DrupalDefaultEntityController::resetCache(). * * Called by workflow_reset_cache, to * Reset the Workflow when States, Transitions have been changed. */ // public function resetCache(array $ids = NULL) { // parent::resetCache($ids); // } /** * Overrides DrupalDefaultEntityController::attachLoad(). */ protected function attachLoad(&$queried_entities, $revision_id = FALSE) { foreach ($queried_entities as $entity) { // Load the states, so they are already present on the next (cached) load. $entity->states = $entity->getStates($all = TRUE); $entity->transitions = $entity->getTransitions(FALSE); $entity->typeMap = $entity->getTypeMap(); } parent::attachLoad($queried_entities, $revision_id); } } class Workflow extends Entity { public $wid = 0; public $name = ''; Loading
src/Entity/WorkflowConfigTransition.php +0 −59 Changes for src/Entity/WorkflowConfigTransition.php: 0 added lines, 59 removed lines. Original line number Diff line number Diff line Loading @@ -3,67 +3,8 @@ /** * @file * Contains workflow\includes\Entity\WorkflowConfigTransition. * Contains workflow\includes\Entity\WorkflowConfigTransitionController. */ /** * Implements a controller class for WorkflowConfigTransition. * * The 'true' controller class is 'Workflow'. */ class WorkflowConfigTransitionController extends EntityAPIController { /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } public function save($entity, DatabaseTransaction $transaction = NULL) { $workflow = $entity->getWorkflow(); // To avoid double posting, check if this transition already exist. if (empty($entity->tid)) { if ($workflow) { $config_transitions = $workflow->getTransitionsBySidTargetSid($entity->sid, $entity->target_sid); $config_transition = reset($config_transitions); if ($config_transition) { $entity->tid = $config_transition->tid; } } } // Create the machine_name. This can be used to rebuild/revert the Feature in a target system. if (empty($entity->name)) { $entity->name = $entity->sid . '_' . $entity->target_sid; } $return = parent::save($entity, $transaction); if ($return) { // Save in current workflow for the remainder of this page request. // Keep in sync with Workflow::getTransitions() ! $workflow = $entity->getWorkflow(); if ($workflow) { $workflow->transitions[$entity->tid] = $entity; // $workflow->sortTransitions(); } } // Reset the cache for the affected workflow, to force reload upon next page_load. workflow_reset_cache($entity->wid); return $return; } } /** * Implements a configurated Transition. */ Loading
src/Entity/WorkflowConfigTransitionController.php 0 → 100644 +63 −0 Changes for src/Entity/WorkflowConfigTransitionController.php: 63 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains workflow\includes\Entity\WorkflowConfigTransitionController. */ /** * Implements a controller class for WorkflowConfigTransition. * * The 'true' controller class is 'Workflow'. */ class WorkflowConfigTransitionController extends EntityAPIController { /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } public function save($entity, DatabaseTransaction $transaction = NULL) { $workflow = $entity->getWorkflow(); // To avoid double posting, check if this transition already exist. if (empty($entity->tid)) { if ($workflow) { $config_transitions = $workflow->getTransitionsBySidTargetSid($entity->sid, $entity->target_sid); $config_transition = reset($config_transitions); if ($config_transition) { $entity->tid = $config_transition->tid; } } } // Create the machine_name. This can be used to rebuild/revert the Feature in a target system. if (empty($entity->name)) { $entity->name = $entity->sid . '_' . $entity->target_sid; } $return = parent::save($entity, $transaction); if ($return) { // Save in current workflow for the remainder of this page request. // Keep in sync with Workflow::getTransitions() ! $workflow = $entity->getWorkflow(); if ($workflow) { $workflow->transitions[$entity->tid] = $entity; // $workflow->sortTransitions(); } } // Reset the cache for the affected workflow, to force reload upon next page_load. workflow_reset_cache($entity->wid); return $return; } }
src/Entity/WorkflowController.php 0 → 100644 +72 −0 Changes for src/Entity/WorkflowController.php: 72 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains workflow\includes\Entity\WorkflowController. */ /** * Implements a controller class for Workflow. */ class WorkflowController extends EntityAPIControllerExportable { // public function create(array $values = array()) { return parent::create($values); } // public function load($ids = array(), $conditions = array()) { } public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace WorkflowController::delete() with parent. // @todo: throw error if not workflow->isDeletable(). foreach ($ids as $wid) { if ($workflow = workflow_load($wid)) { $workflow->delete(); } } $this->resetCache(); } /** * Overrides DrupalDefaultEntityController::cacheGet(). * * Override default function, due to Core issue #1572466. */ protected function cacheGet($ids, $conditions = array()) { // Load any available entities from the internal cache. if ($ids === FALSE && !$conditions) { return $this->entityCache; } return parent::cacheGet($ids, $conditions); } /** * Overrides DrupalDefaultEntityController::cacheSet(). */ /* // protected function cacheSet($entities) { } // return parent::cacheSet($entities); // } */ /** * Overrides DrupalDefaultEntityController::resetCache(). * * Called by workflow_reset_cache, to * Reset the Workflow when States, Transitions have been changed. */ // public function resetCache(array $ids = NULL) { // parent::resetCache($ids); // } /** * Overrides DrupalDefaultEntityController::attachLoad(). */ protected function attachLoad(&$queried_entities, $revision_id = FALSE) { foreach ($queried_entities as $entity) { // Load the states, so they are already present on the next (cached) load. $entity->states = $entity->getStates($all = TRUE); $entity->transitions = $entity->getTransitions(FALSE); $entity->typeMap = $entity->getTypeMap(); } parent::attachLoad($queried_entities, $revision_id); } }
src/Entity/WorkflowState.php +0 −43 Changes for src/Entity/WorkflowState.php: 0 added lines, 43 removed lines. Original line number Diff line number Diff line Loading @@ -5,49 +5,6 @@ * Contains workflow\includes\Entity\WorkflowState. */ class WorkflowStateController extends EntityAPIController { public function save($entity, DatabaseTransaction $transaction = NULL) { // Create the machine_name. if (empty($entity->name)) { if ($label = $entity->state) { $entity->name = str_replace(' ', '_', strtolower($label)); } else { $entity->name = 'state_' . $entity->sid; } } $return = parent::save($entity, $transaction); if ($return) { $workflow = $entity->getWorkflow(); // Maintain the new object in the workflow. $workflow->states[$entity->sid] = $entity; } // Reset the cache for the affected workflow. workflow_reset_cache($entity->wid); return $return; } public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace with parent. foreach ($ids as $id) { if ($state = workflow_state_load($id)) { $wid = $state->wid; db_delete('workflow_states') ->condition('sid', $state->sid) ->execute(); // Reset the cache for the affected workflow. workflow_reset_cache($wid); } } } } class WorkflowState extends Entity { // Since workflows do not change, it is implemented as a singleton. protected static $states = array(); Loading