Skip to content

Commit

Permalink
Fix doctrine proxy and UI for organization members (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed May 4, 2020
1 parent 673037d commit fcd08cd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
parameters:
excludes_analyse:
- src/Entity/Organization.php
ignoreErrors:
-
message: "#^Strict comparison using \\!\\=\\= between string and null will always evaluate to true\\.$#"
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function overview(Organization $organization): Response
public function packages(Organization $organization, Request $request): Response
{
$count = $this->packageQuery->count($organization->id());
if ($count === 0) {
if ($count === 0 && $organization->isOwner($this->getUser()->id()->toString())) {
return $this->redirectToRoute('organization_package_new', ['organization' => $organization->alias()]);
}

Expand Down
16 changes: 8 additions & 8 deletions src/Entity/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,46 @@ class Organization
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
*/
private UuidInterface $id;
private ?UuidInterface $id = null;

/**
* @ORM\Column(type="datetime_immutable")
*/
private \DateTimeImmutable $createdAt;
private ?\DateTimeImmutable $createdAt = null;

/**
* @ORM\Column(type="string", length=255)
*/
private string $name;
private ?string $name = null;

/**
* @ORM\Column(type="string", unique=true, length=255)
*/
private string $alias;
private ?string $alias = null;

/**
* @var Collection<int,Package>|Package[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Package", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $packages;
private ?Collection $packages = null;

/**
* @var Collection<int,Token>|Token[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Token", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $tokens;
private ?Collection $tokens = null;

/**
* @var Collection<int,Invitation>|Invitation[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Invitation", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $invitations;
private ?Collection $invitations = null;

/**
* @var Collection<int,Member>|Member[]
* @ORM\OneToMany(targetEntity="Buddy\Repman\Entity\Organization\Member", mappedBy="organization", cascade={"persist"}, orphanRemoval=true)
*/
private Collection $members;
private ?Collection $members = null;

public function __construct(UuidInterface $id, User $owner, string $name, string $alias)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Form/Type/Organization/InviteMemberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'constraints' => [
new NotNull(),
],
'attr' => [
'class' => 'form-control selectpicker',
'data-style' => 'btn-secondary',
],
])
->add('invite', SubmitType::class)
;
Expand Down
6 changes: 3 additions & 3 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
</li>
<li class="nav-item">
<a class="nav-link {{ current_route == 'organization_members' ? 'active' : '' }}" href="{{ path('organization_members', {"organization":organization.alias}) }}">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
<span class="nav-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
</span>
<span class="d-none d-sm-block">Members</span>
</a>
</li>
Expand Down
4 changes: 4 additions & 0 deletions templates/organization/packages.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
</span>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center">no packages added</td>
</tr>
{% endfor %}
</tbody>
</table>
Expand Down

0 comments on commit fcd08cd

Please sign in to comment.