mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-04 23:44:33 +02:00
Added an PHP CS fixer config file and applied it to files.
We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
parent
89258bc102
commit
e557bdedd5
210 changed files with 2099 additions and 2742 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,16 +17,14 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\EntityListeners;
|
||||
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
use App\Services\Attachments\AttachmentReverseSearch;
|
||||
use App\Services\Attachments\AttachmentPathResolver;
|
||||
use App\Services\Attachments\AttachmentReverseSearch;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
||||
use Doctrine\ORM\Mapping\PostRemove;
|
||||
|
@ -35,7 +33,6 @@ use Doctrine\ORM\Mapping\PreUpdate;
|
|||
/**
|
||||
* This listener watches for changes on attachments and deletes the files associated with an attachment, that are not
|
||||
* used any more. This can happens after an attachment is delteted or the path is changed.
|
||||
* @package App\EntityListeners
|
||||
*/
|
||||
class AttachmentDeleteListener
|
||||
{
|
||||
|
@ -52,8 +49,6 @@ class AttachmentDeleteListener
|
|||
|
||||
/**
|
||||
* Removes the file associated with the attachment, if the file associated with the attachment changes.
|
||||
* @param Attachment $attachment
|
||||
* @param PreUpdateEventArgs $event
|
||||
*
|
||||
* @PreUpdate
|
||||
*/
|
||||
|
@ -73,9 +68,6 @@ class AttachmentDeleteListener
|
|||
/**
|
||||
* Removes the file associated with the attachment, after the attachment was deleted.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param LifecycleEventArgs $event
|
||||
*
|
||||
* @PostRemove
|
||||
*/
|
||||
public function postRemoveHandler(Attachment $attachment, LifecycleEventArgs $event)
|
||||
|
@ -87,9 +79,8 @@ class AttachmentDeleteListener
|
|||
|
||||
$file = $this->attachmentHelper->attachmentToFile($attachment);
|
||||
//Only delete if the attachment has a valid file.
|
||||
if ($file !== null) {
|
||||
if (null !== $file) {
|
||||
$this->attachmentReverseSearch->deleteIfNotUsed($file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,20 +17,16 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\EntityListeners;
|
||||
|
||||
|
||||
use App\Entity\Base\DBElement;
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\UserCacheKeyGenerator;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PostFlushEventArgs;
|
||||
use Doctrine\ORM\Event\PreFlushEventArgs;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Contracts\Cache\TagAwareCacheInterface;
|
||||
|
||||
|
@ -49,15 +45,12 @@ class TreeCacheInvalidationListener
|
|||
* @ORM\PostUpdate()
|
||||
* @ORM\PostPersist()
|
||||
* @ORM\PostRemove()
|
||||
*
|
||||
* @param DBElement $element
|
||||
* @param LifecycleEventArgs $event
|
||||
*/
|
||||
public function invalidate(DBElement $element, LifecycleEventArgs $event)
|
||||
{
|
||||
//If an element was changed, then invalidate all cached trees with this element class
|
||||
if ($element instanceof StructuralDBElement) {
|
||||
$secure_class_name = str_replace("\\", '_', get_class($element));
|
||||
$secure_class_name = str_replace('\\', '_', \get_class($element));
|
||||
$this->cache->invalidateTags([$secure_class_name]);
|
||||
}
|
||||
|
||||
|
@ -69,10 +62,9 @@ class TreeCacheInvalidationListener
|
|||
|
||||
/* If any group change, then invalidate all cached trees. Users Permissions can be inherited from groups,
|
||||
so a change in any group can cause big permisssion changes for users. So to be sure, invalidate all trees */
|
||||
if($element instanceof Group) {
|
||||
$tag = "groups";
|
||||
if ($element instanceof Group) {
|
||||
$tag = 'groups';
|
||||
$this->cache->invalidateTags([$tag]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue