-
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 pull request #741 from UN-OCHA/release-versions/v1.4.2
release versions/v1.4.2
- Loading branch information
Showing
4 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
html/modules/custom/ghi_base_objects/ghi_base_objects.deploy.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,37 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Deploy functions for GHI Base objects. | ||
*/ | ||
|
||
use Drupal\Core\Url; | ||
use Drupal\menu_link_content\Entity\MenuLinkContent; | ||
|
||
/** | ||
* Update links in the admin menu. | ||
*/ | ||
function ghi_base_objects_deploy_base_object_bundles_admin_menu_2() { | ||
$types = \Drupal::entityTypeManager()->getStorage('base_object_type')->loadMultiple(); | ||
usort($types, function ($a, $b) { | ||
return strnatcasecmp($a->label(), $b->label()); | ||
}); | ||
foreach (array_values($types) as $weight => $type) { | ||
$route_name = 'view.base_objects.' . $type->id(); | ||
try { | ||
\Drupal::service('router.route_provider')->getRouteByName($route_name); | ||
} | ||
catch (Exception $e) { | ||
continue; | ||
} | ||
MenuLinkContent::create([ | ||
'title' => $type->label(), | ||
'link' => [ | ||
'uri' => 'internal:' . Url::fromRoute($route_name)->toString(), | ||
], | ||
'menu_name' => 'admin', | ||
'parent' => 'base_object.collection', | ||
'weight' => $weight, | ||
])->save(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
html/modules/custom/ghi_base_objects/src/Entity/BaseObjectAwareEntityInterface.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,26 @@ | ||
<?php | ||
|
||
namespace Drupal\ghi_base_objects\Entity; | ||
|
||
/** | ||
* Defines an interface for entities that have a connection with a base object. | ||
*/ | ||
interface BaseObjectAwareEntityInterface { | ||
|
||
/** | ||
* Get the base object that is connected to the entity. | ||
* | ||
* @return \Drupal\ghi_base_objects\Entity\BaseObjectInterface | ||
* The base object connected to the entity. | ||
*/ | ||
public function getBaseObject(); | ||
|
||
/** | ||
* Get the base object type associated with this bundle. | ||
* | ||
* @return \Drupal\ghi_base_objects\Entity\BaseObjectTypeInterface | ||
* The base object type. | ||
*/ | ||
public static function getBaseObjectType(); | ||
|
||
} |
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