update status of child metadata according to the compound metadata.

This commit is contained in:
vnmedeiros 2020-04-23 20:00:56 -03:00
parent 31b3e1a965
commit db86c1cb2a
1 changed files with 14 additions and 1 deletions

View File

@ -83,7 +83,20 @@ class Compound extends Metadata_Type {
if( $metadatum_type_object instanceof \Tainacan\Metadata_Types\Compound ) { if( $metadatum_type_object instanceof \Tainacan\Metadata_Types\Compound ) {
$options = $metadatum->get_metadata_type_options(); $options = $metadatum->get_metadata_type_options();
if( isset( $options['parent'] ) ) {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$childrens = $Tainacan_Metadata->fetch( ['parent' => $options['parent'] ], "OBJECT" );
foreach ($childrens as $child) {
if ($child->get_status() != $metadatum->get_status()) {
$child->set_status( $metadatum->get_status() );
if( $child->validate() ) {
$Tainacan_Metadata->update( $child );
}
}
}
}
if( isset( $options['parent'] ) ) if( isset( $options['parent'] ) )
return; return;