/**
         * Removes all children of given property and attaches them again in 
right order
         * @param $obj
         * @param $forProperty
         * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
         */
        public function setSorting($obj, $forProperty) {
                if ($this->request->hasArgument('swappedItems')) {
                        $swappedItems = 
(array)json_decode($this->request->getArgument('swappedItems'));
                        if ($swappedItems) {
                                // remove all childs
                                $obj->removeAllAttachedObjects($forProperty);
                                
                                // attach in correct order
                                foreach ($swappedItems as $uid => $childs) {
                                        $model = new ReflectionClass($obj);
                                        if (property_exists($obj, 
$forProperty)) {
                                                $propertDocComment = 
$model->getProperty($forProperty)->getDocComment();
                                                preg_match('/.*\\\(.+)>/', 
$propertDocComment, $matches);
                                                $repositoryName = $matches[1];
                                                $repository = 
$this->objectManager->get('KKSoftware\Kkbaybw\Domain\Repository\\' . 
$repositoryName . 'Repository');
                                                foreach ($childs as $child) {
                                                        $childObj = 
$repository->findByUid((int)$child);
                                                        $method = 'add' . 
ucfirst($forProperty);
                                                        
$obj->{$method}($childObj);
                                                }
                                        }
                                }
                        }
                }
        }
_______________________________________________
TYPO3-german mailing list
TYPO3-german@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german

Antwort per Email an