{"action":"created","comment":{"url":"https://api.github.com/repos/ilios/ilios/pulls/comments/38169451","id":38169451,"diff_hunk":"@@ -0,0 +1,127 @@\n+<?php\n+\n+namespace Ilios\\CoreBundle\\DataFixtures\\ORM;\n+\n+use Doctrine\\ORM\\Mapping\\ClassMetadata;\n+use Doctrine\\Common\\DataFixtures\\AbstractFixture as DataFixture;\n+use Doctrine\\Common\\DataFixtures\\FixtureInterface;\n+use Doctrine\\Common\\Persistence\\ObjectManager;\n+\n+use Ilios\\CoreBundle\\Traits\\IdentifiableEntityInterface;\n+use Symfony\\Component\\HttpKernel\\Config\\FileLocator;\n+use Symfony\\Component\\DependencyInjection\\ContainerAwareInterface;\n+use Symfony\\Component\\DependencyInjection\\ContainerInterface;\n+\n+/**\n+ * A Doctrine fixture based data loader base class that populates the DB from data files.\n+ *\n+ * Class AbstractFixture\n+ * @package Ilios\\CoreBundle\\DataFixtures\\ORM\n+ */\n+abstract class AbstractFixture extends DataFixture implements\n+    FixtureInterface,\n+    ContainerAwareInterface\n+{\n+    /**\n+     * @var string\n+     * Doubles as identifier for this fixture's data file and entity references.\n+     */\n+    protected $key;\n+\n+    /**\n+     * @var boolean\n+     * Set to TRUE if the loaded fixture should be held on for reference.\n+     */\n+    protected $storeReference;\n+\n+    /**\n+     * @var ContainerInterface\n+     */\n+    private $container;\n+\n+\n+\n+    /**\n+     * @param string $key\n+     * @param boolean $storeReference\n+     */\n+    public function __construct($key, $storeReference = true)\n+    {\n+        $this->key = $key;\n+        $this->storeReference = $storeReference;\n+    }\n+\n+    public function getKey()\n+    {\n+        return $this->key;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function setContainer(ContainerInterface $container = null)\n+    {\n+        $this->container = $container;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function load(ObjectManager $manager)\n+    {\n+\n+        $fileName = $this->getKey() . '.csv';\n+        $path = $this->getDataFilePath($fileName);\n+\n+        $first = true;\n+        if (($handle = fopen($path, 'r')) !== false) {\n+            while (($data = fgetcsv($handle)) !== false) {\n+                // step over the first row\n+                // since it contains the field names\n+                if ($first) {\n+                    $first = false;\n+                    continue;\n+                }\n+                $entity = $this->createEntity($data);\n+                $manager->persist($entity);\n+\n+                // honor the given entity identifiers.\n+                // @link http://www.ens.ro/2012/07/03/symfony2-doctrine-force-entity-id-on-persist/\n+                $metadata = $manager->getClassMetaData(get_class($entity));\n+                $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);\n+\n+                if ($this->storeReference) {\n+                    $this->addReference($this->getKey() . $entity->getId(), $entity);\n+                }\n+                $manager->flush();\n+            }\n+            fclose($handle);\n+        }\n+    }\n+\n+    /**\n+     * Finds and return the absolute path to a given data file.\n+     * @param string $fileName name of the data file.\n+     * @return string the absolute path.\n+     */\n+    protected function getDataFilePath($fileName)\n+    {\n+        /**\n+         * @var FileLocator $fileLocator\n+         */\n+        $fileLocator = $this->container->get('file_locator');\n+\n+        // TODO: pull this hardwired path to the data files out into configuration. [ST 2015/08/26]","path":"src/Ilios/CoreBundle/DataFixtures/ORM/AbstractFixture.php","position":114,"original_position":114,"commit_id":"0eaec357689dd309cf2174006597d7c9021cb9ee","original_commit_id":"0eaec357689dd309cf2174006597d7c9021cb9ee","user":{"login":"jrjohnson","id":349624,"avatar_url":"https://avatars.githubusercontent.com/u/349624?v=3","gravatar_id":"","url":"https://api.github.com/users/jrjohnson","html_url":"https://github.com/jrjohnson","followers_url":"https://api.github.com/users/jrjohnson/followers","following_url":"https://api.github.com/users/jrjohnson/following{/other_user}","gists_url":"https://api.github.com/users/jrjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/jrjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrjohnson/subscriptions","organizations_url":"https://api.github.com/users/jrjohnson/orgs","repos_url":"https://api.github.com/users/jrjohnson/repos","events_url":"https://api.github.com/users/jrjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/jrjohnson/received_events","type":"User","site_admin":false},"body":"Would the point of pulling this out be to allow an implementer to use their own fixtures?  Otherwise I think maybe it could be a constant in this class, but we're not likely to want to move it around.","created_at":"2015-08-28T03:56:28Z","updated_at":"2015-08-28T03:56:28Z","html_url":"https://github.com/ilios/ilios/pull/982#discussion_r38169451","pull_request_url":"https://api.github.com/repos/ilios/ilios/pulls/982","_links":{"self":{"href":"https://api.github.com/repos/ilios/ilios/pulls/comments/38169451"},"html":{"href":"https://github.com/ilios/ilios/pull/982#discussion_r38169451"},"pull_request":{"href":"https://api.github.com/repos/ilios/ilios/pulls/982"}}},"pull_request":{"url":"https://api.github.com/repos/ilios/ilios/pulls/982","id":43555133,"html_url":"https://github.com/ilios/ilios/pull/982","diff_url":"https://github.com/ilios/ilios/pull/982.diff","patch_url":"https://github.com/ilios/ilios/pull/982.patch","issue_url":"https://api.github.com/repos/ilios/ilios/issues/982","number":982,"state":"open","locked":false,"title":"import default data population","user":{"login":"stopfstedt","id":1410427,"avatar_url":"https://avatars.githubusercontent.com/u/1410427?v=3","gravatar_id":"","url":"https://api.github.com/users/stopfstedt","html_url":"https://github.com/stopfstedt","followers_url":"https://api.github.com/users/stopfstedt/followers","following_url":"https://api.github.com/users/stopfstedt/following{/other_user}","gists_url":"https://api.github.com/users/stopfstedt/gists{/gist_id}","starred_url":"https://api.github.com/users/stopfstedt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stopfstedt/subscriptions","organizations_url":"https://api.github.com/users/stopfstedt/orgs","repos_url":"https://api.github.com/users/stopfstedt/repos","events_url":"https://api.github.com/users/stopfstedt/events{/privacy}","received_events_url":"https://api.github.com/users/stopfstedt/received_events","type":"User","site_admin":false},"body":"fixes #892","created_at":"2015-08-27T19:13:15Z","updated_at":"2015-08-28T03:56:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9624bbf6a99130a6381da858df370f9f1477a68e","assignee":{"login":"jrjohnson","id":349624,"avatar_url":"https://avatars.githubusercontent.com/u/349624?v=3","gravatar_id":"","url":"https://api.github.com/users/jrjohnson","html_url":"https://github.com/jrjohnson","followers_url":"https://api.github.com/users/jrjohnson/followers","following_url":"https://api.github.com/users/jrjohnson/following{/other_user}","gists_url":"https://api.github.com/users/jrjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/jrjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrjohnson/subscriptions","organizations_url":"https://api.github.com/users/jrjohnson/orgs","repos_url":"https://api.github.com/users/jrjohnson/repos","events_url":"https://api.github.com/users/jrjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/jrjohnson/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ilios/ilios/pulls/982/commits","review_comments_url":"https://api.github.com/repos/ilios/ilios/pulls/982/comments","review_comment_url":"https://api.github.com/repos/ilios/ilios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ilios/ilios/issues/982/comments","statuses_url":"https://api.github.com/repos/ilios/ilios/statuses/0eaec357689dd309cf2174006597d7c9021cb9ee","head":{"label":"stopfstedt:892_import_default_data_task","ref":"892_import_default_data_task","sha":"0eaec357689dd309cf2174006597d7c9021cb9ee","user":{"login":"stopfstedt","id":1410427,"avatar_url":"https://avatars.githubusercontent.com/u/1410427?v=3","gravatar_id":"","url":"https://api.github.com/users/stopfstedt","html_url":"https://github.com/stopfstedt","followers_url":"https://api.github.com/users/stopfstedt/followers","following_url":"https://api.github.com/users/stopfstedt/following{/other_user}","gists_url":"https://api.github.com/users/stopfstedt/gists{/gist_id}","starred_url":"https://api.github.com/users/stopfstedt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stopfstedt/subscriptions","organizations_url":"https://api.github.com/users/stopfstedt/orgs","repos_url":"https://api.github.com/users/stopfstedt/repos","events_url":"https://api.github.com/users/stopfstedt/events{/privacy}","received_events_url":"https://api.github.com/users/stopfstedt/received_events","type":"User","site_admin":false},"repo":{"id":38850934,"name":"ilios","full_name":"stopfstedt/ilios","owner":{"login":"stopfstedt","id":1410427,"avatar_url":"https://avatars.githubusercontent.com/u/1410427?v=3","gravatar_id":"","url":"https://api.github.com/users/stopfstedt","html_url":"https://github.com/stopfstedt","followers_url":"https://api.github.com/users/stopfstedt/followers","following_url":"https://api.github.com/users/stopfstedt/following{/other_user}","gists_url":"https://api.github.com/users/stopfstedt/gists{/gist_id}","starred_url":"https://api.github.com/users/stopfstedt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stopfstedt/subscriptions","organizations_url":"https://api.github.com/users/stopfstedt/orgs","repos_url":"https://api.github.com/users/stopfstedt/repos","events_url":"https://api.github.com/users/stopfstedt/events{/privacy}","received_events_url":"https://api.github.com/users/stopfstedt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stopfstedt/ilios","description":"Curriculum Management System for the Health Professions","fork":true,"url":"https://api.github.com/repos/stopfstedt/ilios","forks_url":"https://api.github.com/repos/stopfstedt/ilios/forks","keys_url":"https://api.github.com/repos/stopfstedt/ilios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stopfstedt/ilios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stopfstedt/ilios/teams","hooks_url":"https://api.github.com/repos/stopfstedt/ilios/hooks","issue_events_url":"https://api.github.com/repos/stopfstedt/ilios/issues/events{/number}","events_url":"https://api.github.com/repos/stopfstedt/ilios/events","assignees_url":"https://api.github.com/repos/stopfstedt/ilios/assignees{/user}","branches_url":"https://api.github.com/repos/stopfstedt/ilios/branches{/branch}","tags_url":"https://api.github.com/repos/stopfstedt/ilios/tags","blobs_url":"https://api.github.com/repos/stopfstedt/ilios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stopfstedt/ilios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stopfstedt/ilios/git/refs{/sha}","trees_url":"https://api.github.com/repos/stopfstedt/ilios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stopfstedt/ilios/statuses/{sha}","languages_url":"https://api.github.com/repos/stopfstedt/ilios/languages","stargazers_url":"https://api.github.com/repos/stopfstedt/ilios/stargazers","contributors_url":"https://api.github.com/repos/stopfstedt/ilios/contributors","subscribers_url":"https://api.github.com/repos/stopfstedt/ilios/subscribers","subscription_url":"https://api.github.com/repos/stopfstedt/ilios/subscription","commits_url":"https://api.github.com/repos/stopfstedt/ilios/commits{/sha}","git_commits_url":"https://api.github.com/repos/stopfstedt/ilios/git/commits{/sha}","comments_url":"https://api.github.com/repos/stopfstedt/ilios/comments{/number}","issue_comment_url":"https://api.github.com/repos/stopfstedt/ilios/issues/comments{/number}","contents_url":"https://api.github.com/repos/stopfstedt/ilios/contents/{+path}","compare_url":"https://api.github.com/repos/stopfstedt/ilios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stopfstedt/ilios/merges","archive_url":"https://api.github.com/repos/stopfstedt/ilios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stopfstedt/ilios/downloads","issues_url":"https://api.github.com/repos/stopfstedt/ilios/issues{/number}","pulls_url":"https://api.github.com/repos/stopfstedt/ilios/pulls{/number}","milestones_url":"https://api.github.com/repos/stopfstedt/ilios/milestones{/number}","notifications_url":"https://api.github.com/repos/stopfstedt/ilios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stopfstedt/ilios/labels{/name}","releases_url":"https://api.github.com/repos/stopfstedt/ilios/releases{/id}","created_at":"2015-07-09T23:47:08Z","updated_at":"2015-07-09T23:47:10Z","pushed_at":"2015-08-28T03:23:58Z","git_url":"git://github.com/stopfstedt/ilios.git","ssh_url":"git@github.com:stopfstedt/ilios.git","clone_url":"https://github.com/stopfstedt/ilios.git","svn_url":"https://github.com/stopfstedt/ilios","homepage":"https://www.iliosproject.org","size":40391,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ilios:master","ref":"master","sha":"58ec0121a4d7611fed7ab922238c265dbabbada6","user":{"login":"ilios","id":2955721,"avatar_url":"https://avatars.githubusercontent.com/u/2955721?v=3","gravatar_id":"","url":"https://api.github.com/users/ilios","html_url":"https://github.com/ilios","followers_url":"https://api.github.com/users/ilios/followers","following_url":"https://api.github.com/users/ilios/following{/other_user}","gists_url":"https://api.github.com/users/ilios/gists{/gist_id}","starred_url":"https://api.github.com/users/ilios/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilios/subscriptions","organizations_url":"https://api.github.com/users/ilios/orgs","repos_url":"https://api.github.com/users/ilios/repos","events_url":"https://api.github.com/users/ilios/events{/privacy}","received_events_url":"https://api.github.com/users/ilios/received_events","type":"Organization","site_admin":false},"repo":{"id":7026531,"name":"ilios","full_name":"ilios/ilios","owner":{"login":"ilios","id":2955721,"avatar_url":"https://avatars.githubusercontent.com/u/2955721?v=3","gravatar_id":"","url":"https://api.github.com/users/ilios","html_url":"https://github.com/ilios","followers_url":"https://api.github.com/users/ilios/followers","following_url":"https://api.github.com/users/ilios/following{/other_user}","gists_url":"https://api.github.com/users/ilios/gists{/gist_id}","starred_url":"https://api.github.com/users/ilios/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilios/subscriptions","organizations_url":"https://api.github.com/users/ilios/orgs","repos_url":"https://api.github.com/users/ilios/repos","events_url":"https://api.github.com/users/ilios/events{/privacy}","received_events_url":"https://api.github.com/users/ilios/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ilios/ilios","description":"Curriculum Management System for the Health Professions","fork":false,"url":"https://api.github.com/repos/ilios/ilios","forks_url":"https://api.github.com/repos/ilios/ilios/forks","keys_url":"https://api.github.com/repos/ilios/ilios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ilios/ilios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ilios/ilios/teams","hooks_url":"https://api.github.com/repos/ilios/ilios/hooks","issue_events_url":"https://api.github.com/repos/ilios/ilios/issues/events{/number}","events_url":"https://api.github.com/repos/ilios/ilios/events","assignees_url":"https://api.github.com/repos/ilios/ilios/assignees{/user}","branches_url":"https://api.github.com/repos/ilios/ilios/branches{/branch}","tags_url":"https://api.github.com/repos/ilios/ilios/tags","blobs_url":"https://api.github.com/repos/ilios/ilios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ilios/ilios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ilios/ilios/git/refs{/sha}","trees_url":"https://api.github.com/repos/ilios/ilios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ilios/ilios/statuses/{sha}","languages_url":"https://api.github.com/repos/ilios/ilios/languages","stargazers_url":"https://api.github.com/repos/ilios/ilios/stargazers","contributors_url":"https://api.github.com/repos/ilios/ilios/contributors","subscribers_url":"https://api.github.com/repos/ilios/ilios/subscribers","subscription_url":"https://api.github.com/repos/ilios/ilios/subscription","commits_url":"https://api.github.com/repos/ilios/ilios/commits{/sha}","git_commits_url":"https://api.github.com/repos/ilios/ilios/git/commits{/sha}","comments_url":"https://api.github.com/repos/ilios/ilios/comments{/number}","issue_comment_url":"https://api.github.com/repos/ilios/ilios/issues/comments{/number}","contents_url":"https://api.github.com/repos/ilios/ilios/contents/{+path}","compare_url":"https://api.github.com/repos/ilios/ilios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ilios/ilios/merges","archive_url":"https://api.github.com/repos/ilios/ilios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ilios/ilios/downloads","issues_url":"https://api.github.com/repos/ilios/ilios/issues{/number}","pulls_url":"https://api.github.com/repos/ilios/ilios/pulls{/number}","milestones_url":"https://api.github.com/repos/ilios/ilios/milestones{/number}","notifications_url":"https://api.github.com/repos/ilios/ilios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ilios/ilios/labels{/name}","releases_url":"https://api.github.com/repos/ilios/ilios/releases{/id}","created_at":"2012-12-05T23:27:26Z","updated_at":"2015-08-20T21:10:41Z","pushed_at":"2015-08-28T03:23:58Z","git_url":"git://github.com/ilios/ilios.git","ssh_url":"git@github.com:ilios/ilios.git","clone_url":"https://github.com/ilios/ilios.git","svn_url":"https://github.com/ilios/ilios","homepage":"https://www.iliosproject.org","size":41229,"stargazers_count":17,"watchers_count":17,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":40,"forks":18,"open_issues":40,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ilios/ilios/pulls/982"},"html":{"href":"https://github.com/ilios/ilios/pull/982"},"issue":{"href":"https://api.github.com/repos/ilios/ilios/issues/982"},"comments":{"href":"https://api.github.com/repos/ilios/ilios/issues/982/comments"},"review_comments":{"href":"https://api.github.com/repos/ilios/ilios/pulls/982/comments"},"review_comment":{"href":"https://api.github.com/repos/ilios/ilios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ilios/ilios/pulls/982/commits"},"statuses":{"href":"https://api.github.com/repos/ilios/ilios/statuses/0eaec357689dd309cf2174006597d7c9021cb9ee"}}}}