Skip to content

Commit 6e87308

Browse files
committed
🎨 tidy up
1 parent 49b9b55 commit 6e87308

10 files changed

Lines changed: 57 additions & 42 deletions

File tree

src/Entities/ContentType.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,44 @@ class ContentType
1414
{
1515
/**
1616
* @var int
17-
* @Id @Column(type="integer") @GeneratedValue */
17+
* @Id @Column(type="integer") @GeneratedValue
18+
*/
1819
private $id;
1920

2021
/**
2122
* @var Environment
22-
* @ManyToOne(targetEntity="Environment") */
23+
* @ManyToOne(targetEntity="Environment")
24+
*/
2325
private $environment;
2426

2527
/**
2628
* @var string
27-
* @Column(type="string") */
29+
* @Column(type="string")
30+
*/
2831
private $name;
2932

3033
/**
3134
* @var string
32-
* @Column(type="string") */
35+
* @Column(type="string")
36+
*/
3337
private $path;
3438

3539
/**
3640
* @var string
37-
* @Column(type="string") */
41+
* @Column(type="string")
42+
*/
3843
private $template;
3944

4045
/**
4146
* @var string
42-
* @Column(type="string") */
47+
* @Column(type="string")
48+
*/
4349
private $permalink;
4450

4551
/**
4652
* @var bool
47-
* @Column(type="boolean") */
53+
* @Column(type="boolean")
54+
*/
4855
private $enabled;
4956

5057
/**

src/Entities/Environment.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function getContentTypes()
4343
return $this->contentTypes;
4444
}
4545

46-
public function addContentType(ContentType $contentType) {
46+
public function addContentType(ContentType $contentType)
47+
{
4748
$this->contentTypes[] = $contentType;
4849
}
4950

@@ -52,7 +53,8 @@ public function getFiles()
5253
return $this->files;
5354
}
5455

55-
public function addFile(File $file) {
56+
public function addFile(File $file)
57+
{
5658
$this->files[] = $file;
5759
}
5860
}

src/Entities/File.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public function setEnvironment(Environment $environment)
116116
$this->environment = $environment;
117117
}
118118

119-
public function addFrontMatter(FrontMatter $frontMatter) {
119+
public function addFrontMatter(FrontMatter $frontMatter)
120+
{
120121
if ($this->frontMatter->contains($frontMatter)) {
121122
return;
122123
}

src/Entities/FrontMatter.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ class FrontMatter
1010
{
1111
/**
1212
* @var int
13-
* @Id @Column(type="integer") @GeneratedValue */
13+
* @Id @Column(type="integer") @GeneratedValue
14+
*/
1415
private $id;
1516

1617
/**
1718
* @var string
18-
* @Column(type="string") */
19+
* @Column(type="string")
20+
*/
1921
private $name;
2022

2123
/**
2224
* @var string
23-
* @Column(type="string") */
25+
* @Column(type="string")
26+
*/
2427
private $value;
2528

2629
/** @ManyToOne(targetEntity="File") */

src/Entities/Taxonomy.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ class Taxonomy
1515
/**
1616
* @var int
1717
*
18-
* @Id @Column(type="integer") @GeneratedValue */
18+
* @Id @Column(type="integer") @GeneratedValue
19+
*/
1920
private $id;
2021

2122
/**
2223
* @var string
2324
*
24-
* @Column(type="string") */
25+
* @Column(type="string")
26+
*/
2527
private $name;
2628

2729

@@ -74,7 +76,8 @@ public function getContentType()
7476
return $this->contentType;
7577
}
7678

77-
public function setContentType(ContentType $contentType) {
79+
public function setContentType(ContentType $contentType)
80+
{
7881
$this->contentType = $contentType;
7982
}
8083

src/Exporter.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@
44

55
use Doctrine\ORM\EntityManager;
66
use Doctrine\ORM\EntityManagerInterface;
7-
use PDO;
87
use Symfony\Component\Console\Output\OutputInterface;
98
use Tapestry\Entities\Collections\FlatCollection;
109
use Tapestry\Entities\Project;
11-
use Doctrine\DBAL\Connection;
1210
use Tapestry\Modules\ContentTypes\ContentTypeFactory;
1311
use Tapestry\Tapestry;
14-
use TapestryCloud\Database\Entities\ContentType;
1512
use TapestryCloud\Database\Entities\Environment;
16-
use TapestryCloud\Database\Entities\File;
1713
use TapestryCloud\Database\Synchronizes\ContentTypes;
1814
use TapestryCloud\Database\Synchronizes\Files;
1915
use TapestryCloud\Database\Hydrators\File as FileHydrator;
2016

21-
class Exporter {
17+
class Exporter
18+
{
2219
/**
2320
* @var EntityManagerInterface|EntityManager
2421
*/
@@ -40,7 +37,8 @@ public function __construct(EntityManagerInterface $entityManager, Tapestry $tap
4037

4138
}
4239

43-
public function export(Project $project) {
40+
public function export(Project $project)
41+
{
4442

4543
$this->output->writeln('[$] Syncing with database.');
4644

@@ -53,7 +51,7 @@ public function export(Project $project) {
5351
/** @var array $cmdOptions */
5452
$cmdOptions = $project->get('cmd_options');
5553

56-
if (! $environment = $this->entityManager->getRepository(Environment::class)->findOneBy(['name' => $cmdOptions['env']])) {
54+
if (!$environment = $this->entityManager->getRepository(Environment::class)->findOneBy(['name' => $cmdOptions['env']])) {
5755
$environment = new Environment();
5856
$environment->setName($cmdOptions['env']);
5957
$this->entityManager->persist($environment);

src/Hydrators/File.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class File extends Hydrator
1818
* @param \Tapestry\Entities\File $file
1919
* @param Environment|null $environment
2020
*/
21-
public function hydrate(Model $model, \Tapestry\Entities\File $file, Environment $environment = null)
21+
public function hydrate(Model $model, \Tapestry\Entities\File $file, Environment $environment = null)
2222
{
2323
$model->setUid($file->getUid());
2424
$model->setLastModified($file->getLastModified());
@@ -27,10 +27,10 @@ public function hydrate(Model $model, \Tapestry\Entities\File $file, Environmen
2727
$model->setPath($file->getPath());
2828
$model->setToCopy($file->isToCopy());
2929

30-
if (! $file->isToCopy()) {
30+
if (!$file->isToCopy()) {
3131
$frontMatter = new TapestryFrontMatter($file->getFileContent());
3232
$model->setContent($frontMatter->getContent());
33-
foreach($frontMatter->getData() as $key => $value) {
33+
foreach ($frontMatter->getData() as $key => $value) {
3434
$fmRecord = new FrontMatter();
3535
$fmRecord->setName($key);
3636
$fmRecord->setValue(json_encode($value));

src/ServiceProvider.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace TapestryCloud\Database;
4+
45
use Doctrine\DBAL\Connection;
56
use Doctrine\DBAL\DriverManager;
67
use Doctrine\ORM\EntityManager;
@@ -19,6 +20,7 @@ class ServiceProvider extends AbstractServiceProvider implements BootableService
1920
EntityManagerInterface::class,
2021
Connection::class
2122
];
23+
2224
/**
2325
* Use the register method to register items with the container via the
2426
* protected $this->container property or the `getContainer` method
@@ -29,13 +31,13 @@ class ServiceProvider extends AbstractServiceProvider implements BootableService
2931
public function register()
3032
{
3133

32-
$this->getContainer()->add(Connection::class, function() {
34+
$this->getContainer()->add(Connection::class, function () {
3335
/** @var Configuration $configuration */
3436
$configuration = $this->getContainer()->get(Configuration::class);
3537
return DriverManager::getConnection($configuration->get('plugins.database', []), new \Doctrine\DBAL\Configuration());
3638
});
3739

38-
$this->getContainer()->add(EntityManagerInterface::class, function() {
40+
$this->getContainer()->add(EntityManagerInterface::class, function () {
3941
/** @var Configuration $configuration */
4042
$configuration = $this->getContainer()->get(Configuration::class);
4143

@@ -49,12 +51,8 @@ public function register()
4951
)
5052
);
5153
});
52-
53-
// $this->getContainer()->add(Exporter::class, function() {
54-
//
55-
// return new Exporter();
56-
// });
5754
}
55+
5856
/**
5957
* Method will be invoked on registration of a service provider implementing
6058
* this interface. Provides ability for eager loading of Service Providers.

src/Synchronizes/ContentTypes.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ public function __construct(EntityManagerInterface $em)
2727
$this->em = $em;
2828
}
2929

30-
public function sync(ContentTypeFactory $contentTypeFactory, Environment $environment) {
31-
foreach($contentTypeFactory->all() as $contentType) {
32-
if (!$record = $this->em->getRepository(ContentType::class)->findOneBy(['name' => $contentType->getName(), 'environment' => $environment->getId()])){
30+
public function sync(ContentTypeFactory $contentTypeFactory, Environment $environment)
31+
{
32+
foreach ($contentTypeFactory->all() as $contentType) {
33+
if (!$record = $this->em->getRepository(ContentType::class)->findOneBy(['name' => $contentType->getName(), 'environment' => $environment->getId()])) {
3334
// INSERT
3435
$record = new ContentType();
3536
$record->hydrate($contentType, $environment);
@@ -49,9 +50,10 @@ public function sync(ContentTypeFactory $contentTypeFactory, Environment $enviro
4950
* @param TapestryTaxonomy[] $taxonomies
5051
* @param Environment $environment
5152
*/
52-
private function syncTaxonomyToContentType(ContentType $contentType, array $taxonomies, Environment $environment) {
53+
private function syncTaxonomyToContentType(ContentType $contentType, array $taxonomies, Environment $environment)
54+
{
5355
/** @var TapestryTaxonomy $taxonomy */
54-
foreach($taxonomies as $taxonomy) {
56+
foreach ($taxonomies as $taxonomy) {
5557
if (!$record = $this->em->getRepository(Taxonomy::class)->findOneBy(['name' => $taxonomy->getName()])) {
5658
$record = new Taxonomy();
5759
$record->hydrate($taxonomy);
@@ -64,7 +66,7 @@ private function syncTaxonomyToContentType(ContentType $contentType, array $taxo
6466
}
6567

6668
foreach ($taxonomy->getFileList() as $classification => $files) {
67-
if (! $classificationRecord = $this->em->getRepository(Classification::class)->findOneBy(['name' => $classification])){
69+
if (!$classificationRecord = $this->em->getRepository(Classification::class)->findOneBy(['name' => $classification])) {
6870
$classificationRecord = new Classification();
6971
$classificationRecord->setName($classification);
7072
$this->em->persist($classificationRecord);
@@ -73,9 +75,9 @@ private function syncTaxonomyToContentType(ContentType $contentType, array $taxo
7375
$classificationRecord->addTaxonomy($record);
7476
$this->em->flush();
7577

76-
foreach(array_keys($files) as $filename) {
78+
foreach (array_keys($files) as $filename) {
7779
/** @var File $file */
78-
if ($file = $this->em->getRepository(File::class)->findOneBy(['uid' => $filename, 'environment' => $environment->getId()])){
80+
if ($file = $this->em->getRepository(File::class)->findOneBy(['uid' => $filename, 'environment' => $environment->getId()])) {
7981
$file->addClassification($classificationRecord);
8082
$this->em->persist($file);
8183
}

src/Synchronizes/Files.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public function __construct(EntityManagerInterface $em, FileHydrator $fileHydrat
3232
$this->fileHydrator = $fileHydrator;
3333
}
3434

35-
public function sync(FlatCollection $files, Environment $environment) {
35+
public function sync(FlatCollection $files, Environment $environment)
36+
{
3637

3738
/** @var TapestryFile $file */
3839
foreach ($files as $file) {

0 commit comments

Comments
 (0)