{"action":"created","issue":{"url":"https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle/issues/60","repository_url":"https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle","labels_url":"https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle/issues/60/comments","events_url":"https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle/issues/60/events","html_url":"https://github.com/pix-digital/pixSortableBehaviorBundle/issues/60","id":219818018,"number":60,"title":"Discriminator with Class table inheritance not working correctly for getLastPosition","user":{"login":"twify93","id":8925621,"avatar_url":"https://avatars0.githubusercontent.com/u/8925621?v=3","gravatar_id":"","url":"https://api.github.com/users/twify93","html_url":"https://github.com/twify93","followers_url":"https://api.github.com/users/twify93/followers","following_url":"https://api.github.com/users/twify93/following{/other_user}","gists_url":"https://api.github.com/users/twify93/gists{/gist_id}","starred_url":"https://api.github.com/users/twify93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twify93/subscriptions","organizations_url":"https://api.github.com/users/twify93/orgs","repos_url":"https://api.github.com/users/twify93/repos","events_url":"https://api.github.com/users/twify93/events{/privacy}","received_events_url":"https://api.github.com/users/twify93/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-06T08:08:17Z","updated_at":"2017-06-24T08:40:15Z","closed_at":null,"body":"Hello,\r\nI have this problem where I am using the setup with discriminator in Doctrine and the Class table inheritance and the field is actually on the main Entity rather than each individual Entity, because I want to sort them all on 1 place.\r\nBut this causes the problem that getLastPossition creates query for the child entity class rather than the main. And so I see them all in 1 page, but the buttons are all wrong, because of that.\r\nMeaning that imageOnSide records are only 2 and that's why the getLastPossition returns 2, but it should count all elements in parent entity.\r\n\r\n<img width=\"1441\" alt=\"screen shot 2017-04-06 at 10 07 53\" src=\"https://cloud.githubusercontent.com/assets/8925621/24744047/f252fc6e-1ab0-11e7-9c1a-f0901ca319f9.png\">\r\n"},"comment":{"url":"https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle/issues/comments/310825504","html_url":"https://github.com/pix-digital/pixSortableBehaviorBundle/issues/60#issuecomment-310825504","issue_url":"https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle/issues/60","id":310825504,"user":{"login":"Tofandel","id":6115458,"avatar_url":"https://avatars3.githubusercontent.com/u/6115458?v=3","gravatar_id":"","url":"https://api.github.com/users/Tofandel","html_url":"https://github.com/Tofandel","followers_url":"https://api.github.com/users/Tofandel/followers","following_url":"https://api.github.com/users/Tofandel/following{/other_user}","gists_url":"https://api.github.com/users/Tofandel/gists{/gist_id}","starred_url":"https://api.github.com/users/Tofandel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tofandel/subscriptions","organizations_url":"https://api.github.com/users/Tofandel/orgs","repos_url":"https://api.github.com/users/Tofandel/repos","events_url":"https://api.github.com/users/Tofandel/events{/privacy}","received_events_url":"https://api.github.com/users/Tofandel/received_events","type":"User","site_admin":false},"created_at":"2017-06-24T08:40:15Z","updated_at":"2017-06-24T08:40:15Z","body":"I've made a fix for this issue in the PositionORMHandler.php file : \r\n```php\r\n public function getLastPosition($entity)\r\n    {\r\n\t    $entityClass = ClassUtils::getClass($entity);\r\n\t    $parentEntityClass = true;\r\n\t    while ($parentEntityClass)\r\n\t    {\r\n\t\t    $parentEntityClass = ClassUtils::getParentClass($entity);\r\n\t\t    if ($parentEntityClass)\r\n\t\t\t    $entityClass = $parentEntityClass;\r\n\t    }\r\n\r\n        $positionFields = $this->getPositionFieldByEntity($entityClass);\r\n        $result = $this->dm\r\n            ->createQueryBuilder($entityClass)\r\n            ->hydrate(false)\r\n            ->select($positionFields)\r\n            ->sort($positionFields, 'desc')\r\n            ->limit(1)\r\n            ->getQuery()\r\n            ->getSingleResult();\r\n\r\n        if (is_array($result) && isset($result[$positionFields])) {\r\n            return $result[$positionFields];\r\n        }\r\n\r\n        return 0;\r\n    }\r\n```"}}
{"actor":{"display_login":"Tofandel"}}