Skip to content

Commit

Permalink
Merge pull request #26 from EstelleMyddleware/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
stlgaits authored Jun 16, 2022
2 parents 412fb21 + 3c925ed commit 96664f6
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"php":"8.1.4","version":"3.8.0:v3.8.0#cbad1115aac4b5c3c5540e7210d3c9fba2f81fa3","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"src\\DataFixtures\\AppFixtures.php":1933132425,"src\\DataFixtures\\CategoryFixtures.php":1037989051,"src\\DataFixtures\\ProductFixtures.php":2198566765,"src\\Entity\\Account.php":1383406685,"src\\Entity\\Category.php":2001429968,"src\\Entity\\Product.php":1479744619,"src\\Kernel.php":4115217777,"src\\Repository\\AccountRepository.php":3473817826,"src\\Repository\\CategoryRepository.php":2858896798,"src\\Repository\\ProductRepository.php":3375228323}}
{"php":"8.1.4","version":"3.8.0:v3.8.0#cbad1115aac4b5c3c5540e7210d3c9fba2f81fa3","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"src\\DataFixtures\\AppFixtures.php":1933132425,"src\\DataFixtures\\CategoryFixtures.php":1037989051,"src\\DataFixtures\\ProductFixtures.php":2198566765,"src\\Entity\\Account.php":2786707583,"src\\Entity\\Category.php":2001429968,"src\\Entity\\Product.php":1479744619,"src\\Kernel.php":4115217777,"src\\Repository\\AccountRepository.php":3473817826,"src\\Repository\\CategoryRepository.php":2858896798,"src\\Repository\\ProductRepository.php":3375228323,"src\\Entity\\User.php":1267292205,"src\\Repository\\UserRepository.php":1337344767}}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"nelmio/cors-bundle": "^2.2",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.6",
"stof/doctrine-extensions-bundle": "^1.7",
"symfony/asset": "6.1.*",
"symfony/console": "*",
"symfony/dotenv": "*",
Expand Down
232 changes: 231 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
];
7 changes: 7 additions & 0 deletions config/packages/stof_doctrine_extensions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Read the documentation: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html
# See the official DoctrineExtensions documentation for more details: https://github.com/doctrine-extensions/DoctrineExtensions/tree/main/doc
stof_doctrine_extensions:
default_locale: fr_FR
orm:
default:
timestampable: true
8 changes: 7 additions & 1 deletion src/Entity/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

#[ORM\Entity(repositoryClass: AccountRepository::class)]
#[ApiResource(
Expand All @@ -19,8 +21,10 @@
'formats' => ['json']
]
)]
#[UniqueEntity(fields: ['name'])]
class Account
{

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
Expand All @@ -39,13 +43,15 @@ class Account
private ?string $primaryEmail;

#[ORM\Column(type: 'datetime_immutable')]
#[Gedmo\Timestampable(on: 'create')]
private ?\DateTimeImmutable $createdAt;

#[ORM\Column(type: 'datetime_immutable')]
#[Gedmo\Timestampable(on: 'change', field: ['name', 'description', 'industry', 'primaryEmail', 'users'])]
private ?\DateTimeImmutable $updatedAt;

#[ORM\OneToMany(mappedBy: 'account', targetEntity: User::class, orphanRemoval: true)]
private $users;
private ArrayCollection $users;

public function __construct()
{
Expand Down
33 changes: 33 additions & 0 deletions src/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;

#[ORM\Entity(repositoryClass: CategoryRepository::class)]
#[ApiResource(
Expand Down Expand Up @@ -40,6 +41,14 @@ class Category
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Product::class)]
private ArrayCollection $products;

#[ORM\Column(type: 'datetime_immutable')]
#[Gedmo\Timestampable(on: 'create')]
private ?\DateTimeImmutable $createdAt;

#[ORM\Column(type: 'datetime_immutable')]
#[Gedmo\Timestampable(on: 'change', field: ['name', 'description', 'products'])]
private ?\DateTimeImmutable $updatedAt;

public function __construct()
{
$this->products = new ArrayCollection();
Expand Down Expand Up @@ -103,4 +112,28 @@ public function removeProduct(Product $product): self

return $this;
}

public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}

public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;

return $this;
}

public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}

public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;

return $this;
}
}
Loading

0 comments on commit 96664f6

Please sign in to comment.