Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into epic/ORO-845_expres…
Browse files Browse the repository at this point in the history
…sion_editor
  • Loading branch information
webevt committed Oct 20, 2023
2 parents 7d0f207 + f90811e commit a3cef65
Show file tree
Hide file tree
Showing 144 changed files with 5,831 additions and 1,542 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"oro/doctrine-extensions": "~2.0.2",
"ezyang/htmlpurifier": "~4.16.0",
"xemlock/htmlpurifier-html5": "0.1.10",
"hwi/oauth-bundle": "~1.4.2",
"hwi/oauth-bundle": "2.0.0-BETA3",
"kriswallsmith/buzz": "~1.2.0",
"matomo/device-detector": "~6.0.6",
"symfony/polyfill-php70": "1.*",
Expand Down
2 changes: 1 addition & 1 deletion dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"oro/doctrine-extensions": "~2.0.2",
"ezyang/htmlpurifier": "~4.16.0",
"xemlock/htmlpurifier-html5": "0.1.10",
"hwi/oauth-bundle": "~1.4.2",
"hwi/oauth-bundle": "2.0.0-BETA3",
"kriswallsmith/buzz": "~1.2.0",
"matomo/device-detector": "~6.0.6",
"symfony/polyfill-php70": "1.*",
Expand Down
104 changes: 44 additions & 60 deletions dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ff8dbf74f802c9900d1df9a74a252387",
"content-hash": "ef3394a1e7035afe6e4923beb17eb9e1",
"packages": [
{
"name": "ass/xmlsecurity",
Expand Down Expand Up @@ -3060,88 +3060,66 @@
},
{
"name": "hwi/oauth-bundle",
"version": "1.4.5",
"version": "2.0.0-BETA3",
"source": {
"type": "git",
"url": "https://github.com/hwi/HWIOAuthBundle.git",
"reference": "bc4e5ecf43d6177576fc0776a92fe5e3c856c3df"
"reference": "208ce9c33d2eac2eea16d1d94275b8ecc2f1a50b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hwi/HWIOAuthBundle/zipball/bc4e5ecf43d6177576fc0776a92fe5e3c856c3df",
"reference": "bc4e5ecf43d6177576fc0776a92fe5e3c856c3df",
"url": "https://api.github.com/repos/hwi/HWIOAuthBundle/zipball/208ce9c33d2eac2eea16d1d94275b8ecc2f1a50b",
"reference": "208ce9c33d2eac2eea16d1d94275b8ecc2f1a50b",
"shasum": ""
},
"require": {
"php": "^7.3 || ^8.0",
"php-http/client-common": "^2.0",
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.0",
"php-http/httplug": "^2.0",
"php-http/message-factory": "^1.0",
"psr/http-message": "^1.0",
"symfony/form": "^4.4|^5.1",
"symfony/framework-bundle": "^4.4|^5.1",
"symfony/options-resolver": "^4.4|^5.1",
"symfony/security-bundle": "^4.4|^5.1",
"symfony/templating": "^4.4|^5.1",
"symfony/yaml": "^4.4|^5.1"
"php": "^7.4 || ^8.0",
"symfony/deprecation-contracts": "^2.5 || ^3.0",
"symfony/form": "^5.4 || ^6.1",
"symfony/framework-bundle": "^5.4 || ^6.1",
"symfony/http-client": "^5.4 || ^6.1",
"symfony/options-resolver": "^5.4 || ^6.1",
"symfony/security-bundle": "^5.4 || ^6.1"
},
"conflict": {
"symfony/cache": "^6.0",
"symfony/config": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/doctrine-bridge": "^6.0",
"symfony/error-handler": "^6.0",
"symfony/http-foundation": "^6.0",
"symfony/password-hasher": "^6.0",
"symfony/property-info": "^6.0",
"symfony/security-core": "^6.0",
"symfony/security-csrf": "^6.0",
"symfony/security-http": "^6.0",
"symfony/twig-bridge": "^6.0",
"twig/twig": "<1.34"
"twig/twig": "<1.43|>=2.0,<2.13"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.0",
"doctrine/orm": "^2.6.4",
"friendsofphp/php-cs-fixer": "^3.0",
"friendsofsymfony/user-bundle": "^2.1",
"php-http/guzzle6-adapter": "^2.0",
"php-http/httplug-bundle": "^1.7",
"phpstan/phpstan": "^0.12.91",
"phpunit/phpunit": "^9.5.5",
"symfony/browser-kit": "^4.4|^5.1",
"symfony/css-selector": "^4.4|^5.1",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/orm": "^2.9",
"firebase/php-jwt": "^6.8",
"friendsofphp/php-cs-fixer": "^3.23",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^9.6.11",
"symfony/browser-kit": "^5.4 || ^6.1",
"symfony/css-selector": "^5.4 || ^6.1",
"symfony/monolog-bundle": "^3.4",
"symfony/phpunit-bridge": "^5.3",
"symfony/property-access": "^4.4|^5.1",
"symfony/stopwatch": "^5.1",
"symfony/translation": "^4.4|^5.1",
"symfony/twig-bundle": "^4.4|^5.1",
"symfony/validator": "^4.4|^5.1"
"symfony/phpunit-bridge": "^5.4 || ^6.1",
"symfony/property-access": "^5.4 || ^6.1",
"symfony/stopwatch": "^5.4 || ^6.1",
"symfony/translation": "^5.4 || ^6.1",
"symfony/twig-bundle": "^5.4 || ^6.1",
"symfony/validator": "^5.4 || ^6.1",
"symfony/yaml": "^5.4 || ^6.1"
},
"suggest": {
"doctrine/doctrine-bundle": "to use Doctrine user provider",
"friendsofsymfony/user-bundle": "to connect FOSUB with this bundle",
"php-http/httplug-bundle": "to provide required HTTP client with ease.",
"firebase/php-jwt": "to use JWT utility functions",
"symfony/property-access": "to use FOSUB integration with this bundle",
"symfony/twig-bundle": "to use the Twig hwi_oauth_* functions"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-1.4": "1.4-dev"
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"HWI\\Bundle\\OAuthBundle\\": ""
},
"exclude-from-classmap": [
"/Test/",
"/Tests/"
]
"HWI\\Bundle\\OAuthBundle\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
Expand All @@ -3165,8 +3143,8 @@
"homepage": "https://github.com/hwi/HWIOAuthBundle/contributors"
}
],
"description": "Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony2.",
"homepage": "http://github.com/hwi/HWIOAuthBundle",
"description": "Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony.",
"homepage": "https://github.com/hwi/HWIOAuthBundle",
"keywords": [
"37signals",
"Authentication",
Expand Down Expand Up @@ -3236,9 +3214,15 @@
],
"support": {
"issues": "https://github.com/hwi/HWIOAuthBundle/issues",
"source": "https://github.com/hwi/HWIOAuthBundle/tree/1.4.5"
"source": "https://github.com/hwi/HWIOAuthBundle/tree/2.0.0-BETA3"
},
"time": "2021-12-08T13:27:40+00:00"
"funding": [
{
"url": "https://github.com/stloyd",
"type": "github"
}
],
"time": "2023-08-20T17:29:00+00:00"
},
{
"name": "imagine/imagine",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getActivityContext($class, $id)
return $result;
}

$targets = $entity->getActivityTargets();
$targets = $this->getActivityTargets($entity);
$entityProvider = $this->configManager->getProvider('entity');

foreach ($targets as $target) {
Expand Down Expand Up @@ -124,6 +124,11 @@ function ($a, $b) {
return $result;
}

protected function getActivityTargets(object $entity): array
{
return $entity->getActivityTargets();
}

/**
* @param string $targetClass The FQCN of the activity target entity
* @param int $targetId The identifier of the activity target entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Oro\Bundle\ActivityBundle\Handler;

use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityNotFoundException;
use Doctrine\Persistence\ManagerRegistry;
Expand All @@ -15,14 +16,9 @@
*/
class ActivityEntityDeleteHandler
{
/** @var ManagerRegistry */
private $doctrine;

/** @var ActivityManager */
private $activityManager;

/** @var ActivityEntityDeleteHandlerExtensionInterface */
private $extension;
private ManagerRegistry $doctrine;
private ActivityManager $activityManager;
private ActivityEntityDeleteHandlerExtensionInterface $extension;

public function __construct(
ManagerRegistry $doctrine,
Expand All @@ -35,7 +31,7 @@ public function __construct(
}

/**
* Deletes an activity entity associations that is represented by the given identifier.
* Deletes an activity entity association that is represented by the given identifier.
*
* @param RelationIdentifier $id The activity entity association identifier
* @param bool $flush Whether to call flush() method of an entity manager
Expand All @@ -59,12 +55,33 @@ public function delete(RelationIdentifier $id, bool $flush = true): void
throw new EntityNotFoundException();
}

$this->extension->assertDeleteGranted($entity, $targetEntity);
$this->deleteActivityAssociation($entity, $targetEntity, $flush);
}

$this->activityManager->removeActivityTarget($entity, $targetEntity);
/**
* Deletes an association between the given activity entity and the given target entity.
*
* @param ActivityInterface $activityEntity The activity entity
* @param object $targetEntity The entity associated with the activity entity
* @param bool $flush Whether to call flush() method of an entity manager
*
* @return bool TRUE if the association was removed; otherwise, FALSE
*
* @throws AccessDeniedException if the delete operation is forbidden
*/
public function deleteActivityAssociation(
ActivityInterface $activityEntity,
object $targetEntity,
bool $flush = true
): bool {
$this->extension->assertDeleteGranted($activityEntity, $targetEntity);

$result = $this->activityManager->removeActivityTarget($activityEntity, $targetEntity);

if ($flush) {
$em->flush();
$this->doctrine->getManagerForClass(ClassUtils::getClass($activityEntity))->flush();
}

return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ define(function(require) {
},

initView: function() {
this.contextsView = new ActivityContextActivityView(this.getViewOptions());
},

getViewOptions: function() {
const items = typeof this.options.contextTargets === 'undefined' ? false : this.options.contextTargets;
const editable = typeof this.options.editable === 'undefined' ? false : this.options.editable;
this.contextsView = new ActivityContextActivityView({
return {
contextTargets: items,
entityId: this.options.entityId,
el: this.options._sourceElement,
inputName: this.options.inputName,
target: this.options.target,
activityClass: this.options.activityClassAlias,
editable: editable
});
};
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ define(function(require) {

url: null,

model: ActivityContextActivityModel,
model: function(attributes, options) {
if (typeof options.deleteRoute !== 'undefined') {
options.route = options.deleteRoute;
delete options.deleteRoute;
}
return new ActivityContextActivityModel(attributes, options);
},

/**
* @inheritdoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ define(function(require) {
* @export oroactivity/js/app/models/activity-context-activity-model
*/
const ActivityContextActivityModel = BaseModel.extend({
route: 'oro_api_delete_activity_relation',

defaults: {
entity: '',
className: '',
Expand All @@ -22,6 +24,19 @@ define(function(require) {
ActivityContextActivityModel.__super__.constructor.apply(this, args);
},

/**
* @inheritdoc
*/
initialize: function(data, options) {
if (typeof options.route !== 'undefined') {
this.route = options.route;
}
ActivityContextActivityModel.__super__.initialize.call(this, data, options);
},

/**
* @inheritdoc
*/
url: function() {
const param = {
activity: this.get('activityClassAlias'),
Expand All @@ -30,7 +45,7 @@ define(function(require) {
entityId: this.get('targetId')
};

return routing.generate('oro_api_delete_activity_relation', param);
return routing.generate(this.route, param);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ define([
* @export oroactivity/js/app/views/activity-context-activity-view
*/
const ActivityContextActivityView = BaseView.extend({
options: {},
options: {
getRoute: 'oro_api_get_activity_context',
deleteRoute: 'oro_api_delete_activity_relation'
},

events: {},

Expand All @@ -42,7 +45,7 @@ define([
this.collection.reset();
for (const i in this.options.contextTargets) {
if (this.options.contextTargets.hasOwnProperty(i)) {
this.collection.add(this.options.contextTargets[i]);
this.add(this.options.contextTargets[i]);
}
}
}
Expand All @@ -62,11 +65,11 @@ define([
},

add: function(model) {
this.collection.add(model);
this.collection.add(model, {deleteRoute: this.options.deleteRoute});
},

doRefresh: function() {
const url = routing.generate('oro_api_get_activity_context', {
const url = routing.generate(this.options.getRoute, {
activity: this.options.activityClass,
id: this.options.entityId
});
Expand All @@ -77,7 +80,7 @@ define([
url: url,
success: function(r) {
collection.reset();
collection.add(r);
self.add(r);
},
complete: function() {
self.render();
Expand Down
Loading

0 comments on commit a3cef65

Please sign in to comment.