Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an Organization entity type with a Farm bundle #849

Draft
wants to merge 29 commits into
base: 3.x
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a631df7
Initial organization entity type module.
mstenta May 15, 2024
7abe59b
Fix PHPCodesniffer errors.
mstenta May 15, 2024
eece848
Delete migrate source plugin.
mstenta May 15, 2024
b3f1e63
Remove unnecessary system module version constraints.
mstenta May 15, 2024
0aefdb7
Enable bundle plugins for the Organization entity type.
mstenta May 15, 2024
23cf780
Enforce entity reference integrity on organization reference fields.
mstenta May 15, 2024
3add9d7
Add base fields to organization entities: data, file, image, notes.
mstenta May 15, 2024
0a203e0
Initial Farm organization type.
mstenta May 15, 2024
6038333
Add support for organization reference fields in farm_field.factory.
mstenta May 15, 2024
a9a1a94
Add a farm reference field to assets and logs.
mstenta May 15, 2024
7bc9a87
Document organizations in the data model.
mstenta May 15, 2024
7552f4e
Document where to find example bundle declarations in farmOS.
mstenta May 29, 2024
70a3387
Add a "Users" base field to Organizations.
mstenta May 28, 2024
bc0bcd3
Remove Farm reference from logs.
mstenta May 28, 2024
ddbd530
Put farm reference field in Meta sidebar fieldset.
mstenta May 28, 2024
484161e
Put farm field display in second region.
mstenta May 28, 2024
9e51c57
Move organization primary tasks to secondary tasks and disable Drupal…
mstenta May 28, 2024
aeb9e97
Enable Gin content form on organization entities.
mstenta May 28, 2024
24e9a22
Add a View of Organizations under Setup menu.
mstenta May 28, 2024
53d0b66
Add organization status filter
paul121 Jul 11, 2024
031aa8f
Sort by organization name
paul121 Jul 11, 2024
a518bc1
Add organization action link
paul121 Jul 11, 2024
2827a9a
Add asset tab to farm organization page
paul121 Jul 11, 2024
342c0d4
Use FarmEntityViewsData to support additional field types in views
paul121 Jul 11, 2024
29bee45
Set owner of cloned organizations
paul121 Jul 11, 2024
a2f52c0
Remove roles from Views remember_roles config.
mstenta Jul 12, 2024
e582ba9
Add a description to the Organizations menu item.
mstenta Jul 12, 2024
8ff93b1
Change farm from a bundle field to a base field.
mstenta Jul 12, 2024
f669dcb
Add support for organization entity type in farm_role module.
mstenta Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Set owner of cloned organizations
  • Loading branch information
paul121 authored and mstenta committed Nov 21, 2024
commit 29bee45968e42433e5e2593750335dfbd7b59c16
42 changes: 42 additions & 0 deletions modules/core/organization/src/Plugin/Action/OrganizationClone.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace Drupal\organization\Plugin\Action;

use Drupal\Core\Action\Plugin\Action\EntityActionBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\organization\Entity\OrganizationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Action that clones an organization.
Expand All @@ -17,13 +19,53 @@
*/
class OrganizationClone extends EntityActionBase {

/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;

/**
* Constructs an OrganizationClone object.
*
* @param mixed[] $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, AccountInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
$this->currentUser = $current_user;
}

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity_type.manager'),
$container->get('current_user'),
);
}

/**
* {@inheritdoc}
*/
public function execute(OrganizationInterface $organization = NULL) {
if ($organization) {
$cloned_organization = $organization->createDuplicate();
$new_name = $organization->getName() . ' ' . $this->t('(clone of organization #@id)', ['@id' => $organization->id()]);
$cloned_organization->setOwnerId($this->currentUser->id());
$cloned_organization->setName($new_name);
$cloned_organization->save();
$this->messenger()->addMessage($this->t('Organization saved: <a href=":uri">%organization_label</a>', [':uri' => $cloned_organization->toUrl()->toString(), '%organization_label' => $cloned_organization->label()]));
Expand Down