/** * Load process behavior. * * @param Table $table */ protected function _loadBehavior(Table $table) { $behaviors = $table->behaviors(); if (!Arr::in('Process', $behaviors->loaded())) { $behaviors->load('Union/Core.Process'); } }
/** * Move record in tree table. * * @param Table|\Cake\ORM\Table $table * @param EntityInterface $entity * @param string $type * @param array $options * @param int $step * @return \Cake\Network\Response|null */ public function move(Table $table, EntityInterface $entity, $type = self::MOVE_UP, array $options = [], $step = 1) { $behaviors = $table->behaviors(); if (!in_array('Tree', $behaviors->loaded())) { $behaviors->load('Tree', ['scope' => $entity->get('id')]); } $behaviors->get('Tree')->config('scope', $entity->get('id')); $_options = ['success' => __d('union', 'Object has been moved.'), 'error' => __d('union', 'Object could not been moved.'), 'redirect' => ['prefix' => $this->request->param('prefix'), 'plugin' => $this->request->param('plugin'), 'controller' => $this->request->param('controller'), 'action' => 'index']]; $options = Hash::merge($_options, $options); if ($table->{$type}($entity, $step)) { $this->Flash->success($options['success']); } else { $this->Flash->error($options['error']); } return $this->_controller->redirect($options['redirect']); }