diff --git a/Symfony/app/DoctrineMigrations/Version20160331141711.php b/Symfony/app/DoctrineMigrations/Version20160331141711.php new file mode 100644 index 00000000..47b90b2c --- /dev/null +++ b/Symfony/app/DoctrineMigrations/Version20160331141711.php @@ -0,0 +1,38 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE Example DROP FOREIGN KEY FK_A151A203FE2541D7'); + $this->addSql('DROP TABLE Example'); + $this->addSql('DROP TABLE ExternalLibrary'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE Example (id INT AUTO_INCREMENT NOT NULL, library_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, boards VARCHAR(2048) DEFAULT NULL, INDEX IDX_A151A203FE2541D7 (library_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE ExternalLibrary (id INT AUTO_INCREMENT NOT NULL, humanName VARCHAR(255) NOT NULL, machineName VARCHAR(255) NOT NULL, description VARCHAR(2048) NOT NULL, owner VARCHAR(255) DEFAULT NULL, repo VARCHAR(255) DEFAULT NULL, verified TINYINT(1) NOT NULL, active TINYINT(1) NOT NULL, lastCommit VARCHAR(255) DEFAULT NULL, url VARCHAR(512) DEFAULT NULL, branch VARCHAR(255) DEFAULT NULL, in_repo_path VARCHAR(255) DEFAULT NULL, notes LONGTEXT DEFAULT NULL, source_url VARCHAR(512) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql('ALTER TABLE Example ADD CONSTRAINT FK_A151A203FE2541D7 FOREIGN KEY (library_id) REFERENCES ExternalLibrary (id)'); + } +} diff --git a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryData.php b/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryData.php deleted file mode 100644 index 60b2594f..00000000 --- a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryData.php +++ /dev/null @@ -1,159 +0,0 @@ -setHumanName('Default Arduino Library'); - $defaultLibrary->setMachineName('default'); - $defaultLibrary->setActive(true); - $defaultLibrary->setVerified(false); - $defaultLibrary->setDescription('The default Arduino library (in fact it\'s Adafruit\'s GPS library)'); - $defaultLibrary->setNotes('No notes provided for this library'); - $defaultLibrary->setUrl('http://localhost/library/url'); - - /* - * Set a reference for the library and add it to the database using - * the object manager interface - */ - $this->setReference('defaultLibrary', $defaultLibrary); - $objectManager->persist($defaultLibrary); - - // Dynamic Array Helper library hosted on codebender's Github organistion - $dahLibrary = new ExternalLibrary(); - $dahLibrary->setHumanName('Dynamic Array Helper Arduino Library'); - $dahLibrary->setMachineName('DynamicArrayHelper'); - $dahLibrary->setActive(true); - $dahLibrary->setVerified(false); - $dahLibrary->setDescription('DynamicArrayHelper Arduino Library from the Arduino Playground'); - $dahLibrary->setUrl('https://github.com/codebendercc/DynamicArrayHelper-Arduino-Library'); - $dahLibrary->setSourceUrl('https://github.com/codebendercc/DynamicArrayHelper-Arduino-Library/archive/1.0.x.zip'); - $dahLibrary->setBranch('1.0.x'); - $dahLibrary->setOwner('codebendercc'); - $dahLibrary->setRepo('DynamicArrayHelper-Arduino-Library'); - $dahLibrary->setLastCommit('72b8865ee53b3edf159f22f5ff6f9a6dafa7ee1b'); // This is not the last commit of the branch - - // Reference to DynamicArrayHelper library - $this->setReference('dynamicArrayHelperLibrary', $dahLibrary); - $objectManager->persist($dahLibrary); - - // A fake library with multi-ino examples - $multiIno = new ExternalLibrary(); - $multiIno->setHumanName('MultiIno Arduino Library'); - $multiIno->setMachineName('MultiIno'); - $multiIno->setActive(true); - $multiIno->setVerified(false); - $multiIno->setDescription('A library containing multi-ino examples which should be correctly fetched'); - $multiIno->setSourceUrl('https://some/source/url.com'); - - // Reference to MultiIno library - $this->setReference('MultiInoLibrary', $multiIno); - $objectManager->persist($multiIno); - - // A fake library with examples contained in subcategories - $subcategLibrary = new ExternalLibrary(); - $subcategLibrary->setHumanName('SubCategories Arduino Library'); - $subcategLibrary->setMachineName('SubCateg'); - $subcategLibrary->setActive(true); - $subcategLibrary->setVerified(false); - $subcategLibrary->setDescription('A library containing examples sorted in categories'); - $subcategLibrary->setUrl('https://some/url.com'); - $subcategLibrary->setSourceUrl('https://some/source/url.com'); - - // Reference to SubCateg library - $this->setReference('SubCategLibrary', $subcategLibrary); - $objectManager->persist($subcategLibrary); - - // A fake library containing hidden files - $hiddenFilesLibrary = new ExternalLibrary(); - $hiddenFilesLibrary->setHumanName('Hidden'); - $hiddenFilesLibrary->setMachineName('Hidden'); - $hiddenFilesLibrary->setActive(true); - $hiddenFilesLibrary->setVerified(false); - $hiddenFilesLibrary->setDescription('A library containing hidden files and directories in its code & examples'); - $hiddenFilesLibrary->setUrl('https://some/url.com'); - $hiddenFilesLibrary->setSourceUrl('https://some/source/url.com'); - - // Reference to Hidden library - $this->setReference('HiddenLibrary', $hiddenFilesLibrary); - $objectManager->persist($hiddenFilesLibrary); - - // A fake library with non UTF-8 encoded content. - $invalidEncodingLibrary = new ExternalLibrary(); - $invalidEncodingLibrary->setHumanName('Invalid Encoding Library'); - $invalidEncodingLibrary->setMachineName('Encode'); - $invalidEncodingLibrary->setActive(true); - $invalidEncodingLibrary->setVerified(false); - $invalidEncodingLibrary->setDescription('A library containing characters with invalid encoding in it code & examples'); - $invalidEncodingLibrary->setUrl('https://some/url.com'); - $invalidEncodingLibrary->setSourceUrl('https://some/source/url.com'); - - // Reference to Encode library - $this->setReference('EncodeLibrary', $invalidEncodingLibrary); - $objectManager->persist($invalidEncodingLibrary); - - // A fake library with HTML doc files. - $htmlLibrary = new ExternalLibrary(); - $htmlLibrary->setHumanName('HTML content Library'); - $htmlLibrary->setMachineName('HtmlLib'); - $htmlLibrary->setActive(true); - $htmlLibrary->setVerified(false); - $htmlLibrary->setDescription('A library containing HTML in its files'); - $htmlLibrary->setUrl('https://some/url.com'); - $htmlLibrary->setSourceUrl('https://some/source/url.com'); - - $objectManager->persist($htmlLibrary); - - // A fake library with non-text contents. - $binaryLbrary = new ExternalLibrary(); - $binaryLbrary->setHumanName('Binary content Library'); - $binaryLbrary->setMachineName('Binary'); - $binaryLbrary->setActive(true); - $binaryLbrary->setVerified(false); - $binaryLbrary->setDescription('A library containing non-text files'); - $binaryLbrary->setUrl('https://some/url.com'); - $binaryLbrary->setSourceUrl('https://some/source/url.com'); - - // Persist the new library - $objectManager->persist($binaryLbrary); - - /* - * After all fixture objects have been added to the ObjectManager (`persist` operation), - * it's time to flush the contents of the ObjectManager - */ - $objectManager->flush(); - } - - /** - * Returns the order in which the current fixture will be loaded, - * compared to other fixture classes. - * - * @return int - */ - public function getOrder() - { - return 1; - } -} \ No newline at end of file diff --git a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryExamplesData.php b/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryExamplesData.php deleted file mode 100644 index 29164ff8..00000000 --- a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryExamplesData.php +++ /dev/null @@ -1,128 +0,0 @@ -getReference('defaultLibrary'); - - $defaultExample = new Example(); - $defaultExample->setName('example_one'); - $defaultExample->setLibrary($defaultLibrary); - $defaultExample->setPath('default/examples/example_one/example_one.ino'); - $defaultExample->setBoards(null); - - /* - * Set a reference for each example and add it to the database using - * the object manager interface - */ - $this->setReference('defaultLibraryExample', $defaultExample); - $objectManager->persist($defaultExample); - - /* @var \Codebender\LibraryBundle\Entity\ExternalLibrary $multiInoLibrary */ - $multiInoLibrary = $this->getReference('MultiInoLibrary'); - - $example = new Example(); - $example->setName('example_one'); - $example->setLibrary($multiInoLibrary); - $example->setPath('MultiIno/examples/multi_ino_example/multi_ino_example.ino'); - $example->setBoards(null); - - // Persist the new example - $objectManager->persist($example); - - /* @var \Codebender\LibraryBundle\Entity\ExternalLibrary $subcategLibrary */ - $subcategLibrary = $this->getReference('SubCategLibrary'); - - $exampleDefaultCateg = new Example(); - $exampleDefaultCateg->setName('subcateg_example_one'); - $exampleDefaultCateg->setLibrary($subcategLibrary); - $exampleDefaultCateg->setPath('SubCateg/Examples/subcateg_example_one/subcateg_example_one.ino'); - $exampleDefaultCateg->setBoards(null); - - // Persist the new example - $objectManager->persist($exampleDefaultCateg); - - $exampleBeginnerCateg = new Example(); - $exampleBeginnerCateg->setName('subcateg_example_two'); - $exampleBeginnerCateg->setLibrary($subcategLibrary); - $exampleBeginnerCateg->setPath('SubCateg/Examples/experienceBased/Beginners/subcateg_example_two/subcateg_example_two.ino'); - $exampleBeginnerCateg->setBoards(null); - - // Persist the new example - $objectManager->persist($exampleBeginnerCateg); - - $exampleExperiencedCateg = new Example(); - $exampleExperiencedCateg->setName('subcateg_example_three'); - $exampleExperiencedCateg->setLibrary($subcategLibrary); - $exampleExperiencedCateg->setPath('SubCateg/Examples/experienceBased/Advanced/Experts/subcateg_example_three/subcateg_example_three.ino'); - $exampleExperiencedCateg->setBoards(null); - - // Persist the new example - $objectManager->persist($exampleExperiencedCateg); - - /* @var \Codebender\LibraryBundle\Entity\ExternalLibrary $hiddenFilesLibrary */ - $hiddenFilesLibrary = $this->getReference('HiddenLibrary'); - - $hiddenFilesExample = new Example(); - $hiddenFilesExample->setName('hidden_files_example'); - $hiddenFilesExample->setLibrary($hiddenFilesLibrary); - $hiddenFilesExample->setPath('Hidden/examples/hidden_files_example/hidden_files_example.ino'); - $hiddenFilesExample->setBoards(null); - - // Persist the new example - $objectManager->persist($hiddenFilesExample); - - /* @var \Codebender\LibraryBundle\Entity\ExternalLibrary $encodeLibrary */ - $encodeLibrary = $this->getReference('EncodeLibrary'); - - $encodeLibraryExample = new Example(); - $encodeLibraryExample->setName('encoded_example'); - $encodeLibraryExample->setLibrary($encodeLibrary); - $encodeLibraryExample->setPath('Encode/examples/encoded_example/encoded_example.ino'); - $encodeLibraryExample->setBoards(null); - - // Persist the new example - $objectManager->persist($encodeLibraryExample); - - /* - * After all fixture objects have been added to the ObjectManager (`persist` operation), - * it's time to flush the contents of the ObjectManager - */ - $objectManager->flush(); - } - - /** - * Returns the order in which the current fixture will be loaded, - * compared to other fixture classes. - * Examples database data should be provided after the library data, - * because there is a foreign key constraint between them which should - * be satisfied. - * - * @return int - */ - public function getOrder() - { - return 2; - } -} diff --git a/Symfony/src/Codebender/LibraryBundle/Entity/Example.php b/Symfony/src/Codebender/LibraryBundle/Entity/Example.php deleted file mode 100644 index 480dcce2..00000000 --- a/Symfony/src/Codebender/LibraryBundle/Entity/Example.php +++ /dev/null @@ -1,152 +0,0 @@ -id; - } - - /** - * Set name - * - * @param string $name - * @return Example - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Set library - * - * @param ExternalLibrary $library - * @return Example - */ - public function setLibrary($library) - { - $this->library = $library; - - return $this; - } - - /** - * Get library - * - * @return ExternalLibrary - */ - public function getLibrary() - { - return $this->library; - } - - /** - * Set path - * - * @param string $path - * @return Example - */ - public function setPath($path) - { - $this->path = $path; - - return $this; - } - - /** - * Get path - * - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * Set boards - * - * @param string $boards - * @return Example - */ - public function setBoards($boards) - { - $this->boards = $boards; - - return $this; - } - - /** - * Get boards - * - * @return string - */ - public function getBoards() - { - return $this->boards; - } - -} diff --git a/Symfony/src/Codebender/LibraryBundle/Entity/ExternalLibrary.php b/Symfony/src/Codebender/LibraryBundle/Entity/ExternalLibrary.php deleted file mode 100644 index a2222ca3..00000000 --- a/Symfony/src/Codebender/LibraryBundle/Entity/ExternalLibrary.php +++ /dev/null @@ -1,443 +0,0 @@ -id; - } - - /** - * Set humanName - * - * @param string $humanName - * @return ExternalLibrary - */ - public function setHumanName($humanName) - { - $this->humanName = $humanName; - - return $this; - } - - /** - * Get humanName - * - * @return string - */ - public function getHumanName() - { - return $this->humanName; - } - - /** - * Set machineName - * - * @param string $machineName - * @return ExternalLibrary - */ - public function setMachineName($machineName) - { - $this->machineName = $machineName; - - return $this; - } - - /** - * Get machineName - * - * @return string - */ - public function getMachineName() - { - return $this->machineName; - } - - /** - * Set description - * - * @param string $description - * @return ExternalLibrary - */ - public function setDescription($description) - { - $this->description = $description; - - return $this; - } - - /** - * Get description - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Set owner - * - * @param string $owner - * @return ExternalLibrary - */ - public function setOwner($owner) - { - $this->owner = $owner; - - return $this; - } - - /** - * Get owner - * - * @return string - */ - public function getOwner() - { - return $this->owner; - } - - /** - * Set repo - * - * @param string $repo - * @return ExternalLibrary - */ - public function setRepo($repo) - { - $this->repo = $repo; - - return $this; - } - - /** - * Get repo - * - * @return string - */ - public function getRepo() - { - return $this->repo; - } - - /** - * Set branch - * - * @param string $branch - * @return ExternalLibrary - */ - public function setBranch($branch) - { - $this->branch = $branch; - return $this; - } - - /** - * Get branch - * - * @return string - */ - public function getBranch() - { - return $this->branch; - } - - /** - * Set inRepoPath - * - * @param string $inRepoPath - * @return ExternalLibrary - */ - public function setInRepoPath($inRepoPath) - { - $this->inRepoPath = $inRepoPath; - return $this; - } - - /** - * Get inRepoPath - * - * @return string - */ - public function getInRepoPath() - { - return $this->inRepoPath; - } - - /** - * Set notes - * - * @param string $notes - * @return ExternalLibrary - */ - public function setNotes($notes) - { - $this->notes = $notes; - return $this; - } - - /** - * Get notes - * - * @return string - */ - public function getNotes() - { - return $this->notes; - } - - /** - * Set verified - * - * @param boolean $verified - * @return ExternalLibrary - */ - public function setVerified($verified) - { - $this->verified = $verified; - - return $this; - } - - /** - * Get verified - * - * @return boolean - */ - public function getVerified() - { - return $this->verified; - } - - /** - * Set active - * - * @param boolean $active - * @return ExternalLibrary - */ - public function setActive($active) - { - $this->active = $active; - - return $this; - } - - /** - * Get active - * - * @return boolean - */ - public function getActive() - { - return $this->active; - } - - /** - * Set lastCommit - * - * @param string $lastCommit - * @return ExternalLibrary - */ - public function setLastCommit($lastCommit) - { - $this->lastCommit = $lastCommit; - - return $this; - } - - /** - * Get verified - * - * @return string - */ - public function getLastCommit() - { - return $this->lastCommit; - } - - /** - * Set url - * - * @param string $url - * @return ExternalLibrary - */ - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - - /** - * Get url - * - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * Set sourceUrl - * - * @param string $sourceUrl - * @return ExternalLibrary - */ - public function setSourceUrl($sourceUrl) - { - $this->sourceUrl = $sourceUrl; - - return $this; - } - - /** - * Get sourceUrl - * - * @return string - */ - public function getSourceUrl() - { - return $this->sourceUrl; - } - - /** - * Get the metadata of the library - * - * @return array - */ - public function getLiraryMeta() - { - return array( - 'humanName' => $this->getHumanName(), - 'description' => $this->getDescription(), - 'verified' => $this->getVerified(), - 'gitOwner' => $this->getOwner(), - 'gitRepo' => $this->getRepo(), - 'url' => $this->getUrl(), - 'active' => $this->getActive(), - 'sourceUrl' => $this->getSourceUrl(), - 'gitBranch' => $this->getBranch(), - 'gitLastCommit' => $this->getLastCommit(), - 'gitInRepoPath' => $this->getInRepoPath(), - 'libraryNotes' => $this->getNotes() - ); - } -}