Skip to content

Commit

Permalink
Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars77 authored and github-actions[bot] committed Mar 16, 2023
1 parent b429bad commit 169153c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php

/**
* Studio1 Kommunikation GmbH
*
* This source file is available under following license:
* - GNU General Public License v3.0 (GNU GPLv3)
*
* @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)
* @license https://www.gnu.org/licenses/gpl-3.0.txt
*/

namespace Studio1\WorkflowExtendBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down
14 changes: 12 additions & 2 deletions src/DependencyInjection/WorkflowExtendExtension.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<?php

/**
* Studio1 Kommunikation GmbH
*
* This source file is available under following license:
* - GNU General Public License v3.0 (GNU GPLv3)
*
* @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)
* @license https://www.gnu.org/licenses/gpl-3.0.txt
*/

namespace Studio1\WorkflowExtendBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* This is the class that loads and manages your bundle configuration.
Expand Down
34 changes: 28 additions & 6 deletions src/EventSubscriber/SetAttributeSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<?php

/**
* Studio1 Kommunikation GmbH
*
* This source file is available under following license:
* - GNU General Public License v3.0 (GNU GPLv3)
*
* @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)
* @license https://www.gnu.org/licenses/gpl-3.0.txt
*/

namespace Studio1\WorkflowExtendBundle\EventSubscriber;

use Exception;
use Pimcore\AssetMetadataClassDefinitionsBundle\Helper;
use Pimcore\AssetMetadataClassDefinitionsBundle\Model\Collections;
use Pimcore\AssetMetadataClassDefinitionsBundle\Model\Configuration\Dao;
Expand All @@ -13,20 +24,16 @@
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Workflow\Event\Event;
use Symfony\Component\Workflow\Event\TransitionEvent;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\WorkflowEvents;
use Exception;

/**
* Class SetAttributeSubscriber
*/
class SetAttributeSubscriber implements EventSubscriberInterface
{

private LoggerInterface $workflowExtendBundleLogger;
private Transition $transition;
private string $workflowName;
Expand All @@ -35,6 +42,7 @@ class SetAttributeSubscriber implements EventSubscriberInterface

/**
* SetAttributeSubscriber constructor.
*
* @param LoggerInterface $workflowExtendBundleLogger
*/
public function __construct(LoggerInterface $workflowExtendBundleLogger)
Expand All @@ -44,6 +52,7 @@ public function __construct(LoggerInterface $workflowExtendBundleLogger)

/**
* Subscribe to events
*
* @return string[]
*/
public static function getSubscribedEvents(): array
Expand All @@ -55,8 +64,11 @@ public static function getSubscribedEvents(): array

/**
* Workflow transition event
*
* @param TransitionEvent $event
*
* @return void
*
* @throws Exception
*/
public function onWorkflowTransition(TransitionEvent $event): void
Expand Down Expand Up @@ -100,11 +112,13 @@ public function onWorkflowTransition(TransitionEvent $event): void

if (empty($class)) {
$this->log('Could not change data, no class given.', LogLevel::ERROR, true);

return;
}

if (empty($attribute)) {
$this->log('Could not change data, no attribute given.', LogLevel::ERROR, true);

return;
}

Expand All @@ -123,12 +137,15 @@ public function onWorkflowTransition(TransitionEvent $event): void

/**
* Handles data objects in workflow transtion
*
* @param DataObject $dataObject
* @param string $class
* @param string $attribute
* @param mixed $value
* @param array $languages
*
* @return void
*
* @throws Exception
*/
private function handleObject(DataObject $dataObject, string $class, string $attribute, mixed $value, array $languages = []): void
Expand All @@ -147,7 +164,6 @@ private function handleObject(DataObject $dataObject, string $class, string $att
throw new Exception('Attribute "' . $attribute . '" does not exist in DataObject class "' . $class . '"');
}


// set value for dataobject
if (!empty($languages)) {
foreach ($languages as $language) {
Expand All @@ -163,12 +179,15 @@ private function handleObject(DataObject $dataObject, string $class, string $att

/**
* Handles assets in workflow transtion
*
* @param Asset $asset
* @param string $class
* @param string $attribute
* @param mixed $value
* @param array $languages
*
* @return void
*
* @throws Exception
*/
private function handleAsset(Asset $asset, string $class, string $attribute, mixed $value, array $languages = []): void
Expand Down Expand Up @@ -214,7 +233,6 @@ private function handleAsset(Asset $asset, string $class, string $attribute, mix
$asset->save(['versionNote' => 'Workflow: ' . $this->workflowName . ' - Transition: ' . $this->transitionName . '(add metadata class)']);
}


// set the attribute in meta data
if (!empty($languages)) {
foreach ($languages as $language) {
Expand All @@ -231,10 +249,13 @@ private function handleAsset(Asset $asset, string $class, string $attribute, mix

/**
* Generic log function
*
* @param string $message
* @param $loglevel
* @param bool $throwError
*
* @return void
*
* @throws Exception
*/
private function log(string $message, $loglevel = LogLevel::INFO, bool $throwError = false): void
Expand All @@ -249,6 +270,7 @@ private function log(string $message, $loglevel = LogLevel::INFO, bool $throwErr
/**
* Fetch available metadata classes
* inspired by vendor/pimcore/asset-metadata-class-definitions/src/Controller/BackendController.php
*
* @return array
*/
private function getAvailableAssetMetaClasses(): array
Expand Down
13 changes: 11 additions & 2 deletions src/WorkflowExtendBundle.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<?php

namespace Studio1\WorkflowExtendBundle;
/**
* Studio1 Kommunikation GmbH
*
* This source file is available under following license:
* - GNU General Public License v3.0 (GNU GPLv3)
*
* @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)
* @license https://www.gnu.org/licenses/gpl-3.0.txt
*/

namespace Studio1\WorkflowExtendBundle;

use Pimcore\Extension\Bundle\AbstractPimcoreBundle;

Expand Down Expand Up @@ -40,4 +49,4 @@ public function getVersion()
{
return '1.0.0';
}
}
}

0 comments on commit 169153c

Please sign in to comment.