forked from pimcore/pimcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/10.6' into 11.x
# Conflicts: # bundles/CoreBundle/src/Request/ParamConverter/DataObjectParamConverter.php # bundles/CoreBundle/src/Request/ParamConverter/DataObjectParamResolver.php # doc/Development_Documentation/02_MVC/00_Controller.md # doc/Development_Documentation/02_MVC/04_Routing_and_URLs/02_Custom_Routes.md # doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md # lib/Controller/Configuration/ResponseHeader.php # phpstan-baseline.neon
- Loading branch information
Showing
14 changed files
with
231 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
bundles/CoreBundle/src/Request/ParamConverter/DataObjectParamConverter.php
This file was deleted.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
bundles/CoreBundle/src/Request/ParamConverter/DataObjectParamResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\CoreBundle\Request\ParamConverter; | ||
|
||
use Pimcore\Model\DataObject\AbstractObject; | ||
use Pimcore\Model\DataObject\Concrete; | ||
use Pimcore\Request\Attribute\DataObjectParam; | ||
use Pimcore\Tool; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; | ||
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class DataObjectParamResolver implements ArgumentValueResolverInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @throws NotFoundHttpException When invalid data object ID given | ||
*/ | ||
public function resolve(Request $request, ArgumentMetadata $argument): iterable | ||
{ | ||
$options = $argument->getAttributes(DataObjectParam::class, ArgumentMetadata::IS_INSTANCEOF); | ||
|
||
if (!isset($options[0])) { | ||
$converters = $request->attributes->get('_converters'); | ||
$converter = $converters[0] ?? false; | ||
if ($converter instanceof ParamConverter) { | ||
trigger_deprecation( | ||
'pimcore/pimcore', | ||
'10.6', | ||
'Usage of @ParamConverter annotation is deprecated. please use #[DataObjectParam] argument attribute instead.' | ||
); | ||
$options[0] = new DataObjectParam($converter->getClass(),$converter->getOptions()['unpublished'] ?? null, $converter->getOptions()); | ||
} | ||
} | ||
|
||
$class = $options[0]->class ?? $argument->getType(); | ||
if (null === $class || !is_subclass_of($class, AbstractObject::class)) { | ||
return []; | ||
} | ||
|
||
$param = $argument->getName(); | ||
if (!$request->attributes->has($param)) { | ||
return []; | ||
} | ||
|
||
$value = $request->attributes->get($param); | ||
|
||
if (!$value && $argument->isNullable()) { | ||
$request->attributes->set($param, null); | ||
return []; | ||
} | ||
|
||
/** @var Concrete|null $object */ | ||
$object = $class::getById($value); | ||
if (!$object) { | ||
throw new NotFoundHttpException(sprintf('Invalid data object ID given for parameter "%s".', $param)); | ||
} elseif ( | ||
!$object->isPublished() | ||
&& !Tool::isElementRequestByAdmin($request, $object) | ||
&& (!isset($options[0]) || !$options[0]->unpublished) | ||
) { | ||
throw new NotFoundHttpException(sprintf('Data object for parameter "%s" is not published.', $param)); | ||
} | ||
|
||
$request->attributes->set($param, $object); | ||
|
||
return [$object]; | ||
} | ||
|
||
public function supports(Request $request, ArgumentMetadata $argument) | ||
{ | ||
if (null === $argument->getType()) { | ||
return false; | ||
} | ||
|
||
return is_subclass_of($argument->getType(), AbstractObject::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Controller\Attribute; | ||
|
||
use Pimcore\Controller\Configuration\ResponseHeader as BaseResponseHeader; | ||
|
||
/** | ||
* Allows to set HTTP headers on the response via attributes. The attribute will | ||
* be processed by ResponseHeaderListener which will set the HTTP headers on the | ||
* response. | ||
* | ||
* See ResponseHeaderBag for documentation on the fields. | ||
* | ||
*/ | ||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION)] | ||
final class ResponseHeader extends BaseResponseHeader | ||
{ | ||
} |
Oops, something went wrong.